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

1.7 compat #74

Merged
merged 12 commits into from
Dec 4, 2021
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
matrix:
version:
- '1.0'
- '1.6'
- '1'
- 'nightly'
os:
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "TestReports"
uuid = "dcd651b4-b50a-5b6b-8f22-87e9f253a252"
version = "0.6.1"
version = "0.6.2"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
5 changes: 4 additions & 1 deletion src/TestReports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ else
using Pkg.Operations: with_dependencies_loadable_at_toplevel
end
@static if VERSION >= v"1.2.0"
using Pkg.Operations: sandbox, source_path, update_package_test!
using Pkg.Operations: sandbox, source_path
@static if VERSION < v"1.7.0"
using Pkg.Operations: update_package_test!
end
else
using Pkg.Operations: find_installed
using Pkg.Types: SHA1
Expand Down
10 changes: 9 additions & 1 deletion src/compat_check.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Check whether `current` version is compatible with `desired`.
compatible(current::VersionNumber, desired::VersionNumber) = compatible(current, string(desired))
compatible(current::VersionNumber, desired::String) = compatible(current, Pkg.Types.semver_spec(desired))
compatible(current::VersionNumber, desired::Pkg.Types.VersionSpec) = current in desired
@static if VERSION >= v"1.7.0"
compatible(current::VersionNumber, desired::Pkg.Types.Compat) = compatible(current, desired.val)
end

"""
check_project(project::Nothing, args...)
Expand Down Expand Up @@ -151,10 +154,15 @@ function get_dep_entries end
if haskey(getdeps(active_env.manifest), testreport_proj.deps[dep])
push!(deps_to_check, getdeps(active_env.manifest)[testreport_proj.deps[dep]])
else
@static if VERSION >= v"1.7.0"
version_number = VersionNumber(testreport_proj.compat[dep].str)
else
version_number = VersionNumber(testreport_proj.compat[dep])
end
pkg_entry = Pkg.Types.PackageEntry(
name=dep,
other=Dict("uuid" => testreport_proj.deps[dep]),
version=VersionNumber(testreport_proj.compat[dep])
version=version_number
)
push!(deps_to_check, pkg_entry)
end
Expand Down
78 changes: 63 additions & 15 deletions src/runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ get_deps(manifest, pkg) = get_deps!(String[], manifest, pkg)
Push dependencies for `pkg` found in `manifest` into `deps`.
"""
function get_deps!(deps, manifest, pkg)
if haskey(manifest[pkg][1], "deps")
for dep in manifest[pkg][1]["deps"]
if VERSION >= v"1.7.0"
manifest_dict = manifest["deps"]
else
manifest_dict = manifest
end
if haskey(manifest_dict[pkg][1], "deps")
for dep in manifest_dict[pkg][1]["deps"]
if !(dep in deps)
push!(deps, dep)
get_deps!(deps, manifest, dep)
Expand All @@ -37,7 +42,12 @@ function get_manifest()
manifest_path = replace(path, "Project.toml"=>"Manifest.toml")
if isfile(manifest_path)
manifest = Pkg.TOML.parsefile(manifest_path)
haskey(manifest, "TestReports") && return manifest
if VERSION >= v"1.7.0"
!haskey(manifest, "deps") && continue
haskey(manifest["deps"], "TestReports") && return manifest
else
haskey(manifest, "TestReports") && return manifest
end
end
end

Expand All @@ -55,14 +65,26 @@ from the parsed `manifest` provided.
function make_testreports_environment(manifest)
all_deps = get_deps(manifest, "TestReports")
push!(all_deps, "TestReports")
new_manifest = Dict(pkg => manifest[pkg] for pkg in all_deps)

new_project = Dict(
"deps" => Dict(
"Test" => new_manifest["Test"][1]["uuid"],
"TestReports" => new_manifest["TestReports"][1]["uuid"]
if VERSION >= v"1.7.0"
new_manifest = Dict{String, Any}()
new_manifest["deps"] = Dict(pkg => manifest["deps"][pkg] for pkg in all_deps)
new_manifest["julia_version"] = manifest["julia_version"]
new_manifest["manifest_format"] = manifest["manifest_format"]
new_project = Dict(
"deps" => Dict(
"Test" => new_manifest["deps"]["Test"][1]["uuid"],
"TestReports" => new_manifest["deps"]["TestReports"][1]["uuid"]
)
)
)
else
new_manifest = Dict(pkg => manifest[pkg] for pkg in all_deps)
new_project = Dict(
"deps" => Dict(
"Test" => new_manifest["Test"][1]["uuid"],
"TestReports" => new_manifest["TestReports"][1]["uuid"]
)
)
end
testreportsenv = mktempdir()
open(joinpath(testreportsenv, "Project.toml"), "w") do io
Pkg.TOML.print(io, new_project)
Expand Down Expand Up @@ -163,16 +185,21 @@ is of type `Pkg.Types.Context`. For earlier versions, they are of type
`Pkg.Types.EnvCache`.
"""
function isinstalled!(ctx::Context, pkgspec::Pkg.Types.PackageSpec)
@static if VERSION >= v"1.4.0"
@static if v"1.4.0" <= VERSION < v"1.7.0"
var = ctx
else
var = ctx.env
end
@static if VERSION >= v"1.7.0"
manifest_var = ctx.env.manifest
else
manifest_var = var
end
project_resolve!(var, [pkgspec])
project_deps_resolve!(var, [pkgspec])
manifest_resolve!(var, [pkgspec])
manifest_resolve!(manifest_var, [pkgspec])
try
ensure_resolved(var, [pkgspec])
ensure_resolved(manifest_var, [pkgspec])
catch
return false
end
Expand All @@ -186,7 +213,23 @@ Gets the testfile path of the package. Code for each Julia version mirrors that
in `Pkg/src/Operations.jl`.
"""
function gettestfilepath(ctx::Context, pkgspec::Pkg.Types.PackageSpec)
@static if VERSION >= v"1.4.0"
@static if VERSION >= v"1.7.0"
if is_project_uuid(ctx.env, pkgspec.uuid)
pkgspec.path = dirname(ctx.env.project_file)
pkgspec.version = ctx.env.pkg.version
else !Pkg.Operations.is_stdlib(pkgspec.uuid)
entry = manifest_info(ctx.env.manifest, pkgspec.uuid)
pkgspec.version = entry.version
pkgspec.tree_hash = entry.tree_hash
pkgspec.repo = entry.repo
pkgspec.path = entry.path
pkgspec.pinned = entry.pinned
if isnothing(pkgspec.path)
pkgspec.path = source_path(ctx.env.project_file, pkgspec, ctx.julia_version)
end
end
pkgfilepath = source_path(ctx.env.project_file, pkgspec, ctx.julia_version)
elseif VERSION >= v"1.4.0"
if is_project_uuid(ctx, pkgspec.uuid)
pkgspec.path = dirname(ctx.env.project_file)
pkgspec.version = ctx.env.pkg.version
Expand Down Expand Up @@ -334,7 +377,12 @@ function test!(pkg::AbstractString,
pkgspec,
pkgspec.path,
joinpath(pkgspec.path, "test"))
if VERSION >= v"1.4.0"
if VERSION >= v"1.7.0"
test_project_override = test_folder_has_project_file ?
nothing :
gen_target_project(ctx.env, ctx.registries, pkgspec, pkgspec.path, "test")
sandbox_args = (sandbox_args..., test_project_override)
elseif VERSION >= v"1.4.0"
test_project_override = test_folder_has_project_file ?
nothing :
gen_target_project(ctx, pkgspec, pkgspec.path, "test")
Expand Down
1 change: 0 additions & 1 deletion test/example_normaltestsets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ using Base.Threads
@test_broken sqrt(-1)
@test 1/0 # not a real test
@test 1 == error("Nooo") # error
@test 1 == rand(2,2)\rand(4,4) # deep error
@test_broken true

end
Expand Down
6 changes: 0 additions & 6 deletions test/recordproperty.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
using EzXML
using Test
using Test: DefaultTestSet, AbstractTestSet, Error, get_testset, get_testset_depth
using ReferenceTests
using TestReports

@testset "recordproperty" begin
@testset "Property recording" begin
# Test for blanks in properties if nothing given
Expand Down
5 changes: 2 additions & 3 deletions test/references/complexexample.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<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
<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
Expression: 1 * 2 == 5
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
Expression: 1 + -2 == 1
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
Expression: 1 + 2 == 5
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
</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")
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
</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
</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
Expression: throw(ArgumentError("1"))
Expand Down
9 changes: 7 additions & 2 deletions test/runnerinternals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ end
test_package_expected_fail("OldDepInTarget")
if VERSION >= v"1.2.0"
test_package_expected_fail("OldTestReportsInTestDeps")
test_package_expected_fail("OldTestReportsInTestManifest")
test_package_expected_fail("OldDepInTestDeps")
test_package_expected_fail("OldDepInTestManifest")
if VERSION >= v"1.7.0"
test_package_expected_fail("OldTestReportsInTestManifest_1_7") # new manifest format
test_package_expected_fail("OldDepInTestManifest_1_7") # new manifest format
else
test_package_expected_fail("OldTestReportsInTestManifest")
test_package_expected_fail("OldDepInTestManifest")
end
end
end
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using Dates
using EzXML
using ReferenceTests
using Test
using Test: AbstractTestSet, DefaultTestSet, Result, Pass, Fail, Broken, Error
using Test: get_testset, get_testset_depth
using TestReports

# Include utils
Expand Down
3 changes: 3 additions & 0 deletions test/test_packages/OldDepInTestManifest_1_7/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name = "OldDepInTestManifest_1_7"
uuid = "19d8228f-71fc-4fca-a105-eca906948e75"
version = "0.1.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module OldDepInTestManifest_1_7

end
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!Manifest.toml
Loading