Skip to content

Commit faa62ac

Browse files
Merge pull request #70 from edmondscommerce/PreCommitReAddStaged
Pre commit re add staged
2 parents 84d9e88 + a8d5bb1 commit faa62ac

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

docs/tools/phpunit.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ phpUnitCoverage=1 bin/qa
9292

9393
You might decide to do this if you are running these tests on travis, as you can see in [./travis.yml](./../../.travis.yml)
9494

95+
#### Config Changes When Generating Coverage
96+
97+
Generating coverage can cause a dramatic speed degradation. For this reason
98+
99+
* PHPUnit will fail on the first error rather than run the full suite
100+
* We will not enforce any time limits for `@small` `@medium` `@large`
101+
95102
### Speed Impact of Enabling Coverage
96103

97104
If coverage is enabled, then the tests have to be run with Xdebug enabled. This on it's own has a dramatic impact on the speed of PHP execution.

gitHooks/pre-commit.bash

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ readonly projectRoot="$DIR/../../"
1313

1414
cd $projectRoot
1515

16+
# check for stupid
1617
./bin/qa -t lint
1718

19+
# fix some ugly
1820
./bin/qa -t bf
1921

22+
# re add the staged files so that any CS fixes are applied
23+
git add $(git diff --name-only --cached)
24+
2025
echo "
2126
===========================================
2227
PHPQA Pre Commit Hook COMPLETED

includes/generic/phpunit.inc.bash

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,25 @@ phpunitLogFilePath="$varDir/phpunit_logs/phpunit.junit.xml"
2323
while (( phpunitExitCode > 0 ))
2424
do
2525
extraConfigs=(" ")
26-
if [[ "1" != "$phpUnitCoverage" ]]
27-
then
28-
extraConfigs+=( --no-coverage )
29-
fi
3026
if [[ "1" == "$phpUnitIterativeMode" ]]
3127
then
28+
# Uniterate mode - order by defects, stop on first error, no coverage and enforce time limits
3229
echo
3330
echo "Uniterate Mode - Iterative Testing with Fast Failure"
3431
echo "----------------------------------------------------"
3532
echo
3633
extraConfigs+=( --order-by=depends,defects )
3734
extraConfigs+=( --stop-on-failure --stop-on-error --stop-on-defect --stop-on-warning )
3835
extraConfigs+=( --no-coverage )
39-
else
40-
#Only enforce time limit if we are not in iterative mode, otherwise it kills Xdebug sessions
4136
extraConfigs+=( --enforce-time-limit )
37+
elif [[ "1" != "$phpUnitCoverage" ]]
38+
then
39+
# No Coverage mode - do not generate coverage, do enforce time limits
40+
extraConfigs+=( --no-coverage )
41+
extraConfigs+=( --enforce-time-limit )
42+
else
43+
# Coverage generation mode (slow) - stop on first error, do not enforce time limits
44+
extraConfigs+=( --stop-on-failure --stop-on-error --stop-on-defect --stop-on-warning )
4245
fi
4346
set +e
4447
set -x

0 commit comments

Comments
 (0)