|
1 | 1 | # This file is a part of Julia. License is MIT: https://julialang.org/license |
2 | 2 |
|
| 3 | +import Revise |
3 | 4 | using DistributedNext, Random, Serialization, Sockets |
4 | 5 | import DistributedNext |
5 | 6 | import DistributedNext: launch, manage |
@@ -1993,6 +1994,69 @@ end |
1993 | 1994 | @test length(exited_workers) == 1 |
1994 | 1995 | end |
1995 | 1996 |
|
| 1997 | +# This is a simplified copy of a test from Revise.jl's tests |
| 1998 | +@testset "Revise.jl integration" begin |
| 1999 | + function rm_precompile(pkgname::AbstractString) |
| 2000 | + filepath = Base.cache_file_entry(Base.PkgId(pkgname)) |
| 2001 | + isa(filepath, Tuple) && (filepath = filepath[1]*filepath[2]) # Julia 1.3+ |
| 2002 | + for depot in DEPOT_PATH |
| 2003 | + fullpath = joinpath(depot, filepath) |
| 2004 | + isfile(fullpath) && rm(fullpath) |
| 2005 | + end |
| 2006 | + end |
| 2007 | + |
| 2008 | + pid = only(addprocs(1)) |
| 2009 | + |
| 2010 | + # Test that initialization succeeds by checking that Main.whichtt is defined |
| 2011 | + # on the worker, which is defined by Revise.init_worker(). |
| 2012 | + @test timedwait(() ->remotecall_fetch(() -> hasproperty(Main, :whichtt), pid), 10) == :ok |
| 2013 | + |
| 2014 | + tmpdir = mktempdir() |
| 2015 | + @everywhere push!(LOAD_PATH, $tmpdir) # Don't want to share this LOAD_PATH |
| 2016 | + |
| 2017 | + # Create a fake package |
| 2018 | + module_file = joinpath(tmpdir, "ReviseDistributed", "src", "ReviseDistributed.jl") |
| 2019 | + mkpath(dirname(module_file)) |
| 2020 | + write(module_file, |
| 2021 | + """ |
| 2022 | + module ReviseDistributed |
| 2023 | +
|
| 2024 | + f() = π |
| 2025 | + g(::Int) = 0 |
| 2026 | +
|
| 2027 | + end |
| 2028 | + """) |
| 2029 | + |
| 2030 | + # Check that we can use it |
| 2031 | + @everywhere using ReviseDistributed |
| 2032 | + for p in procs() |
| 2033 | + @test remotecall_fetch(ReviseDistributed.f, p) == π |
| 2034 | + @test remotecall_fetch(ReviseDistributed.g, p, 1) == 0 |
| 2035 | + end |
| 2036 | + |
| 2037 | + # Test changing and deleting methods |
| 2038 | + write(module_file, |
| 2039 | + """ |
| 2040 | + module ReviseDistributed |
| 2041 | +
|
| 2042 | + f() = 3.0 |
| 2043 | +
|
| 2044 | + end |
| 2045 | + """) |
| 2046 | + Revise.revise() |
| 2047 | + for p in procs() |
| 2048 | + # We use timedwait() here because worker updates from Revise are asynchronous |
| 2049 | + @test timedwait(() -> remotecall_fetch(ReviseDistributed.f, p) == 3.0, 10) == :ok |
| 2050 | + |
| 2051 | + @test_throws RemoteException remotecall_fetch(ReviseDistributed.g, p, 1) |
| 2052 | + end |
| 2053 | + |
| 2054 | + rmprocs(workers()) |
| 2055 | + rm_precompile("ReviseDistributed") |
| 2056 | + pop!(LOAD_PATH) |
| 2057 | +end |
| 2058 | + |
| 2059 | + |
1996 | 2060 | # Run topology tests last after removing all workers, since a given |
1997 | 2061 | # cluster at any time only supports a single topology. |
1998 | 2062 | if nprocs() > 1 |
|
0 commit comments