1
1
2
2
# Originally from Pkg.Operations.sandbox
3
- @static if VERSION <= v " 1.1" # 1.0 or 1.1
4
- # For now will just abuse that we solved sandbox
5
- function make_test_env (ctx:: Context , pkgspec)
6
- safe_dir = mktempdir ()
7
- _sandbox (ctx, pkgspec) do
8
- cp (Base. active_project (), joinpath (safe_dir, " Project.toml" ))
9
- end
10
- Pkg. activate (safe_dir)
11
- Pkg. resolve ()
12
- return nothing
3
+ function make_test_env (ctx:: Context , target)
4
+ # This needs to be first as `gen_target_project` fixes `target.path` if it is nothing
5
+ sandbox_project_override = if ! test_dir_has_project_file (ctx, target)
6
+ sandbox_project_override = gen_target_project (ctx, target, target. path, " test" )
7
+ else
8
+ nothing
13
9
end
14
- else
15
- function make_test_env (ctx:: Context , target)
16
- # This needs to be first as `gen_target_project` fixes `target.path` if it is nothing
17
- sandbox_project_override = if ! test_dir_has_project_file (ctx, target)
18
- sandbox_project_override = @static if VERSION < v " 1.7-a"
19
- gen_target_project (ctx, target, target. path, " test" )
20
- else
21
- gen_target_project (ctx. env, ctx. registries, target, target. path, " test" )
22
- end
23
- else
24
- nothing
25
- end
26
10
27
- sandbox_path = joinpath (target. path, " test" )
28
- sandbox_project = projectfile_path (sandbox_path)
11
+ sandbox_path = joinpath (target. path, " test" )
12
+ sandbox_project = projectfile_path (sandbox_path)
29
13
30
- tmp = mktempdir ()
31
- tmp_project = projectfile_path (tmp)
32
- tmp_manifest = manifestfile_path (tmp)
14
+ tmp = mktempdir ()
15
+ tmp_project = projectfile_path (tmp)
16
+ tmp_manifest = manifestfile_path (tmp)
33
17
34
- # Copy env info over to temp env
35
- if sandbox_project_override != = nothing
36
- Types. write_project (sandbox_project_override, tmp_project)
37
- elseif isfile (sandbox_project)
38
- cp (sandbox_project, tmp_project)
39
- chmod (tmp_project, 0o600 )
40
- end
41
- # create merged manifest
42
- # - copy over active subgraph
43
- # - abspath! to maintain location of all deved nodes
44
- working_manifest = if VERSION <= v " 1.7-a"
45
- abspath! (ctx, sandbox_preserve (ctx, target, tmp_project))
46
- else
47
- abspath! (ctx. env, sandbox_preserve (ctx. env, target, tmp_project))
48
- end
49
- # - copy over fixed subgraphs from test subgraph
50
- # really only need to copy over "special" nodes
51
- sandbox_env = Types. EnvCache (projectfile_path (sandbox_path))
52
- sandbox_manifest = if VERSION <= v " 1.7-a"
53
- abspath! (sandbox_path, sandbox_env. manifest)
54
- else
55
- abspath! (sandbox_env, sandbox_env. manifest)
56
- end
57
- for (name, uuid) in sandbox_env. project. deps
58
- entry = get (sandbox_manifest, uuid, nothing )
59
- if entry != = nothing && isfixed (entry)
60
- subgraph = prune_manifest (sandbox_manifest, [uuid])
61
- for (uuid, entry) in subgraph
62
- if haskey (working_manifest, uuid)
63
- pkgerror (" can not merge projects" )
64
- end
65
- working_manifest[uuid] = entry
18
+ # Copy env info over to temp env
19
+ if sandbox_project_override != = nothing
20
+ Types. write_project (sandbox_project_override, tmp_project)
21
+ elseif isfile (sandbox_project)
22
+ cp (sandbox_project, tmp_project)
23
+ chmod (tmp_project, 0o600 )
24
+ end
25
+ # create merged manifest
26
+ # - copy over active subgraph
27
+ # - abspath! to maintain location of all deved nodes
28
+ working_manifest = abspath! (ctx, sandbox_preserve (ctx, target, tmp_project))
29
+
30
+ # - copy over fixed subgraphs from test subgraph
31
+ # really only need to copy over "special" nodes
32
+ sandbox_env = Types. EnvCache (projectfile_path (sandbox_path))
33
+ sandbox_manifest = abspath! (sandbox_path, sandbox_env. manifest)
34
+
35
+ for (name, uuid) in sandbox_env. project. deps
36
+ entry = get (sandbox_manifest, uuid, nothing )
37
+ if entry != = nothing && isfixed (entry)
38
+ subgraph = prune_manifest (sandbox_manifest, [uuid])
39
+ for (uuid, entry) in subgraph
40
+ if haskey (working_manifest, uuid)
41
+ pkgerror (" can not merge projects" )
66
42
end
43
+ working_manifest[uuid] = entry
67
44
end
68
45
end
46
+ end
69
47
70
- Types. write_manifest (working_manifest, tmp_manifest)
48
+ Types. write_manifest (working_manifest, tmp_manifest)
71
49
72
- # sandbox
73
- push! (empty! (LOAD_PATH ), " @" , tmp)
74
- Base. ACTIVE_PROJECT[] = nothing
50
+ # sandbox
51
+ push! (empty! (LOAD_PATH ), " @" , tmp)
52
+ Base. ACTIVE_PROJECT[] = nothing
75
53
76
- temp_ctx = Context ()
77
- temp_ctx. env. project. deps[target. name] = target. uuid
54
+ temp_ctx = Context ()
55
+ temp_ctx. env. project. deps[target. name] = target. uuid
78
56
79
- try
80
- Pkg. resolve (temp_ctx; io= devnull )
81
- @debug " Using _parent_ dep graph"
82
- catch err# TODO
83
- @debug err
84
- @warn " Could not use exact versions of packages in manifest, re-resolving"
85
- temp_ctx. env. manifest. deps = Dict (
86
- uuid => entry for
87
- (uuid, entry) in temp_ctx. env. manifest. deps if isfixed (entry)
88
- )
89
- Pkg. resolve (temp_ctx; io= devnull )
90
- @debug " Using _clean_ dep graph"
91
- end
57
+ try
58
+ Pkg. resolve (temp_ctx; io= devnull )
59
+ @debug " Using _parent_ dep graph"
60
+ catch err# TODO
61
+ @debug err
62
+ @warn " Could not use exact versions of packages in manifest, re-resolving"
63
+ temp_ctx. env. manifest. deps = Dict (
64
+ uuid => entry for
65
+ (uuid, entry) in temp_ctx. env. manifest. deps if isfixed (entry)
66
+ )
67
+ Pkg. resolve (temp_ctx; io= devnull )
68
+ @debug " Using _clean_ dep graph"
69
+ end
92
70
93
- # Absolutify stdlibs paths
94
- for (uuid, entry) in temp_ctx. env. manifest
95
- if is_stdlib (uuid)
96
- entry. path = Types. stdlib_path (entry. name)
97
- end
71
+ # Absolutify stdlibs paths
72
+ for (uuid, entry) in temp_ctx. env. manifest
73
+ if is_stdlib (uuid)
74
+ entry. path = Types. stdlib_path (entry. name)
98
75
end
99
- write_env (temp_ctx. env; update_undo= false )
100
-
101
- # update enviroment variables
102
- path_sep = Sys. iswindows () ? ' ;' : ' :'
103
- ENV [" JULIA_LOAD_PATH" ] = " @$(path_sep)$(tmp) "
104
- delete! (ENV , " JULIA_PROJECT" )
105
-
106
- return Base. active_project ()
107
76
end
77
+ write_env (temp_ctx. env; update_undo= false )
78
+
79
+ # update enviroment variables
80
+ path_sep = Sys. iswindows () ? ' ;' : ' :'
81
+ ENV [" JULIA_LOAD_PATH" ] = " @$(path_sep)$(tmp) "
82
+ delete! (ENV , " JULIA_PROJECT" )
83
+
84
+ return Base. active_project ()
108
85
end
0 commit comments