Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run JuliaInterface tests from runtests.jl via GAP integration #1015

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions pkg/JuliaExperimental/tst/testall.g
Original file line number Diff line number Diff line change
Expand Up @@ -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);

25 changes: 25 additions & 0 deletions pkg/JuliaExperimental/tst/testsetup.g
Original file line number Diff line number Diff line change
@@ -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;
38 changes: 1 addition & 37 deletions pkg/JuliaInterface/tst/testall.g
Original file line number Diff line number Diff line change
Expand Up @@ -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) ) );
Expand Down
38 changes: 38 additions & 0 deletions pkg/JuliaInterface/tst/testsetup.g
Original file line number Diff line number Diff line change
@@ -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`-
2 changes: 1 addition & 1 deletion src/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading