Skip to content

Commit 1e4d9d4

Browse files
authored
Throw on version mismatch (#49)
1 parent ca6b06d commit 1e4d9d4

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "RegressionTests"
22
uuid = "2cca1867-674a-4323-b559-fc77c0bbdb31"
33
authors = ["Lilith Orion Hafner <[email protected]> and contributors"]
4-
version = "0.0.8"
4+
version = "0.0.9"
55

66
[deps]
77
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"

src/RegressionTests.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ function try_runbenchmarks(;
9090
workers = 5,#Sys.CPU_THREADS,
9191
startup_file = Base.JLOptions().startupfile == 1 ? "yes" : "no",
9292
are_different = are_different,
93+
allow_version_mismatch = false,
9394
)
9495

9596
commands = Vector{Cmd}(undef, workers)
@@ -104,7 +105,8 @@ function try_runbenchmarks(;
104105
mkdir(projects[i])
105106
# bench_projectfile_exists && cp(bench_projectfile, joinpath(projects[i], "Project.toml"))
106107
cp(bench_project, projects[i], force=true)
107-
script = "let; using RegressionTests; RegressionTests.FILTER[] = RegressionTests.deserialize($(repr(filter_path))); end; let; include($rfile); end; using RegressionTests; RegressionTests.serialize($(repr(channels[i])), (RegressionTests.STATIC_METADATA, RegressionTests.RUNTIME_METADATA, RegressionTests.DATA))"
108+
verify_version = allow_version_mismatch ? "" : " RegressionTests.verify_source($(repr(dirname(@__DIR__))));"
109+
script = "let; using RegressionTests;$verify_version RegressionTests.FILTER[] = RegressionTests.deserialize($(repr(filter_path))); end; let; include($rfile); end; using RegressionTests; RegressionTests.serialize($(repr(channels[i])), (RegressionTests.STATIC_METADATA, RegressionTests.RUNTIME_METADATA, RegressionTests.DATA))"
108110
commands[i] = if VERSION < v"1.10.0-alpha1"
109111
# --compiled-modules=no is a workaround for https://github.com/JuliaLang/julia/issues/52265
110112
`$julia_exe --compiled-modules=no --startup-file=$startup_file --project=$(projects[i]) -e $script`
@@ -688,6 +690,12 @@ end
688690

689691
# Callie
690692

693+
verify_source(path) = (path == dirname(@__DIR__)) || error("""
694+
RegressionTests version mismatch
695+
Outer process is at $path (version $(Pkg.TOML.parsefile(joinpath(path, "Project.toml"))["version"]))
696+
Inner process is at $(dirname(@__DIR__)) (version $(Pkg.TOML.parsefile(joinpath(dirname(@__DIR__), "Project.toml"))["version"]))
697+
Hint: make sure the bench project and the test project have the same version of RegressionTests.""")
698+
691699
const FILTER = Ref{Union{Nothing, BitVector}}(nothing)
692700
const STATIC_METADATA = Tuple{Symbol, Int, String}[]
693701
const GROUP_ID = Ref(0)

test/runtests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using Pkg
2121

2222
# TODO: make this work when it comes after "Example usage" as well.
2323
@testset "Regression tests" begin
24-
RegressionTests.test(skip_unsupported_platforms=true)
24+
RegressionTests.test(skip_unsupported_platforms=true, allow_version_mismatch=true)
2525
end
2626

2727
if RegressionTests.is_platform_supported()
@@ -48,7 +48,7 @@ using Pkg
4848
old_src = read(src_file, String)
4949
new_src = replace(old_src, "my_sum(x) = sum(x)" => "my_sum(x) = sum(Float64.(x))")
5050
write(src_file, new_src)
51-
t = @elapsed changes = runbenchmarks(project = ".") # Fail
51+
t = @elapsed changes = runbenchmarks(project = ".", allow_version_mismatch=true) # Fail
5252
println("Runtime for positive runbenchmarks: $t")
5353
@test !isempty(changes)
5454

@@ -61,7 +61,7 @@ using Pkg
6161
println.(changes)
6262
run(`git add $src_file`)
6363
run(`git commit -m "Introduce regression"`)
64-
t = @elapsed @test isempty(runbenchmarks(project = ".")) # Pass
64+
t = @elapsed @test isempty(runbenchmarks(project = ".", allow_version_mismatch=true)) # Pass
6565
println("Runtime for negative runbenchmarks: $t")
6666
# TODO: handle this case well
6767
# TODO: track the runtime of these runbenchmark calls... but we can't use RegressionTests.jl because that would be too slow.

0 commit comments

Comments
 (0)