Skip to content

Commit

Permalink
Fixed relative path include on remote machines
Browse files Browse the repository at this point in the history
Ref #21832
Squashed for backporting
(cherry picked from commit d86b37c)
(cherry picked from commit 7e7393c)
(cherry picked from commit 6a4acc0)
(cherry picked from commit 93cf6d9)
(cherry picked from commit 2379294)
(cherry picked from commit 7ff6322)
(cherry picked from commit 49abbf3)
(cherry picked from commit eadb699)
(cherry picked from commit 1ce1d75)
  • Loading branch information
Gollor authored and ararslan committed Sep 14, 2017
1 parent 152f814 commit 8b3ec35
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
13 changes: 10 additions & 3 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,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 @@ -1637,6 +1637,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
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

0 comments on commit 8b3ec35

Please sign in to comment.