55Include file `testpath` into `parentmodule`. If `revise` is `true`, `Revise`,
66which must be loaded beforehand in your Julia session, is used to track all
77recursively included files (in particular testsets). The `revise` keyword
8- defaults to `true` when `Revise` is loaded and `VERSION >= v"1.5"`, and to
9- `false` otherwise.
8+ defaults to `true` when `Revise` is loaded, and to `false` otherwise.
109
1110The point of using this function is when `revise` is `true` and in particular
1211when files are included recursively.
@@ -15,16 +14,12 @@ and if there are no recursively included files, this should be equivalent
1514to `Revise.includet(testpath)`, provided `parentmodule == Main` and
1615all `@testset`s defined in `testpath` are in a module defining
1716 `__revise_mode__ = :eval`.
18-
19- !!! compat "Julia 1.5"
20- This function requires at least Julia 1.5 when `revise` is `true`.
2117"""
2218function load (testpath:: AbstractString ;
2319 parentmodule:: Module = Main, revise:: Maybe{Bool} = nothing )
2420
25- revise === true && VERSION < v " 1.5" &&
26- error (" the `revise` keyword requires at least Julia 1.5" )
2721 Revise = get_revise (revise)
22+ testpath = normpath (abspath (testpath))
2823
2924 if Revise === nothing
3025 Base. include (parentmodule, testpath)
@@ -53,10 +48,7 @@ If `revise` is `true`, `Revise`, which must be loaded beforehand in your Julia
5348session, is used to track the test files (in particular testsets). Note that
5449this might be brittle, and it's recommended instead to load your test module
5550via `using ModTests`. The `revise` keyword defaults to `true` when `Revise` is
56- loaded and `VERSION >= v"1.5"`, and to `false` otherwise.
57-
58- !!! compat "Julia 1.5"
59- This function requires at least Julia 1.5 when `revise` is `true`.
51+ loaded, and to `false` otherwise.
6052"""
6153function load (packagemod:: Module , testfile:: Maybe{AbstractString} = nothing ;
6254 parentmodule:: Module = Main, revise:: Maybe{Bool} = nothing ,
@@ -200,8 +192,6 @@ be loaded beforehand in your Julia session. Note that this might be brittle
200192and not work in all cases. `revise` defaults to `true` when `Revise` is loaded,
201193and to `false` otherwise.
202194
203- !!! compat "Julia 1.5"
204- This function requires at least Julia 1.5.
205195"""
206196function hijack end
207197
@@ -215,14 +205,15 @@ function hijack(path::AbstractString, modname=nothing; parentmodule::Module=Main
215205
216206 # do first, to error early if necessary
217207 Revise = get_revise (revise)
208+ include = setinclude (include, testset)
218209
219210 if modname === nothing
220211 modname = replace (splitext (basename (path))[1 ], [' -' , ' .' ] => ' _' )
221212 end
222213 modname = Symbol (modname)
223214
224215 newmod = @eval parentmodule module $ modname end
225- populate_mod! (newmod, path; lazy= lazy, include= setinclude ( include, testset) ,
216+ populate_mod! (newmod, path; lazy= lazy, include= include,
226217 include_functions= include_functions,
227218 Revise= Revise)
228219 newmod
@@ -250,6 +241,7 @@ function populate_mod!(mod::Module, path; lazy, Revise, include::Maybe{Symbol}=n
250241 lazy ∈ (true , false , :brutal ) ||
251242 throw (ArgumentError (" the `lazy` keyword must be `true`, `false` or `:brutal`" ))
252243
244+ path = normpath (abspath (path))
253245 files = Revise === nothing ? nothing : Dict (path => mod)
254246 substitute! (x) = substitute_retest! (x, lazy, include, files;
255247 include_functions= include_functions)
@@ -269,8 +261,6 @@ function populate_mod!(mod::Module, path; lazy, Revise, include::Maybe{Symbol}=n
269261end
270262
271263function revise_track (Revise, files)
272- # uniquemod serves in v1.5 to make hijack w/ revise still work in many cases,
273- # when there aren't nested submodules/includes
274264 for (filepath, mod) in files
275265 if isfile (filepath) # some files might not exist when they are conditionally
276266 # included
@@ -332,11 +322,7 @@ function substitute_retest!(ex, lazy, include_::Maybe{Symbol}, files=nothing;
332322 include ($ substitute!, $ newfile)
333323 $ files[newfile] = $ (root_module[])
334324 end )
335- if VERSION >= v " 1.6"
336- # v1.5 doesn't play well with @__MODULE__, the let expression
337- # simply... vanishes; so we have to use root_module instead
338- push! (ex2. args[2 ]. args, :(@assert $ (root_module[]) == @__MODULE__ ))
339- end
325+ push! (ex2. args[2 ]. args, :(@assert $ (root_module[]) == @__MODULE__ ))
340326 # TODO : add `copy!(::Expr, ::Expr)` to Base
341327 ex. head = ex2. head
342328 copy! (ex. args, ex2. args)
@@ -456,9 +442,6 @@ and not enclosed within `BaseTests` or `StdLibTests`.
456442The `lazy` and `revise` keywords have the same meaning as in [`ReTest.hijack`](@ref).
457443Depending on the value of `lazy`, some test files are skipped when they
458444are known to fail.
459-
460- !!! compat "Julia 1.5"
461- This function requires at least Julia 1.5.
462445"""
463446function hijack_base (tests, modname= nothing ; parentmodule:: Module = Main, lazy= false ,
464447 base= :BaseTests , stdlib= :StdLibTests , revise:: Maybe{Bool} = nothing )
@@ -511,9 +494,9 @@ function hijack_base(tests, modname=nothing; parentmodule::Module=Main, lazy=fal
511494 # e.g. `tuple`, collision betwen the tuple function and test/tuple.jl
512495 comp = Symbol (comp, :_ )
513496 end
514- if isdefined ( mod, comp) && ith != length (components) ||
497+ if invokelatest (isdefined, mod, comp) && ith != length (components) ||
515498 modname != = nothing && ith == 1 # module already freshly created
516- mod = getfield ( mod, comp)
499+ mod = invokelatest (getglobal, mod, comp)
517500 else
518501 # we always re-eval leaf-modules
519502 mod = @eval mod module $ comp end
@@ -528,7 +511,7 @@ function hijack_base(tests, modname=nothing; parentmodule::Module=Main, lazy=fal
528511end
529512
530513get_revise (revise) =
531- if revise === true || revise === nothing && VERSION >= v " 1.5 "
514+ if revise === true || revise === nothing
532515 Revise = get (Base. loaded_modules, revise_pkgid (), nothing )
533516 Revise === nothing && revise === true &&
534517 error (" Revise is not loaded" )
@@ -573,34 +556,6 @@ function test_path(test)
573556 end
574557end
575558
576- if VERSION < v " 1.8.0-DEV.34"
577- const TESTNAMES = [
578- " subarray" , " core" , " compiler" , " worlds" ,
579- " keywordargs" , " numbers" , " subtype" ,
580- " char" , " strings" , " triplequote" , " unicode" , " intrinsics" ,
581- " dict" , " hashing" , " iobuffer" , " staged" , " offsetarray" ,
582- " arrayops" , " tuple" , " reduce" , " reducedim" , " abstractarray" ,
583- " intfuncs" , " simdloop" , " vecelement" , " rational" ,
584- " bitarray" , " copy" , " math" , " fastmath" , " functional" , " iterators" ,
585- " operators" , " ordering" , " path" , " ccall" , " parse" , " loading" , " gmp" ,
586- " sorting" , " spawn" , " backtrace" , " exceptions" ,
587- " file" , " read" , " version" , " namedtuple" ,
588- " mpfr" , " broadcast" , " complex" ,
589- " floatapprox" , " stdlib" , " reflection" , " regex" , " float16" ,
590- " combinatorics" , " sysinfo" , " env" , " rounding" , " ranges" , " mod2pi" ,
591- " euler" , " show" , " client" ,
592- " errorshow" , " sets" , " goto" , " llvmcall" , " llvmcall2" , " ryu" ,
593- " some" , " meta" , " stacktraces" , " docs" ,
594- " misc" , " threads" , " stress" , " binaryplatforms" , " atexit" ,
595- " enums" , " cmdlineargs" , " int" , " interpreter" ,
596- " checked" , " bitset" , " floatfuncs" , " precompile" ,
597- " boundscheck" , " error" , " ambiguous" , " cartesian" , " osutils" ,
598- " channels" , " iostream" , " secretbuffer" , " specificity" ,
599- " reinterpretarray" , " syntax" , " corelogging" , " missing" , " asyncmap" ,
600- " smallarrayshrink" , " opaque_closure"
601- ]
602- end
603-
604559const BLACKLIST = [
605560 # failing at load time (in hijack_base)
606561 " backtrace" , " misc" , " threads" , " cmdlineargs" ," boundscheck" ,
0 commit comments