Skip to content

Commit 3a5e1f1

Browse files
authored
test: Automatically install Revise for revise- targets (#58559)
This fixes #50256, by automatically installing a private copy of `Revise` into test/deps, similar to the mechanism for Documenter in make.jl. As in #58529, I made sure that this worked with both in-tree and out-of-tree builds.
1 parent 5488386 commit 3a5e1f1

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ deps: $(SRCCACHE)/UnicodeData-$(UNICODE_DATA_VERSION).txt
4242
cp "$<" UnicodeData.txt
4343

4444
alldeps: deps
45-
$(JULIA_EXECUTABLE) --color=yes $(call cygpath_w,$(SRCDIR)/make.jl) deps
45+
$(JULIA_EXECUTABLE) --color=yes $(call cygpath_w,$(SRCDIR)/make.jl) deps $(DOCUMENTER_OPTIONS)
4646

4747
checksum-unicodedata: $(SRCCACHE)/UnicodeData-$(UNICODE_DATA_VERSION).txt
4848
$(JLCHECKSUM) "$<"

test/Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,47 @@ EMBEDDING_ARGS := "JULIA=$(JULIA_EXECUTABLE)" "BIN=$(SRCDIR)/embedding" "CC=$(CC
2525
GCEXT_ARGS := "JULIA=$(JULIA_EXECUTABLE)" "BIN=$(SRCDIR)/gcext" "CC=$(CC)"
2626

2727
TRIMMING_ARGS := "JULIA=$(JULIA_EXECUTABLE)" "BIN=$(SRCDIR)/trimming" "CC=$(CC)"
28+
TEST_JULIA_OPTIONS := --check-bounds=yes --startup-file=no --depwarn=error
29+
TEST_SCRIPT_OPTIONS := --buildroot=$(call cygpath_w,$(BUILDROOT))
2830

2931
default:
3032

3133
$(TESTS):
3234
@cd $(SRCDIR) && \
33-
$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl $@)
35+
$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) $(TEST_JULIA_OPTIONS) ./runtests.jl $(TEST_SCRIPT_OPTIONS) $@)
36+
37+
install-revise-deps:
38+
$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) $(TEST_JULIA_OPTIONS) ./runtests.jl $(TEST_SCRIPT_OPTIONS) --revise)
3439

3540
$(addprefix revise-, $(TESTS)): revise-% :
3641
@cd $(SRCDIR) && \
37-
$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl --revise $*)
42+
$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) $(TEST_JULIA_OPTIONS) ./runtests.jl $(TEST_SCRIPT_OPTIONS) --revise $*)
3843

3944
relocatedepot:
4045
@rm -rf $(SRCDIR)/relocatedepot
4146
@cd $(SRCDIR) && \
42-
$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl $@)
47+
$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) $(TEST_JULIA_OPTIONS) ./runtests.jl $(TEST_SCRIPT_OPTIONS) $@)
4348
@mkdir $(SRCDIR)/relocatedepot
4449
@cp -R $(build_datarootdir)/julia $(SRCDIR)/relocatedepot
4550
@cp -R $(SRCDIR)/RelocationTestPkg1 $(SRCDIR)/relocatedepot
4651
@cp -R $(SRCDIR)/RelocationTestPkg2 $(SRCDIR)/relocatedepot
4752
@cp -R $(SRCDIR)/RelocationTestPkg3 $(SRCDIR)/relocatedepot
4853
@cp -R $(SRCDIR)/RelocationTestPkg4 $(SRCDIR)/relocatedepot
4954
@cd $(SRCDIR) && \
50-
$(call PRINT_JULIA, $(call spawn,RELOCATEDEPOT="" $(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl $@)
55+
$(call PRINT_JULIA, $(call spawn,RELOCATEDEPOT="" $(JULIA_EXECUTABLE)) $(TEST_JULIA_OPTIONS) ./runtests.jl $(TEST_SCRIPT_OPTIONS) $@)
5156

52-
revise-relocatedepot: revise-% :
57+
revise-relocatedepot: revise-% : dep_revise
5358
@rm -rf $(SRCDIR)/relocatedepot
5459
@cd $(SRCDIR) && \
55-
$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl --revise $*)
60+
$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) $(TEST_JULIA_OPTIONS) ./runtests.jl $(TEST_SCRIPT_OPTIONS) --revise $*)
5661
@mkdir $(SRCDIR)/relocatedepot
5762
@cp -R $(build_datarootdir)/julia $(SRCDIR)/relocatedepot
5863
@cp -R $(SRCDIR)/RelocationTestPkg1 $(SRCDIR)/relocatedepot
5964
@cp -R $(SRCDIR)/RelocationTestPkg2 $(SRCDIR)/relocatedepot
6065
@cp -R $(SRCDIR)/RelocationTestPkg3 $(SRCDIR)/relocatedepot
6166
@cp -R $(SRCDIR)/RelocationTestPkg4 $(SRCDIR)/relocatedepot
6267
@cd $(SRCDIR) && \
63-
$(call PRINT_JULIA, $(call spawn,RELOCATEDEPOT="" $(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl --revise $*)
68+
$(call PRINT_JULIA, $(call spawn,RELOCATEDEPOT="" $(JULIA_EXECUTABLE)) $(TEST_JULIA_OPTIONS) ./runtests.jl $(TEST_SCRIPT_OPTIONS) --revise $*)
6469

6570
embedding:
6671
@$(MAKE) -C $(SRCDIR)/$@ check $(EMBEDDING_ARGS)

test/choosetests.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ function choosetests(choices = [])
100100
seed = rand(RandomDevice(), UInt128)
101101
ci_option_passed = false
102102
dryrun = false
103+
buildroot = joinpath(@__DIR__, "..")
103104

104105
for (i, t) in enumerate(choices)
105106
if t == "--skip"
@@ -109,6 +110,8 @@ function choosetests(choices = [])
109110
exit_on_error = true
110111
elseif t == "--revise"
111112
use_revise = true
113+
elseif startswith(t, "--buildroot=")
114+
buildroot = t[(length("--buildroot=") + 1):end]
112115
elseif startswith(t, "--seed=")
113116
seed = parse(UInt128, t[(length("--seed=") + 1):end])
114117
elseif t == "--ci"
@@ -124,6 +127,7 @@ function choosetests(choices = [])
124127
--help-list : prints the options computed without running them
125128
--revise : load Revise
126129
--seed=<SEED> : set the initial seed for all testgroups (parsed as a UInt128)
130+
--buildroot=<PATH> : set the build root directory (default: in-tree)
127131
--skip <NAMES>... : skip test or collection tagged with <NAMES>
128132
TESTS:
129133
Can be special tokens, such as "all", "unicode", "stdlib", the names of stdlib \
@@ -261,5 +265,5 @@ function choosetests(choices = [])
261265
empty!(tests)
262266
end
263267

264-
return (; tests, net_on, exit_on_error, use_revise, seed)
268+
return (; tests, net_on, exit_on_error, use_revise, buildroot, seed)
265269
end

test/runtests.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ include("choosetests.jl")
1313
include("testenv.jl")
1414
include("buildkitetestjson.jl")
1515

16-
(; tests, net_on, exit_on_error, use_revise, seed) = choosetests(ARGS)
16+
(; tests, net_on, exit_on_error, use_revise, buildroot, seed) = choosetests(ARGS)
1717
tests = unique(tests)
1818

1919
if Sys.islinux()
@@ -26,8 +26,15 @@ else
2626
end
2727

2828
if use_revise
29+
# First put this at the top of the DEPOT PATH to install revise if necessary.
30+
# Once it's loaded, we swizzle it to the end, to avoid confusing any tests.
31+
pushfirst!(DEPOT_PATH, joinpath(buildroot, "test", "deps"))
32+
using Pkg
33+
Pkg.activate(joinpath(@__DIR__, "deps"))
34+
Pkg.instantiate()
2935
using Revise
3036
union!(Revise.stdlib_names, Symbol.(STDLIBS))
37+
push!(DEPOT_PATH, popfirst!(DEPOT_PATH))
3138
# Remote-eval the following to initialize Revise in workers
3239
const revise_init_expr = quote
3340
using Revise
@@ -37,6 +44,11 @@ if use_revise
3744
end
3845
end
3946

47+
if isempty(tests)
48+
println("No tests selected. Exiting.")
49+
exit()
50+
end
51+
4052
const max_worker_rss = if haskey(ENV, "JULIA_TEST_MAXRSS_MB")
4153
parse(Int, ENV["JULIA_TEST_MAXRSS_MB"]) * 2^20
4254
else

0 commit comments

Comments
 (0)