Skip to content

Commit a2b3f82

Browse files
Add warnings-as-errors option
1 parent 84bfaaa commit a2b3f82

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

Diff for: 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

Diff for: action.yml

+25-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ inputs:
1616
required: false
1717
type: boolean
1818
default: false
19+
warnings-as-errors:
20+
description: 'If set to true then any errors produced whilst loading the package will be treated as errors'
21+
required: false
22+
type: boolean
23+
default: false
1924
env:
2025
CHERE_INVOKING: 1
2126

@@ -59,14 +64,33 @@ runs:
5964
if IsEmpty(GAP_TESTFILE) or not IsExistingFile(GAP_TESTFILE) then
6065
GAP_TESTFILE := info.TestFile;
6166
fi;
62-
# Load the package with debug info
67+
6368
SetInfoLevel(InfoPackageLoading, PACKAGE_DEBUG);
6469
SetPackagePath(info.PackageName, "/tmp/gaproot/pkg/$(basename $PWD)");
70+
71+
# Capture the output of loading
72+
output := "";
73+
output_stream := OutputTextString(output, true);
74+
SetPrintFormattingStatus(output_stream, false);
75+
OutputLogTo(output_stream);
76+
77+
# Load the package with debug info
6578
if ${{ inputs.only-needed }} = true then
6679
LoadPackage(info.PackageName : OnlyNeeded);
6780
else
6881
LoadPackage(info.PackageName);
6982
fi;
83+
84+
OutputLogTo();
85+
CloseStream(output_stream);
86+
87+
# Treat warnings as errors if specified
88+
if ${{ inputs.warnings-as-errors }} = 'true' ; then
89+
if PositionSublist(output, "warning") <> fail then
90+
Error("Warnings were found when loading the package");
91+
fi;
92+
fi;
93+
7094
SetInfoLevel(InfoPackageLoading, PACKAGE_ERROR);
7195
Print("Now running tests from ", GAP_TESTFILE, "\n");
7296
if EndsWith(GAP_TESTFILE, ".tst") then

0 commit comments

Comments
 (0)