|
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
|
@@ -1969,6 +1970,69 @@ end
|
1969 | 1970 | @test length(exited_workers) == 1
|
1970 | 1971 | end
|
1971 | 1972 |
|
| 1973 | +# This is a simplified copy of a test from Revise.jl's tests |
| 1974 | +@testset "Revise.jl integration" begin |
| 1975 | + function rm_precompile(pkgname::AbstractString) |
| 1976 | + filepath = Base.cache_file_entry(Base.PkgId(pkgname)) |
| 1977 | + isa(filepath, Tuple) && (filepath = filepath[1]*filepath[2]) # Julia 1.3+ |
| 1978 | + for depot in DEPOT_PATH |
| 1979 | + fullpath = joinpath(depot, filepath) |
| 1980 | + isfile(fullpath) && rm(fullpath) |
| 1981 | + end |
| 1982 | + end |
| 1983 | + |
| 1984 | + pid = only(addprocs(1)) |
| 1985 | + |
| 1986 | + # Test that initialization succeeds by checking that Main.whichtt is defined |
| 1987 | + # on the worker, which is defined by Revise.init_worker(). |
| 1988 | + @test timedwait(() ->remotecall_fetch(() -> hasproperty(Main, :whichtt), pid), 10) == :ok |
| 1989 | + |
| 1990 | + tmpdir = mktempdir() |
| 1991 | + @everywhere push!(LOAD_PATH, $tmpdir) # Don't want to share this LOAD_PATH |
| 1992 | + |
| 1993 | + # Create a fake package |
| 1994 | + module_file = joinpath(tmpdir, "ReviseDistributed", "src", "ReviseDistributed.jl") |
| 1995 | + mkpath(dirname(module_file)) |
| 1996 | + write(module_file, |
| 1997 | + """ |
| 1998 | + module ReviseDistributed |
| 1999 | +
|
| 2000 | + f() = π |
| 2001 | + g(::Int) = 0 |
| 2002 | +
|
| 2003 | + end |
| 2004 | + """) |
| 2005 | + |
| 2006 | + # Check that we can use it |
| 2007 | + @everywhere using ReviseDistributed |
| 2008 | + for p in procs() |
| 2009 | + @test remotecall_fetch(ReviseDistributed.f, p) == π |
| 2010 | + @test remotecall_fetch(ReviseDistributed.g, p, 1) == 0 |
| 2011 | + end |
| 2012 | + |
| 2013 | + # Test changing and deleting methods |
| 2014 | + write(module_file, |
| 2015 | + """ |
| 2016 | + module ReviseDistributed |
| 2017 | +
|
| 2018 | + f() = 3.0 |
| 2019 | +
|
| 2020 | + end |
| 2021 | + """) |
| 2022 | + Revise.revise() |
| 2023 | + for p in procs() |
| 2024 | + # We use timedwait() here because worker updates from Revise are asynchronous |
| 2025 | + @test timedwait(() -> remotecall_fetch(ReviseDistributed.f, p) == 3.0, 10) == :ok |
| 2026 | + |
| 2027 | + @test_throws RemoteException remotecall_fetch(ReviseDistributed.g, p, 1) |
| 2028 | + end |
| 2029 | + |
| 2030 | + rmprocs(workers()) |
| 2031 | + rm_precompile("ReviseDistributed") |
| 2032 | + pop!(LOAD_PATH) |
| 2033 | +end |
| 2034 | + |
| 2035 | + |
1972 | 2036 | # Run topology tests last after removing all workers, since a given
|
1973 | 2037 | # cluster at any time only supports a single topology.
|
1974 | 2038 | if nprocs() > 1
|
|
0 commit comments