Skip to content

Commit c68902f

Browse files
committed
add failing test (take 2)
1 parent 42c8ac7 commit c68902f

File tree

6 files changed

+48
-4
lines changed

6 files changed

+48
-4
lines changed

Project.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
99
[weakdeps]
1010
FlameGraphs = "08572546-2f56-4bcf-ba4e-bab62c3a3f89"
1111

12+
[extensions]
13+
FlameGraphsExt = "FlameGraphs"
14+
1215
[compat]
1316
ExprTools = "0.1.0"
1417
FlameGraphs = "1"
18+
Pkg = "1"
1519
julia = "1.10"
1620

1721
[extras]
1822
FlameGraphs = "08572546-2f56-4bcf-ba4e-bab62c3a3f89"
1923
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
20-
21-
[extensions]
22-
FlameGraphsExt = "FlameGraphs"
24+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
2325

2426
[targets]
25-
test = ["Test", "FlameGraphs"]
27+
test = ["Test", "FlameGraphs", "Pkg"]

test/TestPkg/Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name = "TestPkg"
2+
uuid = "a1172fb3-f03b-46d1-aab3-7b5cb3128a7b"
3+
version = "0.1.0"
4+
5+
[deps]
6+
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"

test/TestPkg/src/TestPkg.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module TestPkg
2+
3+
using TimerOutputs
4+
5+
const TIMER = TimerOutput()
6+
7+
@timeit TIMER function abc()
8+
1 + 1
9+
end
10+
11+
end # module TestPkg

test/coverage_script.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# entrypoint to TestPkg to invoke `abc`
2+
using Pkg, TimerOutputs
3+
4+
Pkg.develop(; path=joinpath(pkgdir(TimerOutputs), "test", "TestPkg"))
5+
using TestPkg
6+
7+
TestPkg.abc()

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,3 +759,5 @@ end
759759
flamegraph(to)
760760
flamegraph(to, crop_root=true)
761761
end
762+
763+
include("test_coverage.jl")

test/test_coverage.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function find_cov_files()
2+
pkg = joinpath(pkgdir(TimerOutputs), "test", "TestPkg")
3+
return filter(endswith(".cov"), readdir(joinpath(pkg, "src"); join=true))
4+
end
5+
6+
# remove existing coverage
7+
foreach(rm, find_cov_files())
8+
9+
@testset "functions defined with `@timeit` macro generate code coverage" begin
10+
@test isempty(find_cov_files())
11+
12+
script = joinpath(pkgdir(TimerOutputs), "test", "coverage_script.jl")
13+
run(`julia --startup-file=no --project=$(pkgdir(TimerOutputs)) --check-bounds=yes --code-coverage $script`)
14+
15+
@test !isempty(find_cov_files())
16+
end

0 commit comments

Comments
 (0)