Skip to content

Commit e2df8e5

Browse files
committed
ci: do not throw away exit codes
1 parent 7859d9a commit e2df8e5

11 files changed

+64
-29
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/.gitattributes export-ignore
44
/.github export-ignore
55
/.gitignore export-ignore
6+
/bin/ export-ignore
67
/docs/ export-ignore
78
/phpcs.xml.dist export-ignore
89
/tests/ export-ignore

Makefile

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
.PHONY: test test-report test-fix update-compatibility-patch
22

3-
PHP_VERSION:=$(shell php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;")
4-
PATCH_FILE="tests/php$(PHP_VERSION)-compatibility.patch"
5-
63
test: test-report test-fix
74

85
test-report: vendor
9-
@if [ -f "$(PATCH_FILE)" ]; then git apply $(PATCH_FILE) ; fi
10-
@vendor/bin/phpcs `find tests/input/* | sort` --report=summary --report-file=phpcs.log; diff -u tests/expected_report.txt phpcs.log; if [ $$? -ne 0 ] && [ -f "$(PATCH_FILE)" ]; then git apply -R $(PATCH_FILE) ; exit 1; fi
11-
@if [ -f "$(PATCH_FILE)" ]; then git apply -R $(PATCH_FILE) ; fi
6+
./bin/test-report
127

138
test-fix: vendor
14-
@if [ -f "$(PATCH_FILE)" ]; then git apply $(PATCH_FILE) ; fi
15-
@cp -R tests/input/ tests/input2/
16-
@vendor/bin/phpcbf tests/input2; diff -u tests/input2 tests/fixed; if [ $$? -ne 0 ]; then rm -rf tests/input2/; if [ -f "$(PATCH_FILE)" ]; then git apply -R $(PATCH_FILE) ; fi; exit 1; fi
17-
@rm -rf tests/input2/;
18-
@if [ -f "$(PATCH_FILE)" ]; then git apply -R $(PATCH_FILE) ; fi
9+
./bin/test-fix
1910

2011
update-compatibility-patch-74:
2112
@git apply tests/php74-compatibility.patch

bin/cleanup

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
. bin/patch-file
4+
5+
rm -f phpcs.log
6+
rm -rf tests/input2/
7+
if [ -f "$PATCH_FILE" ]; then git apply -R "$PATCH_FILE" ; fi

bin/init

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
. bin/patch-file
4+
5+
if [ -f "$PATCH_FILE" ]; then git apply "$PATCH_FILE" ; fi

bin/patch-file

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
PHP_VERSION="$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;")"
4+
PATCH_FILE="tests/php$PHP_VERSION-compatibility.patch"
5+
6+
export PATCH_FILE;

bin/test-fix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
bin/init
6+
trap 'bin/cleanup' EXIT
7+
8+
set +e
9+
10+
cp -R tests/input/ tests/input2/
11+
vendor/bin/phpcbf tests/input2
12+
diff -u tests/input2 tests/fixed

bin/test-report

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
bin/init
6+
trap 'bin/cleanup' EXIT
7+
8+
set +e
9+
10+
# shellcheck disable=SC2046
11+
vendor/bin/phpcs $(find tests/input/* | sort) --report=summary --report-file=phpcs.log
12+
diff -u tests/expected_report.txt phpcs.log

tests/expected_report.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,20 @@ tests/input/semicolon_spacing.php 3 0
3535
tests/input/single-line-array-spacing.php 5 0
3636
tests/input/spread-operator.php 6 0
3737
tests/input/static-closures.php 1 0
38+
tests/input/strings.php 1 0
3839
tests/input/superfluous-naming.php 11 0
3940
tests/input/test-case.php 8 0
4041
tests/input/trailing_comma_on_array.php 1 0
4142
tests/input/traits-uses.php 11 0
42-
tests/input/type-hints.php 4 0
43+
tests/input/type-hints.php 7 0
4344
tests/input/UnusedVariables.php 1 0
4445
tests/input/use-ordering.php 1 0
4546
tests/input/useless-semicolon.php 2 0
4647
tests/input/UselessConditions.php 20 0
4748
----------------------------------------------------------------------
48-
A TOTAL OF 377 ERRORS AND 0 WARNINGS WERE FOUND IN 41 FILES
49+
A TOTAL OF 381 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
4950
----------------------------------------------------------------------
50-
PHPCBF CAN FIX 313 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
51+
PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5152
----------------------------------------------------------------------
5253

5354

tests/php74-compatibility.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,26 @@ index c644926..7d122d2 100644
2323
tests/input/null_coalesce_operator.php 3 0
2424
tests/input/optimized-functions.php 1 0
2525
tests/input/PropertyDeclaration.php 6 0
26-
@@ -35,19 +35,20 @@ tests/input/semicolon_spacing.php 3 0
26+
@@ -35,20 +35,20 @@ tests/input/semicolon_spacing.php 3 0
2727
tests/input/single-line-array-spacing.php 5 0
2828
tests/input/spread-operator.php 6 0
2929
tests/input/static-closures.php 1 0
30-
+tests/input/strings.php 1 0
30+
tests/input/strings.php 1 0
3131
tests/input/superfluous-naming.php 11 0
3232
tests/input/test-case.php 8 0
3333
tests/input/trailing_comma_on_array.php 1 0
3434
tests/input/traits-uses.php 11 0
35-
-tests/input/type-hints.php 4 0
35+
-tests/input/type-hints.php 7 0
3636
+tests/input/type-hints.php 8 0
3737
tests/input/UnusedVariables.php 1 0
3838
tests/input/use-ordering.php 1 0
3939
tests/input/useless-semicolon.php 2 0
4040
tests/input/UselessConditions.php 20 0
4141
----------------------------------------------------------------------
42-
-A TOTAL OF 377 ERRORS AND 0 WARNINGS WERE FOUND IN 41 FILES
42+
-A TOTAL OF 381 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
4343
+A TOTAL OF 390 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
4444
----------------------------------------------------------------------
45-
-PHPCBF CAN FIX 313 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
45+
-PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
4646
+PHPCBF CAN FIX 324 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
4747
----------------------------------------------------------------------
4848

tests/php80-compatibility.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ diff --git a/tests/expected_report.txt b/tests/expected_report.txt
22
index 476a58b..54630dd 100644
33
--- a/tests/expected_report.txt
44
+++ b/tests/expected_report.txt
5-
@@ -14,40 +14,43 @@ tests/input/constants-var.php 6 0
5+
@@ -14,41 +14,43 @@ tests/input/constants-var.php 6 0
66
tests/input/ControlStructures.php 28 0
77
tests/input/doc-comment-spacing.php 11 0
88
tests/input/duplicate-assignment-variable.php 1 0
@@ -36,24 +36,24 @@ index 476a58b..54630dd 100644
3636
tests/input/single-line-array-spacing.php 5 0
3737
tests/input/spread-operator.php 6 0
3838
tests/input/static-closures.php 1 0
39-
+tests/input/strings.php 1 0
39+
tests/input/strings.php 1 0
4040
tests/input/superfluous-naming.php 11 0
4141
tests/input/test-case.php 8 0
4242
tests/input/trailing_comma_on_array.php 1 0
4343
+tests/input/TrailingCommaOnFunctions.php 2 0
4444
tests/input/traits-uses.php 11 0
45-
-tests/input/type-hints.php 4 0
45+
-tests/input/type-hints.php 7 0
4646
+tests/input/type-hints.php 9 0
4747
tests/input/UnusedVariables.php 1 0
4848
tests/input/use-ordering.php 1 0
4949
tests/input/useless-semicolon.php 2 0
5050
-tests/input/UselessConditions.php 20 0
5151
+tests/input/UselessConditions.php 21 0
5252
----------------------------------------------------------------------
53-
-A TOTAL OF 377 ERRORS AND 0 WARNINGS WERE FOUND IN 41 FILES
53+
-A TOTAL OF 381 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
5454
+A TOTAL OF 412 ERRORS AND 0 WARNINGS WERE FOUND IN 44 FILES
5555
----------------------------------------------------------------------
56-
-PHPCBF CAN FIX 313 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
56+
-PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5757
+PHPCBF CAN FIX 346 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5858
----------------------------------------------------------------------
5959

0 commit comments

Comments
 (0)