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