From 195b5cc6f97ff23020f250526e109bb095b9a07b Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Tue, 21 May 2024 14:08:32 -0500 Subject: [PATCH 1/5] Define constant to `reporttests.jl` --- src/TestReports.jl | 3 +++ test/reporttests_script.jl | 38 +++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/TestReports.jl b/src/TestReports.jl index ee69277..add7cb1 100644 --- a/src/TestReports.jl +++ b/src/TestReports.jl @@ -16,6 +16,9 @@ using Test: AbstractTestSet, DefaultTestSet, Result, Pass, Fail, Error, Broken, import Test: finish, record +# Defined for use by users of this package +const RUNNER_FILE = abspath(joinpath(@__DIR__(), "..", "bin", "reporttests.jl")) + # Version specific imports @static if VERSION >= v"1.4.0" using Pkg.Operations: gen_target_project diff --git a/test/reporttests_script.jl b/test/reporttests_script.jl index 485ceef..5cce5c8 100644 --- a/test/reporttests_script.jl +++ b/test/reporttests_script.jl @@ -1,14 +1,24 @@ -script_runner = if VERSION >= v"1.7" - joinpath(pkgdir(TestReports), "bin", "reporttests.jl") +@testset "runner file" begin + @test isdefined(TestReports, :RUNNER_FILE) + @test isfile(TestReports.RUNNER_FILE) + + if Sys.islinux() + @test uperm(TestReports.RUNNER_FILE) & 0x01 != 0 + @test gperm(TestReports.RUNNER_FILE) & 0x01 != 0 + @test operm(TestReports.RUNNER_FILE) & 0x01 != 0 + end +end + +runner_cmd = if Sys.iswindows() + `julia $(TestReports.RUNNER_FILE) --` else - joinpath(@__DIR__(), "..", "bin", "reporttests.jl") + `$(TestReports.RUNNER_FILE)` end -script_runner_cmd = Sys.iswindows() ? `julia $script_runner --` : `$script_runner` test_script = "reporttests_testsets.jl" reference_suffix = VERSION >= v"1.7" ? "" : "_pre_1_7" @testset "parse_args" begin - include(script_runner) + include(TestReports.SCRIPT) @test parse_args([]) === nothing # Shows help @test_throws ArgumentError parse_args(["--"]) @@ -45,25 +55,15 @@ reference_suffix = VERSION >= v"1.7" ? "" : "_pre_1_7" end end -@testset "executable" begin - @test isfile(script_runner) - - if Sys.islinux() - @test uperm(script_runner) & 0x01 != 0 - @test gperm(script_runner) & 0x01 != 0 - @test operm(script_runner) & 0x01 != 0 - end -end - @testset "no specified test script" begin - p = run(ignorestatus(`$script_runner_cmd`)) + p = run(ignorestatus(`$runner_cmd`)) @test !success(p) end @testset "default output file" begin reference_file = "references/reporttests_pass$reference_suffix.xml" output_file = "testlog.xml" - p = run(ignorestatus(`$script_runner_cmd $test_script`)) + p = run(ignorestatus(`$runner_cmd $test_script`)) try @test success(p) @test isfile(output_file) @@ -76,7 +76,7 @@ end @testset "specify output file" begin reference_file = "references/reporttests_pass$reference_suffix.xml" output_file = "junit-report.xml" - p = run(ignorestatus(`$script_runner_cmd $test_script --output=$output_file`)) + p = run(ignorestatus(`$runner_cmd $test_script --output=$output_file`)) try @test success(p) @test isfile(output_file) @@ -89,7 +89,7 @@ end @testset "test args" begin reference_file = "references/reporttests_fail$reference_suffix.xml" output_file = "testlog.xml" - p = run(ignorestatus(`$script_runner_cmd $test_script -- foo -e bar`)) + p = run(ignorestatus(`$runner_cmd $test_script -- foo -e bar`)) try @test !success(p) @test isfile(output_file) From 3080b0e2b0718885364ac38dacca3a9c6ec16604 Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Tue, 21 May 2024 14:25:59 -0500 Subject: [PATCH 2/5] fixup! Define constant to `reporttests.jl` --- test/reporttests_script.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/reporttests_script.jl b/test/reporttests_script.jl index 5cce5c8..662f53a 100644 --- a/test/reporttests_script.jl +++ b/test/reporttests_script.jl @@ -18,7 +18,7 @@ test_script = "reporttests_testsets.jl" reference_suffix = VERSION >= v"1.7" ? "" : "_pre_1_7" @testset "parse_args" begin - include(TestReports.SCRIPT) + include(TestReports.RUNNER_FILE) @test parse_args([]) === nothing # Shows help @test_throws ArgumentError parse_args(["--"]) From d80e1ca9720c575812d94b506d78927d102941af Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Wed, 22 May 2024 08:47:06 -0500 Subject: [PATCH 3/5] Documentation refactor --- docs/src/library.md | 3 ++- src/TestReports.jl | 3 --- src/runner.jl | 13 +++++++++++++ test/reporttests_script.jl | 18 +++++++++--------- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/docs/src/library.md b/docs/src/library.md index be514e0..2c35b8c 100644 --- a/docs/src/library.md +++ b/docs/src/library.md @@ -12,6 +12,7 @@ Documentation for `TestReports.jl`'s public interface. ```@docs TestReports.test +TestReports.RUNNER_SCRIPT record_testset_property record_test_property ReportingTestSet @@ -29,7 +30,7 @@ Package internals documentation. Modules = [TestReports] Pages = ["runner.jl"] Public = false -Filter = t -> t != TestReports.test +Filter = t -> !(t in (TestReports.test, TestReports.RUNNER_SCRIPT)) ``` ### TestSets diff --git a/src/TestReports.jl b/src/TestReports.jl index add7cb1..ee69277 100644 --- a/src/TestReports.jl +++ b/src/TestReports.jl @@ -16,9 +16,6 @@ using Test: AbstractTestSet, DefaultTestSet, Result, Pass, Fail, Error, Broken, import Test: finish, record -# Defined for use by users of this package -const RUNNER_FILE = abspath(joinpath(@__DIR__(), "..", "bin", "reporttests.jl")) - # Version specific imports @static if VERSION >= v"1.4.0" using Pkg.Operations: gen_target_project diff --git a/src/runner.jl b/src/runner.jl index 1edfb77..d009fb7 100644 --- a/src/runner.jl +++ b/src/runner.jl @@ -1,3 +1,16 @@ +""" +The path to the test runner script provided by TestReports. Similar to running +[`TestReports.test`](@ref) but allows the user to specify any test file to run and not just +`test/runtests.jl`. + +## Example + +```julia +run(`\$(TestReports.RUNNER_SCRIPT) mytests.jl --output=junit-report.xml`) +``` +""" +const RUNNER_SCRIPT = abspath(joinpath(@__DIR__(), "..", "bin", "reporttests.jl")) + "Exit code for runner when tests fail" const TESTS_FAILED = 3 diff --git a/test/reporttests_script.jl b/test/reporttests_script.jl index 662f53a..53b7379 100644 --- a/test/reporttests_script.jl +++ b/test/reporttests_script.jl @@ -1,24 +1,24 @@ -@testset "runner file" begin - @test isdefined(TestReports, :RUNNER_FILE) - @test isfile(TestReports.RUNNER_FILE) +@testset "runner script" begin + @test isdefined(TestReports, :RUNNER_SCRIPT) + @test isfile(TestReports.RUNNER_SCRIPT) if Sys.islinux() - @test uperm(TestReports.RUNNER_FILE) & 0x01 != 0 - @test gperm(TestReports.RUNNER_FILE) & 0x01 != 0 - @test operm(TestReports.RUNNER_FILE) & 0x01 != 0 + @test uperm(TestReports.RUNNER_SCRIPT) & 0x01 != 0 + @test gperm(TestReports.RUNNER_SCRIPT) & 0x01 != 0 + @test operm(TestReports.RUNNER_SCRIPT) & 0x01 != 0 end end runner_cmd = if Sys.iswindows() - `julia $(TestReports.RUNNER_FILE) --` + `julia $(TestReports.RUNNER_SCRIPT) --` else - `$(TestReports.RUNNER_FILE)` + `$(TestReports.RUNNER_SCRIPT)` end test_script = "reporttests_testsets.jl" reference_suffix = VERSION >= v"1.7" ? "" : "_pre_1_7" @testset "parse_args" begin - include(TestReports.RUNNER_FILE) + include(TestReports.RUNNER_SCRIPT) @test parse_args([]) === nothing # Shows help @test_throws ArgumentError parse_args(["--"]) From 9a09ebb7e2e32d10fcb8afb0411f937457767c15 Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Wed, 22 May 2024 09:03:46 -0500 Subject: [PATCH 4/5] Set project version to 1.0.1 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 5ca98a6..33655c2 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "TestReports" uuid = "dcd651b4-b50a-5b6b-8f22-87e9f253a252" -version = "1.0.0" +version = "1.0.1" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" From 076b2640fca0895262842db45df894a662e218b8 Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Wed, 22 May 2024 10:04:41 -0500 Subject: [PATCH 5/5] Revert "Set project version to 1.0.1" This reverts commit 9a09ebb7e2e32d10fcb8afb0411f937457767c15. --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 33655c2..5ca98a6 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "TestReports" uuid = "dcd651b4-b50a-5b6b-8f22-87e9f253a252" -version = "1.0.1" +version = "1.0.0" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"