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

test: fix is_enabled test when env var is set #23

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Changes from all 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
60 changes: 32 additions & 28 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,43 +71,47 @@ end
@testset "JuliaHub.jl" begin
# Just to make sure the logic within is_enabled() is correct.
@testset "is_enabled" begin
@test !is_enabled(; args=[])
@test is_enabled(; args=["--live"])
# We need to unset JULIAHUBJL_LIVE_WINDOWS_TESTS in case it is set in the
# actual enviornment.
withenv("JULIAHUBJL_LIVE_WINDOWS_TESTS" => nothing) do
@test !is_enabled(; args=[])
@test is_enabled(; args=["--live"])

let args = ["datasets"]
@test_logs (:info,) @test is_enabled("datasets"; args)
@test_logs (:warn,) @test !is_enabled("jobs"; args)
@test_logs (:warn,) @test !is_enabled("jobs-windows"; args)
end
let args = ["--live"]
@test_logs (:info,) @test is_enabled("datasets"; args)
@test_logs (:info,) @test is_enabled("jobs"; args)
@test_logs (:warn,) @test !is_enabled("jobs-windows"; args)
withenv("JULIAHUBJL_LIVE_WINDOWS_TESTS" => "foo") do
let args = ["datasets"]
@test_logs (:info,) @test is_enabled("datasets"; args)
@test_logs (:warn,) @test !is_enabled("jobs"; args)
@test_logs (:warn,) @test !is_enabled("jobs-windows"; args)
end
let args = ["--live"]
@test_logs (:info,) @test is_enabled("datasets"; args)
@test_logs (:info,) @test is_enabled("jobs"; args)
@test_logs (:warn,) @test !is_enabled("jobs-windows"; args)
withenv("JULIAHUBJL_LIVE_WINDOWS_TESTS" => "foo") do
@test_logs (:info,) @test is_enabled("datasets"; args)
@test_logs (:info,) @test is_enabled("jobs"; args)
@test_logs (:warn,) @test !is_enabled("jobs-windows"; args)
end
withenv("JULIAHUBJL_LIVE_WINDOWS_TESTS" => "true") do
@test_logs (:info,) @test is_enabled("datasets"; args)
@test_logs (:info,) @test is_enabled("jobs"; args)
@test_logs (:info,) @test is_enabled("jobs-windows"; args)
end
end
withenv("JULIAHUBJL_LIVE_WINDOWS_TESTS" => "true") do
let args = ["datasets", "jobs"]
@test_logs (:info,) @test is_enabled("datasets"; args)
@test_logs (:info,) @test is_enabled("jobs"; args)
@test_logs (:warn,) @test !is_enabled("jobs-windows"; args)
end
let args = ["jobs-windows"]
@test_logs (:warn,) @test !is_enabled("datasets"; args)
@test_logs (:warn,) @test !is_enabled("jobs"; args)
@test_logs (:info,) @test is_enabled("jobs-windows"; args)
end
let args = ["jobs-windows", "datasets"]
@test_logs (:info,) @test is_enabled("datasets"; args)
@test_logs (:warn,) @test !is_enabled("jobs"; args)
@test_logs (:info,) @test is_enabled("jobs-windows"; args)
end
end
let args = ["datasets", "jobs"]
@test_logs (:info,) @test is_enabled("datasets"; args)
@test_logs (:info,) @test is_enabled("jobs"; args)
@test_logs (:warn,) @test !is_enabled("jobs-windows"; args)
end
let args = ["jobs-windows"]
@test_logs (:warn,) @test !is_enabled("datasets"; args)
@test_logs (:warn,) @test !is_enabled("jobs"; args)
@test_logs (:info,) @test is_enabled("jobs-windows"; args)
end
let args = ["jobs-windows", "datasets"]
@test_logs (:info,) @test is_enabled("datasets"; args)
@test_logs (:warn,) @test !is_enabled("jobs"; args)
@test_logs (:info,) @test is_enabled("jobs-windows"; args)
end
end
# This set tests that we haven't accidentally added or removed any public-looking
Expand Down
Loading