Skip to content

Commit 3021f50

Browse files
committed
Parse dataset information from phpunit logs
1 parent 8fddf37 commit 3021f50

6 files changed

Lines changed: 59 additions & 4 deletions

File tree

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
run: |
3838
python ${LOG_TO_CS} ${RAW_LOG} ${CS_XML}
3939
- name: Convert Raw Log to Checkstyle format (launch action)
40-
uses: mdeweerd/logToCheckStyle@v2024.3.5
40+
uses: mdeweerd/logToCheckStyle@v2025.1.1
4141
if: ${{ failure() }}
4242
with:
4343
in: ${{ env.RAW_LOG }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ optional arguments:
5050
5151
```yaml
5252
- name: Convert Raw Log to Checkstyle format (launch action)
53-
uses: mdeweerd/logToCheckStyle@v2024.3.5
53+
uses: mdeweerd/logToCheckStyle@v2025.1.1
5454
if: ${{ failure() }}
5555
with:
5656
in: ${{ env.RAW_LOG }}

logToCs.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ def submit( # pylint: disable=too-many-arguments
333333
rf"\s*(?P<classname>{IDENTIFIER_REGEX})"
334334
rf"::(?P<method>{IDENTIFIER_REGEX})\b\s*?"
335335
)
336-
336+
PHPUNIT_DATASET_REGEX = (
337+
r"(?P<dataset> with data set (?:#\d+|\"[^\"]+\") \([^\n]*\))"
338+
)
337339

338340
# List of message patterns, add more specific patterns earlier in the list
339341
# Creating patterns by using constants makes them easier to define and read.
@@ -351,7 +353,7 @@ def submit( # pylint: disable=too-many-arguments
351353
),
352354
re.compile(rf"^There were \d+ {SEVERITYGROUP_REGEX}s?:$"),
353355
re.compile(
354-
rf"^\d+\){CLASS_METHOD_REGEX}\n"
356+
rf"^\d+\){CLASS_METHOD_REGEX}{PHPUNIT_DATASET_REGEX}?\n"
355357
rf"{MULTILINE_MSG_REGEX}${FILE_REGEX}:{LINE_REGEX}$"
356358
),
357359
# beautysh
@@ -501,6 +503,13 @@ def parse_file(text):
501503
new_severity_group = result.pop("severity_group", None)
502504
severity_endgroup = result.pop("severity_endgroup", None)
503505
message = result.get("message", None)
506+
dataset = result.get("dataset", None)
507+
508+
if dataset is not None:
509+
if message is None:
510+
message = ""
511+
message += dataset
512+
result["message"] = message
504513

505514
has_group_instructions = False
506515

tests/IN/phpunit_dataset.log

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Time: 01:58.025, Memory: 152.00 MB
2+
3+
There were 6 failures:
4+
5+
1) LangTest::testLang with data set "ca_ES" ('ca_ES')
6+
Failed asserting that false is true.
7+
8+
D:\a\dolibarr\dolibarr\test\phpunit\LangTest.php:263
9+
10+
2) LangTest::testLang with data set "da_DK" ('da_DK')
11+
Failed asserting that false is true.
12+
13+
D:\a\dolibarr\dolibarr\test\phpunit\LangTest.php:263
14+
15+
3) LangTest::testLang with data set "el_GR" ('el_GR')
16+
Failed asserting that false is true.
17+
18+
D:\a\dolibarr\dolibarr\test\phpunit\LangTest.php:263
19+
20+
4) LangTest::testLang with data set "fr_CA" ('fr_CA')
21+
Failed asserting that false is true.
22+
23+
D:\a\dolibarr\dolibarr\test\phpunit\LangTest.php:263
24+
25+
5) LangTest::testLang with data set "lv_LV" ('lv_LV')
26+
Failed asserting that false is true.
27+
28+
D:\a\dolibarr\dolibarr\test\phpunit\LangTest.php:263
29+
30+
6) CodingPhpTest::testPHP with data set #1375 (array('donstats.class.php', 'D:\a\dolibarr\dolibarr\htdocs.../class', 'class', 'don/class/donstats.class.php', 'D:\a\dolibarr\dolibarr\htdocs...ss.php', '', '', 'file'))
31+
Found non sanitized string in building of a IN or NOT IN sql request don/class/donstats.class.php - Bad.
32+
Failed asserting that false is true.
33+
34+
D:\a\dolibarr\dolibarr\test\phpunit\CodingPhpTest.php:513
35+
36+
FAILURES!
37+
Tests: 2935, Assertions: 112671, Failures: 6.
38+
""

tests/IN/phpunit_dataset.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
::error file=D%3A/a/dolibarr/dolibarr/test/phpunit/LangTest.php,line=263::Failed asserting that false is true. with data set "ca_ES" ('ca_ES')
2+
::error file=D%3A/a/dolibarr/dolibarr/test/phpunit/LangTest.php,line=263::Failed asserting that false is true. with data set "da_DK" ('da_DK')
3+
::error file=D%3A/a/dolibarr/dolibarr/test/phpunit/LangTest.php,line=263::Failed asserting that false is true. with data set "el_GR" ('el_GR')
4+
::error file=D%3A/a/dolibarr/dolibarr/test/phpunit/LangTest.php,line=263::Failed asserting that false is true. with data set "fr_CA" ('fr_CA')
5+
::error file=D%3A/a/dolibarr/dolibarr/test/phpunit/LangTest.php,line=263::Failed asserting that false is true. with data set "lv_LV" ('lv_LV')
6+
::error file=D%3A/a/dolibarr/dolibarr/test/phpunit/CodingPhpTest.php,line=513::Found non sanitized string in building of a IN or NOT IN sql request don/class/donstats.class.php - Bad.%0AFailed asserting that false is true. with data set #1375 (array('donstats.class.php', 'D:\a\dolibarr\dolibarr\htdocs.../class', 'class', 'don/class/donstats.class.php', 'D:\a\dolibarr\dolibarr\htdocs...ss.php', '', '', 'file'))

tests/IN/phpunit_dataset.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='utf_8'?>
2+
<checkstyle version="6.5"><file name="D:\a\dolibarr\dolibarr\test\phpunit\LangTest.php"><error severity="error" line="263" message="Failed asserting that false is true. with data set &quot;ca_ES&quot; ('ca_ES')" /><error severity="error" line="263" message="Failed asserting that false is true. with data set &quot;da_DK&quot; ('da_DK')" /><error severity="error" line="263" message="Failed asserting that false is true. with data set &quot;el_GR&quot; ('el_GR')" /><error severity="error" line="263" message="Failed asserting that false is true. with data set &quot;fr_CA&quot; ('fr_CA')" /><error severity="error" line="263" message="Failed asserting that false is true. with data set &quot;lv_LV&quot; ('lv_LV')" /></file><file name="D:\a\dolibarr\dolibarr\test\phpunit\CodingPhpTest.php"><error severity="error" line="513" message="Found non sanitized string in building of a IN or NOT IN sql request don/class/donstats.class.php - Bad.&#10;Failed asserting that false is true. with data set #1375 (array('donstats.class.php', 'D:\a\dolibarr\dolibarr\htdocs.../class', 'class', 'don/class/donstats.class.php', 'D:\a\dolibarr\dolibarr\htdocs...ss.php', '', '', 'file'))" /></file></checkstyle>

0 commit comments

Comments
 (0)