Skip to content

Commit

Permalink
Test custom CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
jagot committed Jul 26, 2024
1 parent 44eb65d commit 0f57ce8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]
4 changes: 4 additions & 0 deletions test/dummy.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
color: white;
background-color: black;
}
14 changes: 12 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using LocalCoverage, Test
using FileCmp

import Pkg

Pkg.activate("./DummyPackage/")
Expand All @@ -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))
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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]) ==
Expand Down

0 comments on commit 0f57ce8

Please sign in to comment.