@@ -6,8 +6,11 @@ function Base.showerror(io::IO, ex::TestEnvError, bt; backtrace=true)
6
6
printstyled (io, ex. msg, color= Base. error_color ())
7
7
end
8
8
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
11
14
12
15
"""
13
16
ctx, pkgspec = ctx_and_pkgspec(pkg::AbstractString)
46
49
47
50
48
51
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" ))
50
55
end
51
56
52
57
"""
@@ -60,16 +65,16 @@ function get_test_dir(ctx::Context, pkgspec::Pkg.Types.PackageSpec)
60
65
pkgspec. path = dirname (ctx. env. project_file)
61
66
pkgspec. version = ctx. env. pkg. version
62
67
else
63
- is_stdlib (pkgspec. uuid) && return
68
+ is_stdlib (pkgspec. uuid:: Base.UUID ) && return
64
69
entry = manifest_info (ctx. env. manifest, pkgspec. uuid)
65
70
pkgspec. version = entry. version
66
71
pkgspec. tree_hash = entry. tree_hash
67
72
pkgspec. repo = entry. repo
68
73
pkgspec. path = entry. path
69
74
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 )
71
76
end
72
- pkgfilepath = source_path (ctx. env. project_file, pkgspec)
77
+ pkgfilepath = source_path (ctx. env. project_file, pkgspec):: String
73
78
return joinpath (pkgfilepath, " test" )
74
79
end
75
80
0 commit comments