From 22400dd2822d8bf3414110619b3a7f70f4c274b5 Mon Sep 17 00:00:00 2001 From: Joseph Edmonds Date: Wed, 12 Sep 2018 15:10:11 +0000 Subject: [PATCH 1/3] rolling back deps, phpunit tweak for uniterate mode --- composer.json | 9 +++++---- includes/generic/phpunit.inc.bash | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 9f04ebf..384d350 100644 --- a/composer.json +++ b/composer.json @@ -24,16 +24,16 @@ "jakub-onderka/php-parallel-lint": "~1", "phploc/phploc": "^4.0", "phpmd/phpmd": "^2.6", - "phpstan/phpstan-shim": "^0.10.3", + "phpstan/phpstan-shim": "^0.9.2", "squizlabs/php_codesniffer": "~3", "sllh/composer-versions-check": "^2.0", - "phpstan/phpstan-strict-rules": "^0.10.1", - "infection/infection": "^0.10.0", + "phpstan/phpstan-strict-rules": "^0.9.0", + "infection/infection": "^0.8", "funkyproject/reflection-file": "^0.1.0", "phpunit/php-invoker": "^2.0" }, "require-dev": { - "phpstan/phpstan-phpunit": "^0.10" + "phpstan/phpstan-phpunit": "~0" }, "suggest": { "phpstan/phpstan-phpunit": "Adds checks for PHPUnit tests" @@ -42,6 +42,7 @@ "bin/qa", "bin/mdlinks", "bin/psr4-validate", + "bin/phpunit-runfailed-filter", "bin/phpunit-check-annotation" ], "config": { diff --git a/includes/generic/phpunit.inc.bash b/includes/generic/phpunit.inc.bash index 4bc8620..e52d4bb 100644 --- a/includes/generic/phpunit.inc.bash +++ b/includes/generic/phpunit.inc.bash @@ -76,7 +76,7 @@ do if (( $phpunitExitCode > 0 )) then - if (( $phpunitExitCode > 2 )) + if (( $phpunitExitCode > 2 && $phpUnitIterativeMode == 0 )) then printf "\n\n\nPHPUnit Crashed\n\nRunning again with Debug mode...\n\n\n" qaQuickTests="$phpUnitQuickTests" phpNoXdebug -f bin/phpunit -- "$testsDir" --debug From c6d42b8b6492610bdeb434148193adac074e6b2f Mon Sep 17 00:00:00 2001 From: Ross Mitchell Date: Wed, 16 Jan 2019 18:28:03 +0000 Subject: [PATCH 2/3] Get md to fail when it has a fatal error --- includes/generic/messDetector.inc.bash | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/includes/generic/messDetector.inc.bash b/includes/generic/messDetector.inc.bash index 466d1e5..dc20d01 100644 --- a/includes/generic/messDetector.inc.bash +++ b/includes/generic/messDetector.inc.bash @@ -6,18 +6,24 @@ phpMdExitCode=99 while (( phpMdExitCode > 0 )) do set -x - phpNoXdebug -f bin/phpmd -- \ + output=$(phpNoXdebug -f bin/phpmd -- \ $pathsString \ text \ "$phpmdConfigPath" \ --suffixes php,phtml \ - --exclude $ignoreString \ - | sort -u \ - | sed G \ - | sed -e 's#p:#p\nLine: #' \ - | sed -e 's#\t\{1,\}#\nMessage: #' \ - | sed -e 's#\. #\.\n#' - phpMdExitCode=$? + --exclude $ignoreString) + if [[ "$output" == "" ]] + then + phpMdExitCode=0; + else + echo "$output" \ + | sort -u \ + | sed G \ + | sed -e 's#p:#p\nLine: #' \ + | sed -e 's#\t\{1,\}#\nMessage: #' \ + | sed -e 's#\. #\.\n#' + phpMdExitCode=1 + fi set +x if (( phpMdExitCode > 0 )) then From 7d2a14dc0fd2a41a67d5821957e9a027eab6a1cc Mon Sep 17 00:00:00 2001 From: joseph Date: Wed, 30 Jan 2019 15:55:58 +0000 Subject: [PATCH 3/3] have backported as much as poss from the 2.0 branch and also brought in the paralel lint fork --- composer.json | 13 ++++++++++--- configDefaults/generic/phpunit.xml | 2 +- includes/functions.inc.bash | 16 +++++++++------- includes/generic/beautifierFixer.inc.bash | 2 +- includes/generic/codeSniffer.inc.bash | 6 +++--- includes/generic/composerChecks.inc.bash | 3 +-- includes/generic/infection.inc.bash | 10 ++++------ includes/generic/markdownLinks.inc.bash | 4 ++-- includes/generic/messDetector.inc.bash | 6 ++---- includes/generic/phpLint.inc.bash | 4 ++-- includes/generic/phploc.inc.bash | 3 +-- includes/generic/phpstan.inc.bash | 4 ++-- includes/generic/phpunit.inc.bash | 8 ++++---- includes/generic/phpunitAnnotations.inc.bash | 4 ++-- includes/generic/psr4Validate.inc.bash | 4 ++-- includes/generic/setConfig.inc.bash | 2 ++ src/Markdown/LinksChecker.php | 4 +++- src/Psr4Validator.php | 4 ++-- 18 files changed, 53 insertions(+), 46 deletions(-) diff --git a/composer.json b/composer.json index 384d350..f2fb7dd 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "php": "~7.1", "phpunit/phpunit": "^7.3", "jakub-onderka/php-console-highlighter": "^0.3.2", - "jakub-onderka/php-parallel-lint": "~1", + "jakub-onderka/php-parallel-lint": "dev-SplitAutoload@dev", "phploc/phploc": "^4.0", "phpmd/phpmd": "^2.6", "phpstan/phpstan-shim": "^0.9.2", @@ -30,8 +30,16 @@ "phpstan/phpstan-strict-rules": "^0.9.0", "infection/infection": "^0.8", "funkyproject/reflection-file": "^0.1.0", - "phpunit/php-invoker": "^2.0" + "phpunit/php-invoker": "^2.0", + "ext-json": "*", + "phpunit/php-timer": "^2.0" }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/edmondscommerce/PHP-Parallel-Lint" + } + ], "require-dev": { "phpstan/phpstan-phpunit": "~0" }, @@ -42,7 +50,6 @@ "bin/qa", "bin/mdlinks", "bin/psr4-validate", - "bin/phpunit-runfailed-filter", "bin/phpunit-check-annotation" ], "config": { diff --git a/configDefaults/generic/phpunit.xml b/configDefaults/generic/phpunit.xml index 5c9e088..12bfaef 100644 --- a/configDefaults/generic/phpunit.xml +++ b/configDefaults/generic/phpunit.xml @@ -1,6 +1,6 @@ "$temporaryPath" - $phpBinPath -n -c "$temporaryPath" "$@" - local exitCode=$? - rm -f "$temporaryPath" + if [[ ! -f ${noXdebugConfigPath} ]] + then + # Using awk to ensure that files ending without newlines do not lead to configuration error + ${phpBinPath} -i | grep "\.ini" | grep -o -e '\(/[a-z0-9._-]\+\)\+\.ini' | grep -v xdebug | xargs awk 'FNR==1{print ""}1' > "$noXdebugConfigPath" + fi set -x + ${phpBinPath} -n -c "$noXdebugConfigPath" "$@" + local exitCode=$? + set +x + echo return $exitCode } diff --git a/includes/generic/beautifierFixer.inc.bash b/includes/generic/beautifierFixer.inc.bash index b29460c..e2e7e0a 100644 --- a/includes/generic/beautifierFixer.inc.bash +++ b/includes/generic/beautifierFixer.inc.bash @@ -1,5 +1,5 @@ set +e -set -x + phpNoXdebug -f bin/phpcbf -- \ --standard="$phpcsCodingStandardsNameOrPath" \ --colors \ diff --git a/includes/generic/codeSniffer.inc.bash b/includes/generic/codeSniffer.inc.bash index d49b68d..464fb58 100644 --- a/includes/generic/codeSniffer.inc.bash +++ b/includes/generic/codeSniffer.inc.bash @@ -3,12 +3,12 @@ ignoreString=$(IFS="," eval 'echo "${pathsToIgnore[*]}"') phpNoXdebug -f bin/phpcs -- \ --config-set ignore_warnings_on_exit "$phpcsFailOnWarning" -set +x + set +e phpcsExitCode=99 while (( phpcsExitCode > 0 )) do - set -x + phpNoXdebug -f bin/phpcs -- \ --standard="$phpcsCodingStandardsNameOrPath" \ --colors \ @@ -19,7 +19,7 @@ do --ignore=$ignoreString \ ${pathsToCheck[@]} phpcsExitCode=$? - set +x + if (( phpcsExitCode > 0 )) then tryAgainOrAbort "Code Sniffer" diff --git a/includes/generic/composerChecks.inc.bash b/includes/generic/composerChecks.inc.bash index 573a9f6..3c3c1fc 100644 --- a/includes/generic/composerChecks.inc.bash +++ b/includes/generic/composerChecks.inc.bash @@ -1,8 +1,7 @@ set +e -set -x + phpNoXdebug -f $(which composer) -- diagnose set +x set -e phpNoXdebug -f $(which composer) -- dump-autoload -set +x \ No newline at end of file diff --git a/includes/generic/infection.inc.bash b/includes/generic/infection.inc.bash index 2e49b20..659df4b 100644 --- a/includes/generic/infection.inc.bash +++ b/includes/generic/infection.inc.bash @@ -15,16 +15,14 @@ function runInfection(){ --threads=${infectionThreads} \ --configuration=${infectionConfig} \ --min-msi=${infectionMutationScoreIndicator} \ - --min-covered-msi=${infectionCoveredCodeMSI} \ - --test-framework-options="--cache-result-file=/tmp/.infection.phpunit.cache" + --min-covered-msi=${infectionCoveredCodeMSI} else ${phpBinPath} -f ./bin/infection \ "${extraArgs[@]}" \ --threads=${infectionThreads} \ --configuration=${infectionConfig} \ --min-msi=${infectionMutationScoreIndicator} \ - --min-covered-msi=${infectionCoveredCodeMSI} \ - --test-framework-options="--cache-result-file=/tmp/.infection.phpunit.cache" + --min-covered-msi=${infectionCoveredCodeMSI} fi } @@ -34,12 +32,12 @@ do backupIFS=$IFS IFS=$standardIFS set +e - set -x + rm -rf $varDir/infection/* runInfection infectionExitCode=$? set -e - set +x + IFS=$backupIFS if (( $infectionExitCode > 0 )) then diff --git a/includes/generic/markdownLinks.inc.bash b/includes/generic/markdownLinks.inc.bash index f433537..d1ed186 100644 --- a/includes/generic/markdownLinks.inc.bash +++ b/includes/generic/markdownLinks.inc.bash @@ -4,10 +4,10 @@ then while (( linksExitCode > 0 )) do set +e - set -x + phpNoXdebug -f bin/mdlinks linksExitCode=$? - set +x + set -e if (( linksExitCode > 0 )) then diff --git a/includes/generic/messDetector.inc.bash b/includes/generic/messDetector.inc.bash index dc20d01..e835a07 100644 --- a/includes/generic/messDetector.inc.bash +++ b/includes/generic/messDetector.inc.bash @@ -5,13 +5,13 @@ set +e phpMdExitCode=99 while (( phpMdExitCode > 0 )) do - set -x output=$(phpNoXdebug -f bin/phpmd -- \ $pathsString \ text \ "$phpmdConfigPath" \ --suffixes php,phtml \ - --exclude $ignoreString) + --exclude $ignoreString \ + 2> /dev/null) if [[ "$output" == "" ]] then phpMdExitCode=0; @@ -24,11 +24,9 @@ do | sed -e 's#\. #\.\n#' phpMdExitCode=1 fi - set +x if (( phpMdExitCode > 0 )) then tryAgainOrAbort "PHP Mess Detector" fi done -set +x set -e diff --git a/includes/generic/phpLint.inc.bash b/includes/generic/phpLint.inc.bash index 18a4812..b6e7105 100644 --- a/includes/generic/phpLint.inc.bash +++ b/includes/generic/phpLint.inc.bash @@ -11,12 +11,12 @@ phpLintExitCode=99 set +e while (( phpLintExitCode > 0 )) do - set -x + phpNoXdebug -f bin/parallel-lint -- \ "${pathsToIgnorePrefixed[@]}" \ "${pathsToCheck[@]}" phpLintExitCode=$? - set +x + if (( phpLintExitCode > 0 )) then tryAgainOrAbort "PHP Lint" diff --git a/includes/generic/phploc.inc.bash b/includes/generic/phploc.inc.bash index 3ef9cd6..89dd98e 100644 --- a/includes/generic/phploc.inc.bash +++ b/includes/generic/phploc.inc.bash @@ -1,3 +1,2 @@ -set -x + phpNoXdebug -f bin/phploc ${pathsToCheck[@]} -set +x \ No newline at end of file diff --git a/includes/generic/phpstan.inc.bash b/includes/generic/phpstan.inc.bash index 1492b6c..5952745 100644 --- a/includes/generic/phpstan.inc.bash +++ b/includes/generic/phpstan.inc.bash @@ -8,10 +8,10 @@ then fi while (( phpStanExitCode > 0 )) do - set -x + phpNoXdebug -d memory_limit=${phpStanMemoryLimit} -f bin/phpstan.phar -- analyse ${pathsToCheck[@]} -l7 -c "$phpstanConfigPath" ${phpstanNoProgress[@]:-} phpStanExitCode=$? - set +x + #exit code 0 = fine, 1 = ran fine but found errors, else it means it crashed if (( phpStanExitCode > 1 )) then diff --git a/includes/generic/phpunit.inc.bash b/includes/generic/phpunit.inc.bash index e52d4bb..8989d41 100644 --- a/includes/generic/phpunit.inc.bash +++ b/includes/generic/phpunit.inc.bash @@ -48,7 +48,7 @@ do extraConfigs+=( --enforce-time-limit ) fi set +e - set -x + phpUnitQuickTests="$phpUnitQuickTests" $phpCmd -f $phpunitPath \ -- \ ${paratestConfig[@]} \ @@ -61,7 +61,7 @@ do phpunitExitCode=$? set -e - set +x + if [[ "" != "$(grep '' $phpunitLogFilePath)" || ! -f $phpunitLogFilePath ]] then echo " @@ -76,11 +76,11 @@ do if (( $phpunitExitCode > 0 )) then - if (( $phpunitExitCode > 2 && $phpUnitIterativeMode == 0 )) + if (( $phpunitExitCode > 2 )) then printf "\n\n\nPHPUnit Crashed\n\nRunning again with Debug mode...\n\n\n" qaQuickTests="$phpUnitQuickTests" phpNoXdebug -f bin/phpunit -- "$testsDir" --debug - set +x + fi tryAgainOrAbort "PHPUnit Tests" fi diff --git a/includes/generic/phpunitAnnotations.inc.bash b/includes/generic/phpunitAnnotations.inc.bash index a4ef7b5..9be0912 100644 --- a/includes/generic/phpunitAnnotations.inc.bash +++ b/includes/generic/phpunitAnnotations.inc.bash @@ -2,13 +2,13 @@ annotationsExitCode=99 while (( annotationsExitCode > 0 )) do set +e - set -x + phpNoXdebug bin/phpunit-check-annotation \ "$testsDir" annotationsExitCode=$? set -e - set +x + if (( $annotationsExitCode > 0 )) then tryAgainOrAbort "PHPUnit Annotations Check" diff --git a/includes/generic/psr4Validate.inc.bash b/includes/generic/psr4Validate.inc.bash index 30c06c6..24aae8e 100644 --- a/includes/generic/psr4Validate.inc.bash +++ b/includes/generic/psr4Validate.inc.bash @@ -2,10 +2,10 @@ set +e psr4ExitCode=99 while (( psr4ExitCode > 0 )) do - set -x + phpNoXdebug -f ./bin/psr4-validate ${psr4IgnoreList[*]} psr4ExitCode=$? - set +x + if (( psr4ExitCode > 0 )) then tryAgainOrAbort "PSR-4 Validation" diff --git a/includes/generic/setConfig.inc.bash b/includes/generic/setConfig.inc.bash index 1a0ea79..e2d1421 100644 --- a/includes/generic/setConfig.inc.bash +++ b/includes/generic/setConfig.inc.bash @@ -12,6 +12,8 @@ varDir="$projectRoot/var/qa"; cacheDir="$varDir/cache"; +noXdebugConfigPath="$varDir/phpqa-no-xdebug.ini" + # the path in this library for default config defaultConfigPath="$(readlink -f ./../configDefaults/)" diff --git a/src/Markdown/LinksChecker.php b/src/Markdown/LinksChecker.php index 315a020..c07f588 100644 --- a/src/Markdown/LinksChecker.php +++ b/src/Markdown/LinksChecker.php @@ -124,7 +124,9 @@ private static function checkLink( '', \dirname($file) ); - $start .= '/' . \rtrim($relativeSubdirs, '/'); + if ($relativeSubdirs !== null) { + $start .= '/' . \rtrim($relativeSubdirs, '/'); + } } $realpath = \realpath($start . '/' . $path); if (false === $realpath) { diff --git a/src/Psr4Validator.php b/src/Psr4Validator.php index a37742a..6e4c977 100644 --- a/src/Psr4Validator.php +++ b/src/Psr4Validator.php @@ -161,8 +161,8 @@ public function __construct(\RecursiveIteratorIterator $iterator) } /** - * @param \SplFileInfo $item1 - * @param \SplFileInfo $item2 + * @param mixed $item1 + * @param mixed $item2 * * @return int */