-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provide a way to run REPL commands outside the REPL (#173)
(cherry picked from commit 7a8d376e02fe8073153e148269cc74be337d3619)
- Loading branch information
1 parent
3047cf0
commit 98d4332
Showing
5 changed files
with
73 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module REPLTests | ||
|
||
using Pkg3 | ||
using UUIDs | ||
using Test | ||
|
||
include("utils.jl") | ||
|
||
const TEST_PKG = (name = "Example", uuid = UUID("7876af07-990d-54b4-ab0e-23690620f79a")) | ||
|
||
temp_pkg_dir() do project_path | ||
cd(project_path) do | ||
@show LOAD_PATH | ||
pkg"init" | ||
pkg"add Example" | ||
@test isinstalled(TEST_PKG) | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function temp_pkg_dir(fn::Function) | ||
local env_dir | ||
local old_load_path | ||
local old_depot_path | ||
try | ||
old_load_path = copy(LOAD_PATH) | ||
old_depot_path = copy(DEPOT_PATH) | ||
empty!(LOAD_PATH) | ||
empty!(DEPOT_PATH) | ||
mktempdir() do env_dir | ||
mktempdir() do depot_dir | ||
pushfirst!(LOAD_PATH, env_dir) | ||
pushfirst!(DEPOT_PATH, depot_dir) | ||
# Add the standard library paths back | ||
vers = "v$(VERSION.major).$(VERSION.minor)" | ||
push!(LOAD_PATH, abspath(Sys.BINDIR, "..", "local", "share", "julia", "site", vers)) | ||
push!(LOAD_PATH, abspath(Sys.BINDIR, "..", "share", "julia", "site", vers)) | ||
fn(env_dir) | ||
end | ||
end | ||
finally | ||
append!(LOAD_PATH, old_load_path) | ||
append!(DEPOT_PATH, old_depot_path) | ||
end | ||
end | ||
|
||
isinstalled(pkg) = Base.locate_package(Base.PkgId(pkg.uuid, pkg.name)) !== nothing |