diff --git a/Project.toml b/Project.toml index 0a58776..64e45be 100644 --- a/Project.toml +++ b/Project.toml @@ -23,6 +23,7 @@ Dates = "1.6" DefaultApplication = "1" DocStringExtensions = "0.8, 0.9" EzXML = "1" +FileCmp = "1" LibGit2 = "1.6" OrderedCollections = "1" Pkg = "1.6" @@ -32,6 +33,7 @@ julia = "1.6" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +FileCmp = "343a5541-a696-4ae7-8102-bc61c09e1896" [targets] -test = ["Test"] +test = ["Test","FileCmp"] diff --git a/test/dummy.css b/test/dummy.css new file mode 100644 index 0000000..a8cb6c2 --- /dev/null +++ b/test/dummy.css @@ -0,0 +1,4 @@ +body { + color: white; + background-color: black; +} diff --git a/test/runtests.jl b/test/runtests.jl index deec42b..d75f1ae 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,6 @@ using LocalCoverage, Test +using FileCmp + import Pkg Pkg.activate("./DummyPackage/") @@ -15,7 +17,8 @@ function test_coverage(pkg; run_test = true, test_args = [""], folder_list = ["src"], - file_list = []) + file_list = [], + css = nothing) @info "Testing coverage for $pkg" test_args folder_list file_list clean_coverage(pkg) @test isdir(LocalCoverage.pkgdir(pkg)) @@ -47,8 +50,10 @@ function test_coverage(pkg; if !isnothing(Sys.which("genhtml")) mktempdir() do dir - html_coverage(pkg, dir = dir) + html_coverage(pkg, dir = dir, css = css) @test isfile(joinpath(dir, "index.html")) + isnothing(css) || + @test filecmp(joinpath(dir, "gcov.css"), css) end end @@ -83,6 +88,11 @@ end folder_list = [joinpath(dirname(@__FILE__), "DummyPackage", "src", "corge")], file_list = [joinpath(dirname(@__FILE__), "DummyPackage", "src", "qux.jl")]) end + + @testset "custom CSS" begin + @test_throws TypeError test_coverage("DummyPackage", css=1) + test_coverage("DummyPackage", css=joinpath(dirname(@__FILE__), "dummy.css")) + end end @test LocalCoverage.find_gaps([nothing, 0, 0, 0, 2, 3, 0, nothing, 0, 3, 0, 6, 2]) ==