Skip to content

Commit 9f83893

Browse files
authored
Merge pull request #74 from JuliaTesting/mm/1_7_compat
1.7 compat
2 parents 14d94a1 + b956c7a commit 9f83893

23 files changed

+438
-35
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
matrix:
1717
version:
1818
- '1.0'
19+
- '1.6'
1920
- '1'
2021
- 'nightly'
2122
os:

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "TestReports"
22
uuid = "dcd651b4-b50a-5b6b-8f22-87e9f253a252"
3-
version = "0.6.1"
3+
version = "0.6.2"
44

55
[deps]
66
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

src/TestReports.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ else
2323
using Pkg.Operations: with_dependencies_loadable_at_toplevel
2424
end
2525
@static if VERSION >= v"1.2.0"
26-
using Pkg.Operations: sandbox, source_path, update_package_test!
26+
using Pkg.Operations: sandbox, source_path
27+
@static if VERSION < v"1.7.0"
28+
using Pkg.Operations: update_package_test!
29+
end
2730
else
2831
using Pkg.Operations: find_installed
2932
using Pkg.Types: SHA1

src/compat_check.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Check whether `current` version is compatible with `desired`.
99
compatible(current::VersionNumber, desired::VersionNumber) = compatible(current, string(desired))
1010
compatible(current::VersionNumber, desired::String) = compatible(current, Pkg.Types.semver_spec(desired))
1111
compatible(current::VersionNumber, desired::Pkg.Types.VersionSpec) = current in desired
12+
@static if VERSION >= v"1.7.0"
13+
compatible(current::VersionNumber, desired::Pkg.Types.Compat) = compatible(current, desired.val)
14+
end
1215

1316
"""
1417
check_project(project::Nothing, args...)
@@ -151,10 +154,15 @@ function get_dep_entries end
151154
if haskey(getdeps(active_env.manifest), testreport_proj.deps[dep])
152155
push!(deps_to_check, getdeps(active_env.manifest)[testreport_proj.deps[dep]])
153156
else
157+
@static if VERSION >= v"1.7.0"
158+
version_number = VersionNumber(testreport_proj.compat[dep].str)
159+
else
160+
version_number = VersionNumber(testreport_proj.compat[dep])
161+
end
154162
pkg_entry = Pkg.Types.PackageEntry(
155163
name=dep,
156164
other=Dict("uuid" => testreport_proj.deps[dep]),
157-
version=VersionNumber(testreport_proj.compat[dep])
165+
version=version_number
158166
)
159167
push!(deps_to_check, pkg_entry)
160168
end

src/runner.jl

Lines changed: 63 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ get_deps(manifest, pkg) = get_deps!(String[], manifest, pkg)
1414
Push dependencies for `pkg` found in `manifest` into `deps`.
1515
"""
1616
function get_deps!(deps, manifest, pkg)
17-
if haskey(manifest[pkg][1], "deps")
18-
for dep in manifest[pkg][1]["deps"]
17+
if VERSION >= v"1.7.0"
18+
manifest_dict = manifest["deps"]
19+
else
20+
manifest_dict = manifest
21+
end
22+
if haskey(manifest_dict[pkg][1], "deps")
23+
for dep in manifest_dict[pkg][1]["deps"]
1924
if !(dep in deps)
2025
push!(deps, dep)
2126
get_deps!(deps, manifest, dep)
@@ -37,7 +42,12 @@ function get_manifest()
3742
manifest_path = replace(path, "Project.toml"=>"Manifest.toml")
3843
if isfile(manifest_path)
3944
manifest = Pkg.TOML.parsefile(manifest_path)
40-
haskey(manifest, "TestReports") && return manifest
45+
if VERSION >= v"1.7.0"
46+
!haskey(manifest, "deps") && continue
47+
haskey(manifest["deps"], "TestReports") && return manifest
48+
else
49+
haskey(manifest, "TestReports") && return manifest
50+
end
4151
end
4252
end
4353

@@ -55,14 +65,26 @@ from the parsed `manifest` provided.
5565
function make_testreports_environment(manifest)
5666
all_deps = get_deps(manifest, "TestReports")
5767
push!(all_deps, "TestReports")
58-
new_manifest = Dict(pkg => manifest[pkg] for pkg in all_deps)
59-
60-
new_project = Dict(
61-
"deps" => Dict(
62-
"Test" => new_manifest["Test"][1]["uuid"],
63-
"TestReports" => new_manifest["TestReports"][1]["uuid"]
68+
if VERSION >= v"1.7.0"
69+
new_manifest = Dict{String, Any}()
70+
new_manifest["deps"] = Dict(pkg => manifest["deps"][pkg] for pkg in all_deps)
71+
new_manifest["julia_version"] = manifest["julia_version"]
72+
new_manifest["manifest_format"] = manifest["manifest_format"]
73+
new_project = Dict(
74+
"deps" => Dict(
75+
"Test" => new_manifest["deps"]["Test"][1]["uuid"],
76+
"TestReports" => new_manifest["deps"]["TestReports"][1]["uuid"]
77+
)
6478
)
65-
)
79+
else
80+
new_manifest = Dict(pkg => manifest[pkg] for pkg in all_deps)
81+
new_project = Dict(
82+
"deps" => Dict(
83+
"Test" => new_manifest["Test"][1]["uuid"],
84+
"TestReports" => new_manifest["TestReports"][1]["uuid"]
85+
)
86+
)
87+
end
6688
testreportsenv = mktempdir()
6789
open(joinpath(testreportsenv, "Project.toml"), "w") do io
6890
Pkg.TOML.print(io, new_project)
@@ -163,16 +185,21 @@ is of type `Pkg.Types.Context`. For earlier versions, they are of type
163185
`Pkg.Types.EnvCache`.
164186
"""
165187
function isinstalled!(ctx::Context, pkgspec::Pkg.Types.PackageSpec)
166-
@static if VERSION >= v"1.4.0"
188+
@static if v"1.4.0" <= VERSION < v"1.7.0"
167189
var = ctx
168190
else
169191
var = ctx.env
170192
end
193+
@static if VERSION >= v"1.7.0"
194+
manifest_var = ctx.env.manifest
195+
else
196+
manifest_var = var
197+
end
171198
project_resolve!(var, [pkgspec])
172199
project_deps_resolve!(var, [pkgspec])
173-
manifest_resolve!(var, [pkgspec])
200+
manifest_resolve!(manifest_var, [pkgspec])
174201
try
175-
ensure_resolved(var, [pkgspec])
202+
ensure_resolved(manifest_var, [pkgspec])
176203
catch
177204
return false
178205
end
@@ -186,7 +213,23 @@ Gets the testfile path of the package. Code for each Julia version mirrors that
186213
in `Pkg/src/Operations.jl`.
187214
"""
188215
function gettestfilepath(ctx::Context, pkgspec::Pkg.Types.PackageSpec)
189-
@static if VERSION >= v"1.4.0"
216+
@static if VERSION >= v"1.7.0"
217+
if is_project_uuid(ctx.env, pkgspec.uuid)
218+
pkgspec.path = dirname(ctx.env.project_file)
219+
pkgspec.version = ctx.env.pkg.version
220+
else !Pkg.Operations.is_stdlib(pkgspec.uuid)
221+
entry = manifest_info(ctx.env.manifest, pkgspec.uuid)
222+
pkgspec.version = entry.version
223+
pkgspec.tree_hash = entry.tree_hash
224+
pkgspec.repo = entry.repo
225+
pkgspec.path = entry.path
226+
pkgspec.pinned = entry.pinned
227+
if isnothing(pkgspec.path)
228+
pkgspec.path = source_path(ctx.env.project_file, pkgspec, ctx.julia_version)
229+
end
230+
end
231+
pkgfilepath = source_path(ctx.env.project_file, pkgspec, ctx.julia_version)
232+
elseif VERSION >= v"1.4.0"
190233
if is_project_uuid(ctx, pkgspec.uuid)
191234
pkgspec.path = dirname(ctx.env.project_file)
192235
pkgspec.version = ctx.env.pkg.version
@@ -334,7 +377,12 @@ function test!(pkg::AbstractString,
334377
pkgspec,
335378
pkgspec.path,
336379
joinpath(pkgspec.path, "test"))
337-
if VERSION >= v"1.4.0"
380+
if VERSION >= v"1.7.0"
381+
test_project_override = test_folder_has_project_file ?
382+
nothing :
383+
gen_target_project(ctx.env, ctx.registries, pkgspec, pkgspec.path, "test")
384+
sandbox_args = (sandbox_args..., test_project_override)
385+
elseif VERSION >= v"1.4.0"
338386
test_project_override = test_folder_has_project_file ?
339387
nothing :
340388
gen_target_project(ctx, pkgspec, pkgspec.path, "test")

test/example_normaltestsets.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ using Base.Threads
2929
@test_broken sqrt(-1)
3030
@test 1/0 # not a real test
3131
@test 1 == error("Nooo") # error
32-
@test 1 == rand(2,2)\rand(4,4) # deep error
3332
@test_broken true
3433

3534
end

test/recordproperty.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
using EzXML
2-
using Test
3-
using Test: DefaultTestSet, AbstractTestSet, Error, get_testset, get_testset_depth
4-
using ReferenceTests
5-
using TestReports
6-
71
@testset "recordproperty" begin
82
@testset "Property recording" begin
93
# Test for blanks in properties if nothing given

test/references/complexexample.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<testsuites tests="19" failures="6" errors="5"><testsuite name="Math/Multiplication" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="0"><testcase name="pass (info lost) (Test 1)" id="_testcase_id_" classname="Math/Multiplication" time="0.0"/><testcase name="1 * 2 == 5" id="_testcase_id_" classname="Math/Multiplication" time="0.0"><failure message="2 == 5" type="test">Test Failed
2+
<testsuites tests="18" failures="6" errors="4"><testsuite name="Math/Multiplication" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="0"><testcase name="pass (info lost) (Test 1)" id="_testcase_id_" classname="Math/Multiplication" time="0.0"/><testcase name="1 * 2 == 5" id="_testcase_id_" classname="Math/Multiplication" time="0.0"><failure message="2 == 5" type="test">Test Failed
33
Expression: 1 * 2 == 5
44
Evaluated: 2 == 5</failure></testcase><testcase name="pass (info lost) (Test 3)" id="_testcase_id_" classname="Math/Multiplication" time="0.0"/></testsuite><testsuite name="Math/addition/negative addition" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="1"><testcase name="pass (info lost) (Test 1)" id="_testcase_id_" classname="Math/addition/negative addition" time="0.0"/><testcase name="1 + -2 == 1" id="_testcase_id_" classname="Math/addition/negative addition" time="0.0"><failure message="-1 == 1" type="test">Test Failed
55
Expression: 1 + -2 == 1
66
Evaluated: -1 == 1</failure></testcase><testcase name="pass (info lost) (Test 3)" id="_testcase_id_" classname="Math/addition/negative addition" time="0.0"/></testsuite><testsuite name="Math/addition" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="2"><testcase name="pass (info lost) (Test 1)" id="_testcase_id_" classname="Math/addition" time="0.0"/><testcase name="1 + 2 == 5" id="_testcase_id_" classname="Math/addition" time="0.0"><failure message="3 == 5" type="test">Test Failed
77
Expression: 1 + 2 == 5
8-
Evaluated: 3 == 5</failure></testcase><testcase name="pass (info lost) (Test 3)" id="_testcase_id_" classname="Math/addition" time="0.0"/></testsuite><testsuite name="Math/other" tests="4" failures="0" errors="4" time="0.0" timestamp="0" hostname="localhost" id="3"><testcase name="sqrt(-1)" id="_testcase_id_" classname="Math/other" time="0.0"><skip/></testcase><error message="Expression evaluated to non-Boolean" type="Expression evaluated to non-Boolean" classname="Math/other" time="0.0"></error><error message="Nooo" type="ErrorException" classname="Math/other" time="0.0">Nooo
9-
</error><error message="DimensionMismatch(&quot;B has leading dimension 4, but needs 2&quot;)" type="DimensionMismatch" classname="Math/other" time="0.0">DimensionMismatch("B has leading dimension 4, but needs 2")
8+
Evaluated: 3 == 5</failure></testcase><testcase name="pass (info lost) (Test 3)" id="_testcase_id_" classname="Math/addition" time="0.0"/></testsuite><testsuite name="Math/other" tests="3" failures="0" errors="3" time="0.0" timestamp="0" hostname="localhost" id="3"><testcase name="sqrt(-1)" id="_testcase_id_" classname="Math/other" time="0.0"><skip/></testcase><error message="Expression evaluated to non-Boolean" type="Expression evaluated to non-Boolean" classname="Math/other" time="0.0"></error><error message="Nooo" type="ErrorException" classname="Math/other" time="0.0">Nooo
109
</error><error message="Got correct result, please change to @test if no longer broken." type="Unexpected Pass" classname="Math/other" time="0.0"></error></testsuite><testsuite name="Math/Error outside of tests" tests="0" failures="0" errors="1" time="0.0" timestamp="0" hostname="localhost" id="4"><error message="Got exception outside of a @test" type="ErrorException" classname="Math/Error outside of tests" time="0.0">Outside of tests
1110
</error></testsuite><testsuite name="Math/Different failures" tests="2" failures="2" errors="0" time="0.0" timestamp="0" hostname="localhost" id="5"><testcase name="throw(ArgumentError(&quot;1&quot;))" id="_testcase_id_" classname="Math/Different failures" time="0.0"><failure message="Wrong exception type thrown" type="test_throws_wrong">Test Failed
1211
Expression: throw(ArgumentError("1"))

test/runnerinternals.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,13 @@ end
5656
test_package_expected_fail("OldDepInTarget")
5757
if VERSION >= v"1.2.0"
5858
test_package_expected_fail("OldTestReportsInTestDeps")
59-
test_package_expected_fail("OldTestReportsInTestManifest")
6059
test_package_expected_fail("OldDepInTestDeps")
61-
test_package_expected_fail("OldDepInTestManifest")
60+
if VERSION >= v"1.7.0"
61+
test_package_expected_fail("OldTestReportsInTestManifest_1_7") # new manifest format
62+
test_package_expected_fail("OldDepInTestManifest_1_7") # new manifest format
63+
else
64+
test_package_expected_fail("OldTestReportsInTestManifest")
65+
test_package_expected_fail("OldDepInTestManifest")
66+
end
6267
end
6368
end

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
using Dates
2+
using EzXML
3+
using ReferenceTests
14
using Test
5+
using Test: AbstractTestSet, DefaultTestSet, Result, Pass, Fail, Broken, Error
6+
using Test: get_testset, get_testset_depth
27
using TestReports
38

49
# Include utils
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name = "OldDepInTestManifest_1_7"
2+
uuid = "19d8228f-71fc-4fca-a105-eca906948e75"
3+
version = "0.1.0"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module OldDepInTestManifest_1_7
2+
3+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!Manifest.toml

0 commit comments

Comments
 (0)