diff --git a/pkg/JuliaExperimental/tst/testall.g b/pkg/JuliaExperimental/tst/testall.g index 7e0661600..39f02ace6 100644 --- a/pkg/JuliaExperimental/tst/testall.g +++ b/pkg/JuliaExperimental/tst/testall.g @@ -4,34 +4,10 @@ # This file runs package tests. # It is referenced in the package metadata in PackageInfo.g. # -LoadPackage( "JuliaExperimental" ); -pairs:= [ - [ "context.tst", [ "Nemo" ] ], - [ "gapnemo.tst", [ "Nemo" ] ], - [ "gapperm.tst", [] ], - [ "hnf.tst", [ "Nemo" ] ], - [ "numfield.tst", [ "Nemo" ] ], - [ "realcyc.tst", [ "Nemo" ] ], - [ "singular.tst", [ "Singular" ] ], - [ "utils.tst", [] ], - [ "zmodnz.tst", [ "Nemo" ] ], -]; - -dirs:= DirectoriesPackageLibrary( "JuliaExperimental", "tst" ); -Assert(0, dirs <> fail); - -# Run only those tests that are supported by the current Julia installation. -pairs:= Filtered( pairs, x -> ForAll( x[2], JuliaImportPackage ) ); -files:= List( pairs, x -> Filename( dirs, x[1] ) ); -if fail in files then - Print( "#E unavailable test files:\n", - List( pairs{ Positions( files, fail ) }, x -> x[1] ), "\n" ); - files:= Filtered( files, IsString ); -fi; +ReadPackage("JuliaExperimental", "tst/testsetup.g"); TestDirectory( files, rec(exitGAP := true, testOptions := rec(compareFunction := "uptowhitespace") ) ); FORCE_QUIT_GAP(1); - diff --git a/pkg/JuliaExperimental/tst/testsetup.g b/pkg/JuliaExperimental/tst/testsetup.g new file mode 100644 index 000000000..ef6b94da5 --- /dev/null +++ b/pkg/JuliaExperimental/tst/testsetup.g @@ -0,0 +1,25 @@ +LoadPackage( "JuliaExperimental" ); + +pairs:= [ + [ "context.tst", [ "Nemo" ] ], + [ "gapnemo.tst", [ "Nemo" ] ], + [ "gapperm.tst", [] ], + [ "hnf.tst", [ "Nemo" ] ], + [ "numfield.tst", [ "Nemo" ] ], + [ "realcyc.tst", [ "Nemo" ] ], + [ "singular.tst", [ "Singular" ] ], + [ "utils.tst", [] ], + [ "zmodnz.tst", [ "Nemo" ] ], +]; + +dirs:= DirectoriesPackageLibrary( "JuliaExperimental", "tst" ); +Assert(0, dirs <> fail); + +# Run only those tests that are supported by the current Julia installation. +pairs:= Filtered( pairs, x -> ForAll( x[2], JuliaImportPackage ) ); +files:= List( pairs, x -> Filename( dirs, x[1] ) ); +if fail in files then + Print( "#E unavailable test files:\n", + List( pairs{ Positions( files, fail ) }, x -> x[1] ), "\n" ); + files:= Filtered( files, IsString ); +fi; diff --git a/pkg/JuliaInterface/tst/testall.g b/pkg/JuliaInterface/tst/testall.g index 5c033b5d2..b9a9fc5d4 100644 --- a/pkg/JuliaInterface/tst/testall.g +++ b/pkg/JuliaInterface/tst/testall.g @@ -4,44 +4,8 @@ # This file runs package tests. It is also referenced in the package # metadata in PackageInfo.g. # -LoadPackage("JuliaInterface"); -dir:=DirectoriesPackageLibrary("JuliaInterface", "tst"); -Assert(0, dir <> fail); -CompareUpToWhitespaceAndMatches:= function( pairs ) - return function( a, b ) - local pair; - - a:= ShallowCopy( a ); - b:= ShallowCopy( b ); - for pair in pairs do - if ForAll( [ a, b ], - str -> ForAny( pair, - x -> PositionSublist( str, x ) <> fail ) ) then - if pair[1] <> "" then - a:= ReplacedString( a, pair[1], "" ); - b:= ReplacedString( b, pair[1], "" ); - fi; - if pair[2] <> "" then - a:= ReplacedString( a, pair[2], "" ); - b:= ReplacedString( b, pair[2], "" ); - fi; - fi; - od; - - return TEST.compareFunctions.uptowhitespace( a, b ); - end; -end; - -# Several Julia types are shown differently in Julia 1.6.0-DEV -# and older Julia versions. -compare:= CompareUpToWhitespaceAndMatches( - [ [ "Vector{Any}", "Vector{Any}" ], - [ "Maybe you forgot to use an operator such as *, ^, %, / etc. ?", "" ] ] ); - -# The testfiles assume that no traceback is printed. -AlwaysPrintTracebackOnError:= false; -#TODO: This can be removed as soon as GAP's `Test` sets the value to `false`- +ReadPackage("JuliaInterface", "tst/testsetup.g"); TestDirectory(dir, rec(exitGAP := true, testOptions := rec(compareFunction := compare) ) ); diff --git a/pkg/JuliaInterface/tst/testsetup.g b/pkg/JuliaInterface/tst/testsetup.g new file mode 100644 index 000000000..61c0b7c79 --- /dev/null +++ b/pkg/JuliaInterface/tst/testsetup.g @@ -0,0 +1,38 @@ +LoadPackage("JuliaInterface"); +dir:=DirectoriesPackageLibrary("JuliaInterface", "tst"); +Assert(0, dir <> fail); + +CompareUpToWhitespaceAndMatches:= function( pairs ) + return function( a, b ) + local pair; + + a:= ShallowCopy( a ); + b:= ShallowCopy( b ); + for pair in pairs do + if ForAll( [ a, b ], + str -> ForAny( pair, + x -> PositionSublist( str, x ) <> fail ) ) then + if pair[1] <> "" then + a:= ReplacedString( a, pair[1], "" ); + b:= ReplacedString( b, pair[1], "" ); + fi; + if pair[2] <> "" then + a:= ReplacedString( a, pair[2], "" ); + b:= ReplacedString( b, pair[2], "" ); + fi; + fi; + od; + + return TEST.compareFunctions.uptowhitespace( a, b ); + end; +end; + +# Several Julia types are shown differently in Julia 1.6.0-DEV +# and older Julia versions. +compare:= CompareUpToWhitespaceAndMatches( + [ [ "Vector{Any}", "Vector{Any}" ], + [ "Maybe you forgot to use an operator such as *, ^, %, / etc. ?", "" ] ] ); + +# The testfiles assume that no traceback is printed. +AlwaysPrintTracebackOnError:= false; +#TODO: This can be removed as soon as GAP's `Test` sets the value to `false`- diff --git a/src/setup.jl b/src/setup.jl index b3ab1446e..1b52a5ce7 100644 --- a/src/setup.jl +++ b/src/setup.jl @@ -269,7 +269,7 @@ function create_gap_sh(dstdir::String) ## Create Project.toml & Manifest.toml for use by gap.sh ## @info "Generating custom Julia project ..." - run(pipeline(`$(Base.julia_cmd()) --startup-file=no --project=$(dstdir) -e "using Pkg; Pkg.develop(PackageSpec(path=\"$(gaproot_gapjl)\"))"`)) + run(`$(Base.julia_cmd()) --startup-file=no --project=$(dstdir) -e "using Pkg; Pkg.develop(PackageSpec(path=\"$(gaproot_gapjl)\"))"`) ## ## Create custom gap.sh diff --git a/test/runtests.jl b/test/runtests.jl index becb54d79..e46c053fc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -24,3 +24,13 @@ end @testset "manual examples" begin include("doctest.jl") end + +@testset "JuliaInterface tests" begin + GAP.Wrappers.Read(joinpath(dirname(dirname(pathof(GAP))), "pkg/JuliaInterface/tst/testsetup.g")) + @test GAP.Globals.TestDirectory(GAP.Globals.dir, GapObj(Dict(:exitGAP => false, :testOptions => Dict(:compareFunction => GAP.Globals.compare)); recursive=true)) +end + +@testset "JuliaExperimental tests" begin + GAP.Wrappers.Read(joinpath(dirname(dirname(pathof(GAP))), "pkg/JuliaExperimental/tst/testsetup.g")) + @test GAP.Globals.TestDirectory(GAP.Globals.files, GapObj(Dict(:exitGAP => false, :testOptions => Dict(:compareFunction => "uptowhitespace")); recursive=true)) +end