diff --git a/base/loading.jl b/base/loading.jl index cdc1fc1442d1bd..cfc02ebc7e8d80 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -538,15 +538,13 @@ function stale_cachefile(modpath, cachefile) end function recompile_stale(mod, cachefile) - path = find_in_path(string(mod), nothing) + smod = string(mod) + path = find_in_path(smod, nothing) if path === nothing - rm(cachefile) - error("module $mod not found in current path; removed orphaned cache file $cachefile") + error("module $mod not found in current path; you should rm(\"$(escape_string(cachefile))\") to remove the orphaned cache file") end if stale_cachefile(path, cachefile) info("Recompiling stale cache file $cachefile for module $mod.") - if !success(create_expr_cache(path, cachefile)) - error("Failed to precompile $mod to $cachefile") - end + compilecache(smod) end end diff --git a/test/compile.jl b/test/compile.jl index c8fdd7913c8cb8..dfb8ccb9753c78 100644 --- a/test/compile.jl +++ b/test/compile.jl @@ -3,6 +3,7 @@ using Base.Test dir = mktempdir() +dir2 = mktempdir() insert!(LOAD_PATH, 1, dir) insert!(Base.LOAD_CACHE_PATH, 1, dir) Foo_module = :Foo4b3a94a1a081a8cb @@ -71,6 +72,16 @@ try end Base.compilecache("FooBar") sleep(2) + @test isfile(joinpath(dir, "FooBar.ji")) + + touch(FooBar_file) + insert!(Base.LOAD_CACHE_PATH, 1, dir2) + Base.recompile_stale(:FooBar, joinpath(dir, "FooBar.ji")) + sleep(2) + @test isfile(joinpath(dir2, "FooBar.ji")) + @test Base.stale_cachefile(FooBar_file, joinpath(dir, "FooBar.ji")) + @test !Base.stale_cachefile(FooBar_file, joinpath(dir2, "FooBar.ji")) + open(FooBar_file, "w") do f print(f, """ __precompile__(true) @@ -83,9 +94,10 @@ try @test_throws ErrorException Base.require(:FooBar) finally - splice!(Base.LOAD_CACHE_PATH, 1) + splice!(Base.LOAD_CACHE_PATH, 1:2) splice!(LOAD_PATH, 1) rm(dir, recursive=true) + rm(dir2, recursive=true) end # test --compilecache=no command line option