Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
fatteneder committed May 21, 2023
1 parent be58fca commit d0e93a0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
22 changes: 21 additions & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ STDLIBDIR := $(build_datarootdir)/julia/stdlib/$(VERSDIR)
TESTGROUPS = unicode strings compiler
TESTS = all default stdlib $(TESTGROUPS) \
$(patsubst $(STDLIBDIR)/%/,%,$(dir $(wildcard $(STDLIBDIR)/*/.))) \
$(filter-out runtests testdefs, \
$(filter-out runtests testdefs relocatedepot, \
$(patsubst $(SRCDIR)/%.jl,%,$(wildcard $(SRCDIR)/*.jl))) \
$(foreach group,$(TESTGROUPS), \
$(patsubst $(SRCDIR)/%.jl,%,$(wildcard $(SRCDIR)/$(group)/*.jl)))
Expand All @@ -29,6 +29,26 @@ $(addprefix revise-, $(TESTS)): revise-% :
@cd $(SRCDIR) && \
$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl --revise $*)

relocatedepot:
@rm -rf $(SRCDIR)/relocatedepot
@cd $(SRCDIR) && \
$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl $@)
@mkdir $(SRCDIR)/relocatedepot
@cp -RP $(build_datarootdir)/julia/{stdlib,compiled,environments}/ $(SRCDIR)/relocatedepot/
@[[ -e $(build_datarootdir)/julia/packages ]] && cp -RP $(build_datarootdir)/julia/packages/ $(SRCDIR)/relocatedepot/
@cd $(SRCDIR) && \
$(call PRINT_JULIA, $(call spawn,RELOCATEDEPOT="" JULIA_DEPOT_PATH=$(SRCDIR)/relocatedepot $(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl $@)

revise-relocatedepot: revise-% :
@rm -rf $(SRCDIR)/relocatedepot
@cd $(SRCDIR) && \
$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl --revise $*)
@mkdir $(SRCDIR)/relocatedepot
@cp -RP $(build_datarootdir)/julia/{stdlib,compiled,environments}/ $(SRCDIR)/relocatedepot/
@[[ -e $(build_datarootdir)/julia/packages ]] && cp -RP $(build_datarootdir)/julia/packages/ $(SRCDIR)/relocatedepot/
@cd $(SRCDIR) && \
$(call PRINT_JULIA, $(call spawn,RELOCATEDEPOT="" JULIA_DEPOT_PATH=$(SRCDIR)/relocatedepot $(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl --revise $*)

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

Expand Down
2 changes: 1 addition & 1 deletion test/choosetests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const TESTNAMES = [
"some", "meta", "stacktraces", "docs", "gc",
"misc", "threads", "stress", "binaryplatforms", "atexit",
"enums", "cmdlineargs", "int", "interpreter",
"checked", "bitset", "floatfuncs", "precompile",
"checked", "bitset", "floatfuncs", "precompile", "relocatedepot",
"boundscheck", "error", "ambiguous", "cartesian", "osutils",
"channels", "iostream", "secretbuffer", "specificity",
"reinterpretarray", "syntax", "corelogging", "missing", "asyncmap",
Expand Down
25 changes: 25 additions & 0 deletions test/relocatedepot.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Test


include("testenv.jl")


@testset "compile and load relocated pkg" begin
name = "DelimitedFiles"
uuid = Base.UUID("8bb1440f-4735-579b-a4ab-409b98df4dab")
pkg = Base.PkgId(uuid, name)
if !relocated_depot
# precompile
Base.require(Main, :DelimitedFiles)
@test Base.root_module_exists(pkg) == true
else
path = Base.locate_package(pkg)
iscached = @lock Base.require_lock begin
m = Base._require_search_from_serialized(pkg, path, UInt128(0))
m isa Module
end
@test iscached == true # can load from cache
Base.require(Main, :DelimitedFiles)
@test Base.root_module_exists(pkg) == true
end
end
2 changes: 2 additions & 0 deletions test/testenv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ if !@isdefined(testenv_defined)
const rr_exename = ``
end

const relocated_depot = haskey(ENV, "RELOCATEDEPOT")

function addprocs_with_testenv(X; rr_allowed=true, kwargs...)
exename = rr_allowed ? `$rr_exename $test_exename` : test_exename
addprocs(X; exename=exename, exeflags=test_exeflags, kwargs...)
Expand Down

0 comments on commit d0e93a0

Please sign in to comment.