-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Extracts the examples from the reference manual chapter by chapter into separate `.tst` files * Runs each of the created `.tst` files in a separate GAP process * Creates coverage reports, which are uploaded to codecov.io.
- Loading branch information
Showing
5 changed files
with
205 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,3 +63,6 @@ | |
|
||
/tags | ||
/src/TAGS | ||
|
||
# Tests | ||
/tst/testmanuals/*.tst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
############################################################################# | ||
## | ||
#W testmanuals.g | ||
## | ||
## <#GAPDoc Label="[1]{testmanuals.g}"> | ||
## <#/GAPDoc> | ||
## | ||
|
||
# This code extracts the examples from manuals chapter-wise and | ||
# stores them in a file that can be passed to the Test function | ||
|
||
pathtodoc := DirectoriesLibrary("doc/ref"); | ||
Read(Filename(pathtodoc, "makedocreldata.g")); | ||
GAPInfo.ManualDataRef.pathtodoc := DirectoriesLibrary("doc/ref"); | ||
GAPInfo.ManualDataRef.pathtoroot := DirectoriesLibrary(""); | ||
|
||
exsref := ExtractExamples( | ||
GAPInfo.ManualDataRef.pathtodoc, | ||
GAPInfo.ManualDataRef.main, | ||
GAPInfo.ManualDataRef.files, | ||
"Chapter" ); | ||
|
||
WriteExamplesTst := function(directory) | ||
local ch, chname, chapterfiles, i, a, output; | ||
chapterfiles := []; | ||
directory := Directory(directory); | ||
for i in [1..Length(exsref)] do | ||
ch := exsref[i]; | ||
if Length(ch) > 0 then | ||
chname := STRINGIFY("chapter", i, ".tst"); | ||
Add(chapterfiles, chname); | ||
|
||
# Note that the following truncates the testfile. | ||
output := OutputTextFile( Filename(directory, chname), false ); | ||
SetPrintFormattingStatus( output, false ); | ||
|
||
AppendTo(output, "#### Reference manual, Chapter ",i," ####\n", | ||
"gap> START_TEST(\"", chname, "\");\n"); | ||
for a in ch do | ||
AppendTo(output, "\n#LOC# ", a[2], a[1]); | ||
if a[1][Length(a[1])] <> '\n' then | ||
AppendTo(output, "\n"); | ||
fi; | ||
od; | ||
AppendTo(output, "\n\n\ngap> STOP_TEST(\"", chname, "\", 0);"); | ||
fi; | ||
od; | ||
return chapterfiles; | ||
end; | ||
|
||
testdir := Filename(DirectoriesLibrary("tst")[1], "testmanuals"); | ||
CreateDir(testdir); | ||
Print("Extracting manual examples to ", testdir, "...\n"); | ||
WriteExamplesTst( testdir ); | ||
QUIT_GAP(0); | ||
|
||
############################################################################# | ||
## | ||
#E | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
############################################################################# | ||
## | ||
#W testmanuals.g | ||
## | ||
## <#GAPDoc Label="[1]{testmanuals.g}"> | ||
## <#/GAPDoc> | ||
## | ||
|
||
# This code extracts the examples from manuals chapter-wise and | ||
# stores them in a file that can be passed to the Test function | ||
|
||
ExamplesReportDiff := function(inp, expout, found, fnam, line, time) | ||
local tstf, i, loc, res; | ||
|
||
Print("########> Diff in "); | ||
if IsStream(fnam) then | ||
Print("test stream, line ",line,"\n"); | ||
else | ||
tstf := SplitString(StringFile(fnam), "\n"); | ||
i := line; | ||
# Look for location marker | ||
while (i > 0) and | ||
((Length(tstf[i]) < 5) or (tstf[i]{[1..5]} <> "#LOC#")) do | ||
i := i - 1; | ||
od; | ||
# Found a location marker | ||
if i > 0 then | ||
loc := InputTextString(Concatenation(tstf[i]{[6..Length(tstf[i])]}, ";")); | ||
res := READ_COMMAND_REAL(loc, false); | ||
if res[1] = true then | ||
Print(res[2][1],":",res[2][2]); | ||
fi; | ||
Print(" (", fnam,":",line,")\n"); | ||
else # did not find a location marker | ||
Print(fnam,":",line,"\n"); | ||
fi; | ||
fi; | ||
Print("# Input is:\n", inp); | ||
Print("# Expected output:\n", expout); | ||
Print("# But found:\n", found); | ||
Print("########\n"); | ||
end; | ||
|
||
TestManualChapter := function(filename) | ||
local testResult; | ||
|
||
GAP_EXIT_CODE(1); | ||
testResult := Test(filename, rec( width := 72, | ||
compareFunction := "uptowhitespace", | ||
reportDiff := ExamplesReportDiff ) ); | ||
if not(testResult) then | ||
QUIT_GAP(1); | ||
fi; | ||
QUIT_GAP(0); | ||
end; | ||
|
||
############################################################################# | ||
## | ||
#E | ||
|