Skip to content

Commit 1e2fa2c

Browse files
Add warnings-as-errors option
1 parent 454e444 commit 1e2fa2c

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ All of the following inputs are optional.
2020
- `GAP_TESTFILE`:
2121
- The name of the GAP file to be read for executing the package tests.
2222
- default: `'tst/testall.g'`
23+
- `warnings-as-errors`:
24+
- Set to `true` to treat warnings produced when loading the package as errors.
25+
- default: `false`
2326

2427
### Example
2528

@@ -46,10 +49,12 @@ jobs:
4649
```
4750
4851
## Contact
52+
4953
Please submit bug reports, suggestions for improvements and patches via
5054
the [issue tracker](https://github.com/gap-actions/run-pkg-tests/issues).
5155
5256
## License
57+
5358
The action `run-pkg-tests` is free software; you can redistribute
5459
and/or modify it under the terms of the GNU General Public License as published
5560
by the Free Software Foundation; either version 2 of the License, or (at your

action.yml

+22-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ inputs:
1818
default: false
1919
load-all:
2020
description: 'If set to true then execute LoadAllPackages() before the package being tested'
21+
warnings-as-errors:
22+
description: 'If set to true then any errors produced whilst loading the package will be treated as errors'
2123
required: false
2224
type: boolean
2325
default: false
@@ -64,9 +66,17 @@ runs:
6466
if IsEmpty(GAP_TESTFILE) or not IsExistingFile(GAP_TESTFILE) then
6567
GAP_TESTFILE := info.TestFile;
6668
fi;
67-
# Load the package with debug info
69+
6870
SetInfoLevel(InfoPackageLoading, PACKAGE_DEBUG);
6971
SetPackagePath(info.PackageName, "/tmp/gaproot/pkg/$(basename $PWD)");
72+
73+
# Capture the output of loading
74+
output := "";
75+
output_stream := OutputTextString(output, true);
76+
SetPrintFormattingStatus(output_stream, false);
77+
OutputLogTo(output_stream);
78+
79+
# Load the package with debug info
7080
if ${{ inputs.only-needed }} = true then
7181
LoadPackage(info.PackageName : OnlyNeeded);
7282
else
@@ -75,6 +85,17 @@ runs:
7585
if ${{ inputs.load-all }} = true then
7686
LoadAllPackages();
7787
fi;
88+
89+
OutputLogTo();
90+
CloseStream(output_stream);
91+
92+
# Treat warnings as errors if specified
93+
if ${{ inputs.warnings-as-errors }} = 'true' ; then
94+
if PositionSublist(output, "warning") <> fail then
95+
Error("Warnings were found when loading the package");
96+
fi;
97+
fi;
98+
7899
SetInfoLevel(InfoPackageLoading, PACKAGE_ERROR);
79100
Print("Now running tests from ", GAP_TESTFILE, "\n");
80101
if EndsWith(GAP_TESTFILE, ".tst") then

0 commit comments

Comments
 (0)