Skip to content

Commit 5152bc4

Browse files
committed
Run tests a second time without precompiled code
1 parent 43fb4ce commit 5152bc4

File tree

6 files changed

+76
-25
lines changed

6 files changed

+76
-25
lines changed

examples/PrecompileCategoryOfSkeletalFinSets.g

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ cat := CategoryOfSkeletalFinSets( );
4040
# Now we check whether the compiled code is loaded automatically.
4141
# For this we use the name of the argument of `InitialObject`;
4242
# for non-compiled code it is "cat", while for compiled code it is "cat_1":
43-
NamesLocalVariablesFunction(
44-
Last( cat!.added_functions.InitialObject )[1] )[1];
45-
#! "cat_1"
43+
argument_name := NamesLocalVariablesFunction(
44+
Last( cat!.added_functions.InitialObject )[1] )[1];;
45+
46+
(ValueOption( "no_precompiled_code" ) = true and argument_name = "cat") or
47+
(ValueOption( "no_precompiled_code" ) = fail and argument_name = "cat_1");
48+
#! true
4649

4750
#! @EndExample

gap/SkeletalFinSetsForCAP.gi

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,6 @@ AddCoastrictionToImageWithGivenImageObject( SkeletalFinSets,
485485
#% CAP_JIT_DROP_NEXT_STATEMENT
486486
Assert( 3, IsEpimorphism( cat, pi ) );
487487

488-
#% CAP_JIT_DROP_NEXT_STATEMENT
489-
SetIsEpimorphism( pi, true );
490-
491488
return pi;
492489

493490
end );
@@ -673,14 +670,26 @@ AddIsInjective( SkeletalFinSets,
673670
end );
674671

675672
##
676-
AddMonomorphismIntoSomeInjectiveObject( SkeletalFinSets,
673+
AddSomeInjectiveObject( SkeletalFinSets,
677674
function ( cat, M )
678675

679676
if IsInitial( cat, M ) then
680-
return UniversalMorphismIntoTerminalObject( cat, M );
677+
678+
return TerminalObject( cat );
679+
680+
else
681+
682+
return M;
683+
681684
fi;
682685

683-
return IdentityMorphism( cat, M );
686+
end );
687+
688+
##
689+
AddMonomorphismIntoSomeInjectiveObjectWithGivenSomeInjectiveObject( SkeletalFinSets,
690+
function ( cat, M, injective_object )
691+
692+
return MapOfFinSets( M, List( M, x -> x ), injective_object );
684693

685694
end );
686695

gap/precompiled_categories/CategoryOfSkeletalFinSetsPrecompiled.gi

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -563,22 +563,13 @@ end
563563
, 100 );
564564

565565
##
566-
AddMonomorphismIntoSomeInjectiveObject( cat,
566+
AddMonomorphismIntoSomeInjectiveObjectWithGivenSomeInjectiveObject( cat,
567567

568568
########
569-
function ( cat_1, A_1 )
570-
local hoisted_1_1, deduped_2_1, deduped_3_1;
571-
deduped_2_1 := Length( A_1 );
572-
if deduped_2_1 = 0 then
573-
deduped_3_1 := FinSet( cat_1, 1 );
574-
hoisted_1_1 := Length( deduped_3_1 );
575-
return MapOfFinSets( A_1, List( AsList( A_1 ), function ( a_2 )
576-
return hoisted_1_1;
577-
end ), deduped_3_1 );
578-
else
579-
return MapOfFinSets( A_1, [ 1 .. deduped_2_1 ], A_1 );
580-
fi;
581-
return;
569+
function ( cat_1, A_1, I_1 )
570+
return MapOfFinSets( A_1, List( A_1, function ( x_2 )
571+
return x_2;
572+
end ), I_1 );
582573
end
583574
########
584575

@@ -663,6 +654,22 @@ end
663654

664655
, 100 );
665656

657+
##
658+
AddSomeInjectiveObject( cat,
659+
660+
########
661+
function ( cat_1, arg2_1 )
662+
if Length( arg2_1 ) = 0 then
663+
return FinSet( cat_1, 1 );
664+
else
665+
return arg2_1;
666+
fi;
667+
return;
668+
end
669+
########
670+
671+
, 100 );
672+
666673
##
667674
AddSubobjectClassifier( cat,
668675

makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ test-with-coverage: doc
3131
gap --quitonbreak --cover stats tst/testall.g
3232
echo 'LoadPackage("profiling"); OutputJsonCoverage("stats", "coverage.json");' | gap --quitonbreak
3333

34+
test-with-coverage-without-precompiled-code: doc
35+
gap --quitonbreak --cover stats_no_precompiled_code tst/testall_no_precompiled_code.g
36+
echo 'LoadPackage("profiling"); OutputJsonCoverage("stats_no_precompiled_code", "coverage_no_precompiled_code.json");' | gap --quitonbreak
37+
3438
test-spacing:
3539
grep -R "[^ [\"] " gap/*.gi && echo "Duplicate spaces found" && exit 1 || exit 0
3640
grep -RE '[^ ] +$$' gap/* && echo "Trailing whitespace found" && exit 1 || exit 0
@@ -54,4 +58,4 @@ test-spacing:
5458
rm spacing_diff
5559
rm spacing_diff_no_blanks
5660

57-
ci-test: test-basic-spacing test-spacing test-doc test-with-coverage
61+
ci-test: test-basic-spacing test-spacing test-doc test-with-coverage test-with-coverage-without-precompiled-code

process_coverage_ignored_lines.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
regex_block_start = re.compile("^\s*# COVERAGE_IGNORE_BLOCK_START$")
1616
regex_block_end = re.compile("^\s*# COVERAGE_IGNORE_BLOCK_END$")
1717
regex_next_line = re.compile("^\s*# COVERAGE_IGNORE_NEXT_LINE$")
18+
regex_return_void = re.compile("^\s*return;$")
1819

19-
for coverage_filename in Path(".").glob("**/coverage.json"):
20+
for coverage_filename in Path(".").glob("**/coverage*.json"):
2021
print("processing coverage file " + str(coverage_filename))
2122
with open(coverage_filename) as json_file:
2223
data = json.load(json_file)
@@ -53,6 +54,14 @@
5354
exit(1)
5455
ignored_lines.append(line_number + 1)
5556

57+
# ignore empty return statements in precompiled code
58+
# those are inserted automatically by GAP and are never executed
59+
if "precompiled_categories" in filename and regex_return_void.match(line) is not None:
60+
if ignoring:
61+
print("Error in line " + str(line_number) + ": ignoring empty return statement while already ignoring block")
62+
exit(1)
63+
ignored_lines.append(line_number)
64+
5665
if ignoring:
5766
ignored_lines.append(line_number)
5867

tst/testall_no_precompiled_code.g

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-License-Identifier: GPL-2.0-or-later
2+
# FinSetsForCAP: The elementary topos of (skeletal) finite sets
3+
#
4+
# This file runs package tests without precompiled code.
5+
#
6+
options := rec(
7+
exitGAP := true,
8+
testOptions := rec(
9+
compareFunction := "uptowhitespace",
10+
),
11+
);
12+
13+
PushOptions( rec(
14+
no_precompiled_code := true,
15+
) );
16+
17+
TestDirectory( DirectoriesPackageLibrary( "FinSetsForCAP", "tst" ), options );
18+
19+
FORCE_QUIT_GAP( 1 ); # if we ever get here, there was an error

0 commit comments

Comments
 (0)