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

RFC: Fixed relative path include on remote machines #21832

Merged
merged 9 commits into from
Jun 27, 2017
Merged
13 changes: 10 additions & 3 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,17 @@ const _require_dependencies = Any[] # a list of (path, mtime) tuples that are th
const _track_dependencies = Ref(false) # set this to true to track the list of file dependencies
function _include_dependency(_path::AbstractString)
prev = source_path(nothing)
path = (prev === nothing) ? abspath(_path) : joinpath(dirname(prev), _path)
if prev === nothing
if myid() == 1
path = abspath(_path)
else
path = joinpath(remotecall_fetch(abspath, 1, "."), _path)
end
else
path = joinpath(dirname(prev), _path)
end
if myid() == 1 && _track_dependencies[]
apath = abspath(path)
push!(_require_dependencies, (apath, mtime(apath)))
push!(_require_dependencies, (path, mtime(path)))
end
return path, prev
end
Expand Down
41 changes: 41 additions & 0 deletions test/distributed_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,47 @@ catch ex
@test ex.captured.ex.exceptions[2].ex == UndefVarError(:DontExistOn1)
end

@test let
# creates a new worker in the same folder and tries to include file
tmp_file, temp_file_stream = mktemp()
close(temp_file_stream)
tmp_file = relpath(tmp_file)
try
proc = addprocs_with_testenv(1)
include(tmp_file)
remotecall_fetch(include, proc[1], tmp_file)
rmprocs(proc)
rm(tmp_file)
return true
catch e
println(e)
rm(tmp_file, force=true)
return false
end
end == true

@test let
# creates a new worker in the different folder and tries to include file
Copy link
Contributor

Choose a reason for hiding this comment

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

in a different folder

tmp_file, temp_file_stream = mktemp()
close(temp_file_stream)
tmp_file = relpath(tmp_file)
tmp_dir = relpath(mktempdir())
try
proc = addprocs_with_testenv(1, dir=tmp_dir)
include(tmp_file)
remotecall_fetch(include, proc[1], tmp_file)
rmprocs(proc)
rm(tmp_dir)
rm(tmp_file)
return true
catch e
println(e)
rm(tmp_dir, force=true)
rm(tmp_file, force=true)
return false
end
end == true

# Run topology tests last after removing all workers, since a given
# cluster at any time only supports a single topology.
rmprocs(workers())
Expand Down