Skip to content

Commit 8620bcf

Browse files
committed
1.7 compat WIP
1 parent d4ebb32 commit 8620bcf

File tree

2 files changed

+67
-16
lines changed

2 files changed

+67
-16
lines changed

src/TestReports.jl

+4-1
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-beta3" # TODO: replace with 1.7.0 everywhere
28+
using Pkg.Operations: update_package_test!
29+
end
2730
else
2831
using Pkg.Operations: find_installed
2932
using Pkg.Types: SHA1

src/runner.jl

+63-15
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-beta3"
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-beta3"
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-beta3"
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-beta3"
167189
var = ctx
168190
else
169191
var = ctx.env
170192
end
193+
@static if VERSION >= v"1.7.0-beta3"
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-beta3"
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
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
@@ -328,7 +371,12 @@ function test!(pkg::AbstractString,
328371
pkgspec,
329372
pkgspec.path,
330373
joinpath(pkgspec.path, "test"))
331-
if VERSION >= v"1.4.0"
374+
if VERSION >= v"1.7.0-beta3"
375+
test_project_override = test_folder_has_project_file ?
376+
nothing :
377+
gen_target_project(ctx.env, ctx.registries, pkgspec, pkgspec.path, "test")
378+
sandbox_args = (sandbox_args..., test_project_override)
379+
elseif VERSION >= v"1.4.0"
332380
test_project_override = test_folder_has_project_file ?
333381
nothing :
334382
gen_target_project(ctx, pkgspec, pkgspec.path, "test")

0 commit comments

Comments
 (0)