Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define constant to reporttests.jl #112

Merged
merged 6 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/TestReports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 19 additions & 19 deletions test/reporttests_script.jl
Original file line number Diff line number Diff line change
@@ -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.RUNNER_FILE)
@test parse_args([]) === nothing # Shows help
@test_throws ArgumentError parse_args(["--"])

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Loading