Skip to content

Commit

Permalink
Add GAP.Packages.test
Browse files Browse the repository at this point in the history
Co-authored-by: Max Horn <[email protected]>
  • Loading branch information
lgoettgens and fingolfin committed Nov 21, 2024
1 parent 8df11ab commit 38ac1f9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI-distro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ jobs:
- name: "Build GAP package"
run: julia --color=yes --project=. -e 'using GAP; GAP.Packages.build("${{ matrix.gap-package }}")'
- name: "Run GAP package tests"
run: julia --color=yes --project=. -e 'using GAP; GAP.Globals.TestPackage(GAP.Obj("${{ matrix.gap-package }}"))'
run: julia --color=yes --project=. -e 'using GAP; GAP.Packages.test("${{ matrix.gap-package }}")'
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
AbstractAlgebra = "0.41.11, 0.42.1, 0.43"
Expand All @@ -40,4 +41,5 @@ Pkg = "1.6"
REPL = "1.6"
Random = "1.6"
Scratch = "1.1"
Test = "1.6"
julia = "1.6"
45 changes: 44 additions & 1 deletion src/packages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module Packages

import Downloads
import Pidfile
import ...GAP: Globals, GapObj, replace_global!, RNamObj, sysinfo, Wrappers
import Test: @test
import ...GAP: disable_error_handler, Globals, GapObj, replace_global!, RNamObj, sysinfo, Wrappers

const DEFAULT_PKGDIR = Ref{String}()
const DOWNLOAD_HELPER = Ref{Downloads.Downloader}()
Expand Down Expand Up @@ -408,6 +409,48 @@ function build(name::String; quiet::Bool = false,
return res
end

function test(name::String)
global disable_error_handler

function with_gap_var(f, n::String, val)
name = GapObj(n)
old_value = Globals.ValueGlobal(name)
Globals.MakeReadWriteGlobal(name)
Globals.UnbindGlobal(name)
Globals.BindGlobal(name, val)
try
f()
finally
Globals.MakeReadWriteGlobal(name);
Globals.UnbindGlobal(name);
Globals.BindGlobal(name, old_value);
end
end

error_occurred = false
function fake_QuitGap(code)
global error_occurred
if code != 0
error_occurred = true
end
end

disable_error_handler[] = true
try
with_gap_var("ERROR_OUTPUT", Globals._JULIAINTERFACE_ORIGINAL_ERROR_OUTPUT) do
with_gap_var("QuitGap", fake_QuitGap) do
with_gap_var("FORCE_QUIT_GAP", identity) do
Globals.TestPackage(GapObj(name))
end
end
end
finally
disable_error_handler[] = false
end

@test !error_occurred
end

"""
locate_package(name::String)
Expand Down

0 comments on commit 38ac1f9

Please sign in to comment.