Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

absolutify --project path #28625

Merged
merged 1 commit into from
Aug 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ function init_load_path()
unsafe_string(Base.JLOptions().project) :
get(ENV, "JULIA_PROJECT", nothing))
HOME_PROJECT[] =
project == nothing ? nothing :
project == "" ? nothing :
project == "@." ? current_project() : project
project == "@." ? current_project() : abspath(project)
append!(empty!(LOAD_PATH), paths)
end

Expand Down
2 changes: 2 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,8 @@ static void jl_resolve_sysimg_location(JL_IMAGE_SEARCH rel)
jl_options.outputbc = abspath(jl_options.outputbc, 0);
if (jl_options.machine_file)
jl_options.machine_file = abspath(jl_options.machine_file, 0);
if (jl_options.project && strncmp(jl_options.project, "@.", strlen(jl_options.project)) != 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can use strcmp – this would just be a more verbose and slower way of implementing that

jl_options.project = abspath(jl_options.project, 0);

const char **cmdp = jl_options.cmds;
if (cmdp) {
Expand Down
16 changes: 16 additions & 0 deletions test/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,22 @@ finally
popfirst!(LOAD_PATH)
end

@testset "--project and JULIA_PROJECT paths should be absolutified" begin
mktempdir() do dir; cd(dir) do
mkdir("foo")
script = """
using Test
old = Base.active_project()
cd("foo")
@test Base.active_project() == old
"""
@test success(`$(Base.julia_cmd()) --project=foo -e $(script)`)
withenv("JULIA_PROJECT" => "foo") do
@test success(`$(Base.julia_cmd()) -e $(script)`)
end
end; end
end

## cleanup after tests ##

for env in keys(envs)
Expand Down