Skip to content

Commit 25d9afb

Browse files
committed
Catch up on 1.8/1.9 changes
1 parent 323b579 commit 25d9afb

File tree

6 files changed

+32
-20
lines changed

6 files changed

+32
-20
lines changed

src/julia-1.8/activate_do.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ Indeed this is basically extracted from what `Pkg.test()` does.
1212
function activate(f, pkg::AbstractString=current_pkg_name())
1313
ctx, pkgspec = ctx_and_pkgspec(pkg)
1414

15-
test_project_override = maybe_gen_project_override!(ctx, pkgspec)
16-
return sandbox(ctx, pkgspec, pkgspec.path, joinpath(pkgspec.path, "test"), test_project_override) do
15+
test_project_override = maybe_gen_project_override!(ctx, pkgspec)
16+
path = pkgspec.path::String
17+
return sandbox(ctx, pkgspec, path, joinpath(path, "test"), test_project_override) do
1718
flush(stdout)
1819
f()
1920
end

src/julia-1.8/activate_set.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function activate(pkg::AbstractString=current_pkg_name())
1111
# This needs to be first as `gen_target_project` fixes `pkgspec.path` if it is nothing
1212
sandbox_project_override = maybe_gen_project_override!(ctx, pkgspec)
1313

14-
sandbox_path = joinpath(pkgspec.path, "test")
14+
sandbox_path = joinpath(pkgspec.path::String, "test")
1515
sandbox_project = projectfile_path(sandbox_path)
1616

1717
tmp = mktempdir()
@@ -71,7 +71,7 @@ function activate(pkg::AbstractString=current_pkg_name())
7171
# Absolutify stdlibs paths
7272
for (uuid, entry) in temp_ctx.env.manifest
7373
if is_stdlib(uuid)
74-
entry.path = Types.stdlib_path(entry.name)
74+
entry.path = Types.stdlib_path(entry.name::String)
7575
end
7676
end
7777
write_env(temp_ctx.env; update_undo=false)

src/julia-1.8/common.jl

+11-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ function Base.showerror(io::IO, ex::TestEnvError, bt; backtrace=true)
66
printstyled(io, ex.msg, color=Base.error_color())
77
end
88

9-
10-
current_pkg_name() = (Context().env.pkg::PackageSpec).name
9+
function current_pkg_name()
10+
ctx = Context()
11+
ctx.env.pkg === nothing && throw(TestEnvError("trying to activate test environment of an unnamed project"))
12+
return ctx.env.pkg.name
13+
end
1114

1215
"""
1316
ctx, pkgspec = ctx_and_pkgspec(pkg::AbstractString)
@@ -46,7 +49,9 @@ end
4649

4750

4851
function test_dir_has_project_file(ctx, pkgspec)
49-
return isfile(joinpath(get_test_dir(ctx, pkgspec), "Project.toml"))
52+
test_dir = get_test_dir(ctx, pkgspec)
53+
test_dir === nothing && return false
54+
return isfile(joinpath(test_dir, "Project.toml"))
5055
end
5156

5257
"""
@@ -60,16 +65,16 @@ function get_test_dir(ctx::Context, pkgspec::Pkg.Types.PackageSpec)
6065
pkgspec.path = dirname(ctx.env.project_file)
6166
pkgspec.version = ctx.env.pkg.version
6267
else
63-
is_stdlib(pkgspec.uuid) && return
68+
is_stdlib(pkgspec.uuid::Base.UUID) && return
6469
entry = manifest_info(ctx.env.manifest, pkgspec.uuid)
6570
pkgspec.version = entry.version
6671
pkgspec.tree_hash = entry.tree_hash
6772
pkgspec.repo = entry.repo
6873
pkgspec.path = entry.path
6974
pkgspec.pinned = entry.pinned
70-
pkgspec.path = project_rel_path(ctx.env, source_path(ctx.env.project_file, pkgspec))
75+
pkgspec.path = project_rel_path(ctx.env, source_path(ctx.env.project_file, pkgspec)::String)
7176
end
72-
pkgfilepath = source_path(ctx.env.project_file, pkgspec)
77+
pkgfilepath = source_path(ctx.env.project_file, pkgspec)::String
7378
return joinpath(pkgfilepath, "test")
7479
end
7580

src/julia-1.9/activate_do.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ Indeed this is basically extracted from what `Pkg.test()` does.
1212
function activate(f, pkg::AbstractString=current_pkg_name())
1313
ctx, pkgspec = ctx_and_pkgspec(pkg)
1414

15-
test_project_override = maybe_gen_project_override!(ctx, pkgspec)
16-
return sandbox(ctx, pkgspec, pkgspec.path, joinpath(pkgspec.path, "test"), test_project_override) do
15+
test_project_override = maybe_gen_project_override!(ctx, pkgspec)
16+
path = pkgspec.path::String
17+
return sandbox(ctx, pkgspec, path, joinpath(path, "test"), test_project_override) do
1718
flush(stdout)
1819
f()
1920
end

src/julia-1.9/activate_set.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function activate(pkg::AbstractString=current_pkg_name())
1111
# This needs to be first as `gen_target_project` fixes `pkgspec.path` if it is nothing
1212
sandbox_project_override = maybe_gen_project_override!(ctx, pkgspec)
1313

14-
sandbox_path = joinpath(pkgspec.path, "test")
14+
sandbox_path = joinpath(pkgspec.path::String, "test")
1515
sandbox_project = projectfile_path(sandbox_path)
1616

1717
tmp = mktempdir()
@@ -71,7 +71,7 @@ function activate(pkg::AbstractString=current_pkg_name())
7171
# Absolutify stdlibs paths
7272
for (uuid, entry) in temp_ctx.env.manifest
7373
if is_stdlib(uuid)
74-
entry.path = Types.stdlib_path(entry.name)
74+
entry.path = Types.stdlib_path(entry.name::String)
7575
end
7676
end
7777
write_env(temp_ctx.env; update_undo=false)

src/julia-1.9/common.jl

+11-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ function Base.showerror(io::IO, ex::TestEnvError, bt; backtrace=true)
66
printstyled(io, ex.msg, color=Base.error_color())
77
end
88

9-
10-
current_pkg_name() = (Context().env.pkg::PackageSpec).name
9+
function current_pkg_name()
10+
ctx = Context()
11+
ctx.env.pkg === nothing && throw(TestEnvError("trying to activate test environment of an unnamed project"))
12+
return ctx.env.pkg.name
13+
end
1114

1215
"""
1316
ctx, pkgspec = ctx_and_pkgspec(pkg::AbstractString)
@@ -46,7 +49,9 @@ end
4649

4750

4851
function test_dir_has_project_file(ctx, pkgspec)
49-
return isfile(joinpath(get_test_dir(ctx, pkgspec), "Project.toml"))
52+
test_dir = get_test_dir(ctx, pkgspec)
53+
test_dir === nothing && return false
54+
return isfile(joinpath(test_dir, "Project.toml"))
5055
end
5156

5257
"""
@@ -60,16 +65,16 @@ function get_test_dir(ctx::Context, pkgspec::Pkg.Types.PackageSpec)
6065
pkgspec.path = dirname(ctx.env.project_file)
6166
pkgspec.version = ctx.env.pkg.version
6267
else
63-
is_stdlib(pkgspec.uuid) && return
68+
is_stdlib(pkgspec.uuid::Base.UUID) && return
6469
entry = manifest_info(ctx.env.manifest, pkgspec.uuid)
6570
pkgspec.version = entry.version
6671
pkgspec.tree_hash = entry.tree_hash
6772
pkgspec.repo = entry.repo
6873
pkgspec.path = entry.path
6974
pkgspec.pinned = entry.pinned
70-
pkgspec.path = project_rel_path(ctx.env, source_path(ctx.env.project_file, pkgspec))
75+
pkgspec.path = project_rel_path(ctx.env, source_path(ctx.env.project_file, pkgspec)::String)
7176
end
72-
pkgfilepath = source_path(ctx.env.project_file, pkgspec)
77+
pkgfilepath = source_path(ctx.env.project_file, pkgspec)::String
7378
return joinpath(pkgfilepath, "test")
7479
end
7580

0 commit comments

Comments
 (0)