From d8363067e62c441780e50f4a4787b3a246a03993 Mon Sep 17 00:00:00 2001 From: odain Date: Mon, 15 Jun 2020 09:07:31 +0200 Subject: [PATCH] ci 2 new options: coverture + run only one test :green_heart: try to have coverture option --- .jenkins/bin/tests/phpunit.sh | 23 +++++++++++++++++++++-- Jenkinsfile | 5 ++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.jenkins/bin/tests/phpunit.sh b/.jenkins/bin/tests/phpunit.sh index 319e977c4..17fa52827 100755 --- a/.jenkins/bin/tests/phpunit.sh +++ b/.jenkins/bin/tests/phpunit.sh @@ -6,6 +6,8 @@ cd test export DEBUG_UNIT_TEST=0 RUN_NONREG_TESTS=0 +#USAGE ${debugMode} ${runNonRegOQLTests} "${coverture}" "${testFile}" + if [ $# -ge 1 -a "x$1" == "xtrue" ] then export DEBUG_UNIT_TEST=1 @@ -13,10 +15,27 @@ else export DEBUG_UNIT_TEST=0 fi +set -x +OPTION="" +if [ $# -ge 3 -a "x$3" == "xtrue" ] +then + ##coverture + OPTION="-dxdebug.coverage_enable=1 --coverage-clover ../var/test/coverage.xml" +fi + +TESTFILE="$4" +if [ "x$TESTFILE" != "x" ] +then + # shellcheck disable=SC2001 + TESTFILE=$(echo "$TESTFILE" | sed 's|test/||1') + php vendor/bin/phpunit --log-junit ../var/test/phpunit-log.junit.xml $OPTION $TESTFILE --teamcity + exit 0 +fi + if [ $# -ge 2 -a "x$2" == "xtrue" ] then - php vendor/bin/phpunit --log-junit ../var/test/phpunit-log.junit.xml --teamcity + php vendor/bin/phpunit --log-junit ../var/test/phpunit-log.junit.xml $OPTION --teamcity else #echo php vendor/bin/phpunit --log-junit ../var/test/phpunit-log.junit.xml --teamcity - php vendor/bin/phpunit --log-junit ../var/test/phpunit-log.junit.xml --exclude-group OQL --teamcity + php vendor/bin/phpunit --log-junit ../var/test/phpunit-log.junit.xml $OPTION --exclude-group OQL --teamcity fi diff --git a/Jenkinsfile b/Jenkinsfile index 8569d7552..32c49f9b7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,6 +2,8 @@ pipeline { agent any parameters { booleanParam(name: 'debugMode', defaultValue: 'false', description: 'Debug mode?') + string(name: 'testFile', defaultValue: '', description: 'Provide test file to execute. Example: test/core/LogAPITest.php') + booleanParam(name: 'coverture', defaultValue: 'false', description: 'Test coverture?') booleanParam(name: 'runNonRegOQLTests', defaultValue: 'false', description: 'Do You want to run legacy OQL regression tests?') } stages { @@ -40,7 +42,7 @@ pipeline { parallel { stage('phpunit') { steps { - sh './.jenkins/bin/tests/phpunit.sh ${debugMode} ${runNonRegOQLTests}' + sh './.jenkins/bin/tests/phpunit.sh ${debugMode} ${runNonRegOQLTests} "${coverture}" "${testFile}"' } } } @@ -50,6 +52,7 @@ pipeline { post { always { + archiveArtifacts allowEmptyArchive:true, excludes: '.gitkeep', artifacts: 'var/test/*.xml' junit 'var/test/phpunit-log.junit.xml' } failure {