From commits-return-70706-archive-asf-public=cust-asf.ponee.io@maven.apache.org Sun Feb 18 01:47:37 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 11D6F180780 for ; Sun, 18 Feb 2018 01:47:35 +0100 (CET) Received: (qmail 39850 invoked by uid 500); 18 Feb 2018 00:47:28 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 35275 invoked by uid 99); 18 Feb 2018 00:47:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Feb 2018 00:47:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B34CAF4DD0; Sun, 18 Feb 2018 00:47:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tibordigana@apache.org To: commits@maven.apache.org Date: Sun, 18 Feb 2018 00:48:04 -0000 Message-Id: <97bf9172dd094d45814b9be98e727df7@git.apache.org> In-Reply-To: <0d5eb687612d46988383d07764e1fce1@git.apache.org> References: <0d5eb687612d46988383d07764e1fce1@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [52/52] [abbrv] maven-surefire git commit: [SUREFIRE-1472] Multibranch Pipeline supports JDK 7-10 Maven 3.2-3.5 Linux Windows [SUREFIRE-1472] Multibranch Pipeline supports JDK 7-10 Maven 3.2-3.5 Linux Windows Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/eb210e08 Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/eb210e08 Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/eb210e08 Branch: refs/heads/master Commit: eb210e08f5cf98a20c7d45c3e389391992845443 Parents: 4d00932 Author: Tibor17 Authored: Tue Feb 6 05:30:00 2018 +0100 Committer: Tibor17 Committed: Sun Feb 18 01:44:10 2018 +0100 ---------------------------------------------------------------------- Jenkinsfile | 334 ++++++++----------- maven-failsafe-plugin/pom.xml | 5 + maven-surefire-common/pom.xml | 2 - maven-surefire-report-plugin/pom.xml | 1 + pom.xml | 93 +++--- surefire-api/pom.xml | 2 - surefire-booter/pom.xml | 2 - surefire-its/pom.xml | 14 +- .../maven/surefire/its/JUnit47ParallelIT.java | 6 +- .../apache/maven/surefire/its/UmlautDirIT.java | 17 +- .../surefire/its/fixture/JUnit4SuiteTest.java | 44 +++ .../its/fixture/SurefireLauncherTest.java | 4 - ...urefire1295AttributeJvmCrashesToTestsIT.java | 107 +++--- .../test/resources/crash-during-test/pom.xml | 13 + .../java/junit44/environment/BasicTest.java | 52 --- .../java/junit44/environment/SomeOtherTest.java | 28 -- .../junit44/environment/Test1CrashedTest.java | 52 +++ .../junit44/environment/Test2WaitingTest.java | 34 ++ .../java/junit44/environment/Test3FastTest.java | 30 ++ surefire-providers/pom.xml | 1 - surefire-providers/surefire-junit3/pom.xml | 1 - surefire-providers/surefire-junit4/pom.xml | 6 - .../surefire/junitcore/pc/ParallelComputer.java | 22 +- .../junitcore/pc/ParallelComputerBuilder.java | 2 +- .../pc/ParallelComputerBuilderTest.java | 82 +++-- .../junitcore/pc/ParallelComputerUtilTest.java | 63 ++-- surefire-report-parser/pom.xml | 12 +- .../surefire/report/JUnit4SuiteTest.java | 46 +++ 28 files changed, 606 insertions(+), 469 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/Jenkinsfile ---------------------------------------------------------------------- diff --git a/Jenkinsfile b/Jenkinsfile index c080713..822bbc1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,208 +26,42 @@ properties( ] ) -def oses = ['windows'] // ['linux', 'windows'] -def mavens = env.BRANCH_NAME == 'master' ? ['3.2.x', '3.3.x', '3.5.x'] : ['3.5.x'] -def jdks = ['9'] // env.BRANCH_NAME == 'master' ? ['7', '8', '9', '10'] : ['10'] +final String NIX_LABEL = 'ubuntu-1||ubuntu-4||ubuntu-6||H19||H20' +final String WIN_LABEL = 'windows-2016-1' -def cmd = ['mvn'] -def options = ['-e', '-V', '-nsu'] -def optionsITs = ['-e', '-V', '-nsu', '-P', 'run-its'] -def goals = ['clean', 'install' , 'jacoco:report'] -def goalsITs = ['verify'] -def Map stages = [:] +final def oses = ['linux', 'windows'] +final def mavens = ['3.2.x', '3.3.x', '3.5.x'] // env.BRANCH_NAME == 'master' ? ['3.2.x', '3.3.x', '3.5.x'] : ['3.5.x'] +final def jdks = ['7', '8', '9', '10'] // env.BRANCH_NAME == 'master' ? ['7', '8', '9', '10'] : ['10'] -oses.eachWithIndex { os, indexOfOs -> - - mavens.eachWithIndex { maven, indexOfMaven -> - - jdks.eachWithIndex { jdk, indexOfJdk -> - - def String label = jenkinsEnv.labelForOS(os); - def String jdkTestName = jenkinsEnv.jdkFromVersion(os, jdk) - def String jdkName = jenkinsEnv.jdkFromVersion(os, '8') - def String mvnName = jenkinsEnv.mvnFromVersion(os, maven) - - def stageKey = "${os}-jdk${jdk}-maven${maven}" - - if (label == null || jdkTestName == null || mvnName == null) { - println "Skipping ${stageKey} as unsupported by Jenkins Environment." - return; - } - - println "${stageKey} ==> Label: ${label}, JDK: ${jdkTestName}, Maven: ${mvnName}." +final def cmd = ['mvn'] +final def options = ['-e', '-V', '-nsu', '-P', 'run-its'] +final def goals = ['clean', 'install', 'jacoco:report'] +final Map stages = [:] +oses.eachWithIndex { os, indexOfOs -> + stages[os] = { + mavens.eachWithIndex { maven, indexOfMaven -> + jdks.eachWithIndex { jdk, indexOfJdk -> + final String label = jenkinsEnv.labelForOS(os); + final String jdkTestName = jenkinsEnv.jdkFromVersion(os, jdk) + final String jdkName = jenkinsEnv.jdkFromVersion(os, '8') + final String mvnName = jenkinsEnv.mvnFromVersion(os, maven) + final String stageKey = "${os}-jdk${jdk}-maven${maven}" + + if (label == null || jdkTestName == null || mvnName == null) { + println "Skipping ${stageKey} as unsupported by Jenkins Environment." + return; + } - stages[stageKey] = { + println "${stageKey} ==> Label: ${label}, JDK: ${jdkTestName}, Maven: ${mvnName}." if (os == 'windows') { - node("${env.WIN_LABEL}") { - try { - println "Basedir = ${pwd()}." - - def mvnLocalRepoDir - - dir('.repository') { - mvnLocalRepoDir = "${pwd()}" - } - - println "Maven Local Repository = ${mvnLocalRepoDir}." - - dir('build') { - stage("checkout ${stageKey}") { - checkout scm - } - - def jdkTestHome = resolveToolNameToJavaPath(jdkTestName, mvnName) - def properties = ["\"-Djdk.home=${jdkTestHome}\"", "-Djacoco.skip=true"] - println("Setting JDK for testing ${properties[0]}") - - stage("build ${stageKey}") { - withMaven(jdk: jdkName, maven: mvnName, - mavenLocalRepo: mvnLocalRepoDir, mavenOpts: '-Xmx512m', - options: [ - artifactsPublisher(disabled: true), - ]) { - def script = cmd + options + goals + properties - bat script.join(' ') - } - } - - def propertiesITs = properties - - stage("build-failsafe-it ${stageKey}") { -// lock('maven-surefire-its') { -// timeout(time: 15, unit: 'MINUTES') { -// withMaven(jdk: jdkName, maven: mvnName, -// mavenLocalRepo: mvnLocalRepoDir, mavenOpts: '-Xmx512m', -// options: [ -// invokerPublisher(), -// artifactsPublisher(disabled: true) -// ]) { -// def script = cmd + optionsITs + goalsITs + propertiesITs -// bat script.join(' ') -// } -// } -// } - } - } - } finally { -// Wait for INFRA installation of Pipeline Utils, use fileExists() -// if (fileExists('build/maven-failsafe-plugin/target/it') { -// zip(zipFile: "it--maven-failsafe-plugin--${stageKey}.zip", dir: 'build/maven-failsafe-plugin/target/it', archive: true) -// } -// -// if (fileExists('build/surefire-its/target') { -// zip(zipFile: "it--surefire-its--${stageKey}.zip", dir: 'build/surefire-its/target', archive: true) -// } - -// archiveArtifacts(artifacts: 'build/surefire-its/target/**/log.txt', allowEmptyArchive: true, fingerprint: true, onlyIfSuccessful: false) - - stage("cleanup ${stageKey}") { - // clean up after ourselves to reduce disk space - cleanWs() - } - } + node(WIN_LABEL) { + buildProcess(stageKey, jdkName, jdkTestName, mvnName, cmd, options, goals, false) } } else { - node("${env.NIX_LABEL}") { - try { - println "Basedir = ${pwd()}." - - def mvnLocalRepoDir - - dir('.repository') { - mvnLocalRepoDir = "${pwd()}" - } - - println "Maven Local Repository = ${mvnLocalRepoDir}." - - dir('build') { - stage("checkout ${stageKey}") { - checkout scm - } - - def jdkTestHome = resolveToolNameToJavaPath(jdkTestName, mvnName) - //https://github.com/jacoco/jacoco/issues/629 - def skipPlugins = jdk != '9' - def properties = ["\"-Djdk.home=${jdkTestHome}\"", "-Djacoco.skip=${skipPlugins}"] - println("Setting JDK for testing ${properties[0]}") - - stage("build ${stageKey}") { - withMaven(jdk: jdkName, maven: mvnName, - mavenLocalRepo: mvnLocalRepoDir, mavenOpts: '-Xmx1g', - options: [ - findbugsPublisher(disabled: skipPlugins), - openTasksPublisher(disabled: skipPlugins, ignoreCase: true, - pattern: sourcesPatternCsv(), - low: tasksViolationLow(), - normal: tasksViolationNormal(), - high: tasksViolationHigh()), - artifactsPublisher(disabled: true) - ]) { - def script = cmd + options + goals + properties - sh script.join(' ') - } - } - - def propertiesITs = [properties[0], '-Djacoco.skip=true'] - - stage("build-failsafe-it ${stageKey}") { -// lock('maven-surefire-its') { -// timeout(time: 15, unit: 'MINUTES') { -// withMaven(jdk: jdkName, maven: mvnName, -// mavenLocalRepo: mvnLocalRepoDir, mavenOpts: '-Xmx1g', -// options: [ -// invokerPublisher(), -// openTasksPublisher(disabled: true, ignoreCase: true, -// pattern: sourcesPatternCsv(), -// low: tasksViolationLow(), -// normal: tasksViolationNormal(), -// high: tasksViolationHigh()), -// artifactsPublisher(disabled: true) -// ]) { -// def script = cmd + optionsITs + goalsITs + propertiesITs -// sh script.join(' ') -// } -// } -// } - } - } - } finally { - if (indexOfMaven == mavens.size() - 1 && jdk == '9') { - jacoco(changeBuildStatus: false, - execPattern: '**/*.exec', - sourcePattern: sourcesPatternCsv(), - classPattern: classPatternCsv()) - - junit(healthScaleFactor: 0.0, - allowEmptyResults: true, - keepLongStdio: true, - testResults: testReportsPatternCsv()) - - if (currentBuild.result == 'UNSTABLE') { - currentBuild.result = 'FAILURE' - } - } - -// Wait for INFRA installation of Pipeline Utils, use fileExists() -// if (fileExists('build/maven-failsafe-plugin/target/it') { -// zip(zipFile: "it--maven-failsafe-plugin--${stageKey}.zip", dir: 'build/maven-failsafe-plugin/target/it', archive: true) -// } -// -// if (fileExists('build/surefire-its/target') { -// zip(zipFile: "it--surefire-its--${stageKey}.zip", dir: 'build/surefire-its/target', archive: true) -// } -// -// sh 'tar czvf it1.tgz build/maven-failsafe-plugin/target/it' -// sh 'tar czvf it2.tgz build/surefire-its/target' -// archiveArtifacts(artifacts: '**/*.tgz', allowEmptyArchive: true, fingerprint: true, onlyIfSuccessful: false) -// archiveArtifacts(artifacts: '*.tgz', allowEmptyArchive: true, fingerprint: true, onlyIfSuccessful: false) - - stage("cleanup ${stageKey}") { - // clean up after ourselves to reduce disk space - cleanWs() - } - } + node(NIX_LABEL) { + boolean makeReports = indexOfMaven == mavens.size() - 1 && jdk == '9' + buildProcess(stageKey, jdkName, jdkTestName, mvnName, cmd, options, goals, makeReports) } } } @@ -235,7 +69,7 @@ oses.eachWithIndex { os, indexOfOs -> } } -timeout(time: 18, unit: 'HOURS') { +timeout(time: 24, unit: 'HOURS') { try { parallel(stages) // JENKINS-34376 seems to make it hard to detect the aborted builds @@ -268,6 +102,102 @@ timeout(time: 18, unit: 'HOURS') { } } +def buildProcess(String stageKey, String jdkName, String jdkTestName, String mvnName, cmd, options, goals, boolean makeReports) { + cleanWs() + try { + if (isUnix()) { + sh 'mkdir -p .m2' + } else { + bat 'mkdir .m2' + } + def mvnLocalRepoDir = null + dir('.m2') { + mvnLocalRepoDir = "${pwd()}" + } + + println "Maven Local Repository = ${mvnLocalRepoDir}." + assert mvnLocalRepoDir != null: 'Local Maven Repository is undefined.' + + stage("checkout ${stageKey}") { + checkout scm + } + + def jdkTestHome = resolveToolNameToJavaPath(jdkTestName, mvnName) + //https://github.com/jacoco/jacoco/issues/629 + def properties = ["\"-Djdk.home=${jdkTestHome}\"", "-Djacoco.skip=${!makeReports}"] + println("Setting JDK for testing ${properties[0]}") + def mavenOpts = '-server -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xms64m -Xmx1g -Djava.awt.headless=true' + + stage("build ${stageKey}") { + withMaven(jdk: jdkName, maven: mvnName, + mavenLocalRepo: mvnLocalRepoDir, mavenOpts: mavenOpts, + options: [ + findbugsPublisher(disabled: !makeReports), + openTasksPublisher(disabled: true), + junitPublisher(disabled: true), + artifactsPublisher(disabled: true), + invokerPublisher(disabled: true) + ]) { + def script = cmd + options + goals + properties + if (isUnix()) { + sh script.join(' ') + } else { + bat script.join(' ') + } + } + } + } finally { + stage("reporting ${stageKey}") { + if (makeReports) { + openTasks(ignoreCase: true, canComputeNew: false, defaultEncoding: 'UTF-8', pattern: sourcesPatternCsv(), + high: tasksViolationHigh(), normal: tasksViolationNormal(), low: tasksViolationLow()) + + jacoco(changeBuildStatus: false, + execPattern: '**/*.exec', + sourcePattern: sourcesPatternCsv(), + classPattern: classPatternCsv()) + + junit(healthScaleFactor: 0.0, + allowEmptyResults: true, + keepLongStdio: true, + testResults: testReportsPatternCsv()) + + if (currentBuild.result == 'UNSTABLE') { + currentBuild.result = 'FAILURE' + } + } + + if (isUnix()) { + if (fileExists('maven-failsafe-plugin/target/it')) { + sh "tar czf failsafe-its-${stageKey}.tgz maven-failsafe-plugin/target/it" + } + + if (fileExists('surefire-its/target')) { + sh "tar czf surefire-its-${stageKey}.tgz surefire-its/target" + } +// println(readFile('target/rat.txt')) +// Wait for INFRA installation of Pipeline Utils, use fileExists() +// if (fileExists('maven-failsafe-plugin/target/it')) { +// zip(zipFile: "it--maven-failsafe-plugin--${stageKey}.zip", dir: 'maven-failsafe-plugin/target/it', archive: true) +// } +// +// if (fileExists('surefire-its/target')) { +// zip(zipFile: "it--surefire-its--${stageKey}.zip", dir: 'surefire-its/target', archive: true) +// } +// +// archiveArtifacts(artifacts: 'surefire-its/target/**/log.txt', allowEmptyArchive: true, fingerprint: true, onlyIfSuccessful: false) + + archive includes: '*.tgz' + } + } + + stage("cleanup ${stageKey}") { + // clean up after ourselves to reduce disk space + cleanWs() + } + } +} + /** * It is used instead of tool(${jdkTestName}). */ @@ -295,7 +225,7 @@ def resolveToolNameToJavaPath(jdkToolName, mvnName) { } @NonCPS -def sourcesPatternCsv() { +static def sourcesPatternCsv() { return '**/maven-failsafe-plugin/src/main/java,' + '**/maven-surefire-common/src/main/java,' + '**/maven-surefire-plugin/src/main/java,' + @@ -310,7 +240,7 @@ def sourcesPatternCsv() { } @NonCPS -def classPatternCsv() { +static def classPatternCsv() { return '**/maven-failsafe-plugin/target/classes,' + '**/maven-surefire-common/target/classes,' + '**/maven-surefire-plugin/target/classes,' + @@ -325,23 +255,23 @@ def classPatternCsv() { } @NonCPS -def tasksViolationLow() { +static def tasksViolationLow() { return '@SuppressWarnings' } @NonCPS -def tasksViolationNormal() { +static def tasksViolationNormal() { return 'TODO,FIXME,@deprecated' } @NonCPS -def tasksViolationHigh() { +static def tasksViolationHigh() { return 'finalize(),Locale.setDefault,TimeZone.setDefault,\ System.out,System.err,System.setOut,System.setErr,System.setIn,System.exit,System.gc,System.runFinalization,System.load' } @NonCPS -def testReportsPatternCsv() { +static def testReportsPatternCsv() { return '**/maven-failsafe-plugin/target/surefire-reports/*.xml,' + '**/maven-surefire-common/target/surefire-reports/*.xml,' + '**/maven-surefire-plugin/target/surefire-reports/*.xml,' + http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/maven-failsafe-plugin/pom.xml ---------------------------------------------------------------------- diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml index 9e3d87b..7176456 100644 --- a/maven-failsafe-plugin/pom.xml +++ b/maven-failsafe-plugin/pom.xml @@ -57,6 +57,10 @@ site-source + org.apache.maven.shared + maven-shared-utils + + org.apache.commons commons-lang3 @@ -284,6 +288,7 @@ clean verify + -nsu dummy-*/pom.xml http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/maven-surefire-common/pom.xml ---------------------------------------------------------------------- diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml index 7e063c8..e6ef88a 100644 --- a/maven-surefire-common/pom.xml +++ b/maven-surefire-common/pom.xml @@ -171,8 +171,6 @@ maven-surefire-plugin - ${jdk.home}/bin/java - true **/JUnit4SuiteTest.java http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/maven-surefire-report-plugin/pom.xml ---------------------------------------------------------------------- diff --git a/maven-surefire-report-plugin/pom.xml b/maven-surefire-report-plugin/pom.xml index 9cdd569..662db98 100644 --- a/maven-surefire-report-plugin/pom.xml +++ b/maven-surefire-report-plugin/pom.xml @@ -168,6 +168,7 @@ maven-surefire-plugin + true org.fusesource.jansi:jansi http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index f5af360..4a768a5 100644 --- a/pom.xml +++ b/pom.xml @@ -50,8 +50,8 @@ surefire-logger-api - surefire-shadefire surefire-api + surefire-shadefire surefire-booter surefire-grouper surefire-providers @@ -99,6 +99,7 @@ ${java.home}/.. 1.7 1.7 + -server -XX:+UseG1GC -Xms128m -Xmx144m -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true @@ -433,8 +434,10 @@ false - -Xms128m -Xmx144m ${jacoco.agent} + ${jvm.args.tests} ${jacoco.agent} false + false + ${jdk.home}/bin/java @@ -470,6 +473,10 @@ maven-site-plugin 3.4 + + maven-deploy-plugin + 2.8.2 + @@ -546,50 +553,60 @@ - true + + true + org.codehaus.mojo animal-sniffer-maven-plugin - - org.apache.rat - apache-rat-plugin - 0.12 - - - rat-check - - check - - - - Jenkinsfile - README.md - .gitignore - .git/**/* - **/.idea - **/.svn/**/* - **/*.iml - **/*.ipr - **/*.iws - **/*.versionsBackup - **/dependency-reduced-pom.xml - .repository/** - src/test/resources/**/* - src/test/resources/**/*.css - **/*.jj - src/main/resources/META-INF/services/org.apache.maven.surefire.providerapi.SurefireProvider - - DEPENDENCIES - - - - - + + org.apache.rat + apache-rat-plugin + 0.12 + + + rat-check + + check + + + + Jenkinsfile + README.md + .gitignore + .git/**/* + **/.idea + **/.svn/**/* + **/*.iml + **/*.ipr + **/*.iws + **/*.versionsBackup + **/dependency-reduced-pom.xml + .repository/** + src/test/resources/**/* + src/test/resources/**/*.css + **/*.jj + src/main/resources/META-INF/services/org.apache.maven.surefire.providerapi.SurefireProvider + + DEPENDENCIES + .m2/** + .m2 + + + + + + + maven-deploy-plugin + + true + + http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-api/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml index 00ef758..bfc4203 100644 --- a/surefire-api/pom.xml +++ b/surefire-api/pom.xml @@ -52,8 +52,6 @@ maven-surefire-plugin - ${jdk.home}/bin/java - true **/JUnit4SuiteTest.java http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-booter/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-booter/pom.xml b/surefire-booter/pom.xml index ef5e26c..a69b38b 100644 --- a/surefire-booter/pom.xml +++ b/surefire-booter/pom.xml @@ -116,8 +116,6 @@ - ${jdk.home}/bin/java - true **/JUnit4SuiteTest.java http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-its/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/pom.xml b/surefire-its/pom.xml index e679753..bc097db 100644 --- a/surefire-its/pom.xml +++ b/surefire-its/pom.xml @@ -27,7 +27,7 @@ 2.21.0-SNAPSHOT - surefire-is + surefire-its Maven Surefire Integration Tests Used internally testing MOJOs. The project is not deployed. @@ -84,8 +84,17 @@ maven-surefire-plugin + + + org.apache.maven.surefire + surefire-shadefire + 2.12.4 + + - *Test + + org/apache/maven/surefire/its/fixture/JUnit4SuiteTest.java + @@ -120,7 +129,6 @@ ${jacoco-it.agent} false - false http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java index 5aee1a8..fdf75ef 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java @@ -524,7 +524,7 @@ public class JUnit47ParallelIT @Test public void forcedShutdownVerifyingLogs() { - // executes for 2.5 sec until timeout has elapsed + // attempts to run for 2.4 sec until timeout has elapsed unpack().parallelMethods().threadCountMethods( 3 ).disablePerCoreThreadCount() .parallelTestsTimeoutForcedInSeconds( 1.05d ).setTestToRun( "Waiting*Test" ).failNever().executeTest() .verifyTextInLog( "The test run has finished abruptly after timeout of 1.05 seconds." ) @@ -535,6 +535,8 @@ public class JUnit47ParallelIT private SurefireLauncher unpack() { return unpack( "junit47-parallel" ) - .showErrorStackTraces(); + .showErrorStackTraces() + .forkOnce() + .redirectToFile( false ); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-its/src/test/java/org/apache/maven/surefire/its/UmlautDirIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/UmlautDirIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/UmlautDirIT.java index 8848dc2..7b008bc 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/UmlautDirIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/UmlautDirIT.java @@ -40,25 +40,30 @@ public class UmlautDirIT public void testUmlaut() throws Exception { - specialUnpack().executeTest().verifyErrorFreeLog().assertTestSuiteResults( 1, 0, 0, 0 ); + specialUnpack( "1" ) + .executeTest() + .verifyErrorFreeLog() + .assertTestSuiteResults( 1, 0, 0, 0 ); } @Test public void testUmlautIsolatedClassLoader() throws Exception { - specialUnpack().useSystemClassLoader( false ).executeTest().assertTestSuiteResults( 1, 0, 0, 0 ); + specialUnpack( "2" ) + .useSystemClassLoader( false ) + .executeTest() + .assertTestSuiteResults( 1, 0, 0, 0 ); } - SurefireLauncher specialUnpack() - throws VerificationException, IOException + SurefireLauncher specialUnpack( String postfix ) + throws IOException { SurefireLauncher unpack = unpack( "junit-pathWithUmlaut" ); MavenLauncher maven = unpack.maven(); - File dest = new File( maven.getUnpackedAt().getParentFile().getPath(), "/junit-pathWith\u00DCmlaut" ); + File dest = new File( maven.getUnpackedAt().getParentFile().getPath(), "/junit-pathWith\u00DCmlaut_" + postfix ); maven.moveUnpackTo( dest ); return unpack; } - } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/JUnit4SuiteTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/JUnit4SuiteTest.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/JUnit4SuiteTest.java new file mode 100644 index 0000000..3961b13 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/JUnit4SuiteTest.java @@ -0,0 +1,44 @@ +package org.apache.maven.surefire.its.fixture; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.JUnit4TestAdapter; +import junit.framework.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Adapt the JUnit4 tests which use only annotations to the JUnit3 test suite. + * + * @author Tibor Digana (tibor17) + * @since 2.21.0 + */ +@Suite.SuiteClasses( { + MavenLauncherTest.class, + SurefireLauncherTest.class +} ) +@RunWith( Suite.class ) +public class JUnit4SuiteTest +{ + public static Test suite() + { + return new JUnit4TestAdapter( JUnit4SuiteTest.class ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java index b5df941..801ebec 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java @@ -19,9 +19,6 @@ package org.apache.maven.surefire.its.fixture; * under the License. */ -import java.io.IOException; -import org.apache.maven.it.VerificationException; - import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -33,7 +30,6 @@ public class SurefireLauncherTest { @Test public void launcherGetsProperMethodName() - throws IOException, VerificationException { MavenLauncher mavenLauncher = new MavenLauncher( SurefireLauncherTest.class, "foo", "" ); String method = new SurefireLauncher( mavenLauncher ).getTestMethodName(); http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java index 3ca758a..e160f7a 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java @@ -19,21 +19,25 @@ package org.apache.maven.surefire.its.jiras; * under the License. */ -import org.apache.maven.it.VerificationException; import org.apache.maven.surefire.its.fixture.OutputValidator; import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; import org.apache.maven.surefire.its.fixture.SurefireLauncher; -import org.junit.Before; -import org.junit.Test; +import org.junit.experimental.theories.DataPoints; +import org.junit.experimental.theories.FromDataPoints; +import org.junit.experimental.theories.Theories; +import org.junit.experimental.theories.Theory; +import org.junit.runner.RunWith; import java.util.Iterator; -import java.util.concurrent.TimeUnit; +import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.commons.lang3.SystemUtils.IS_OS_LINUX; import static org.apache.commons.lang3.SystemUtils.IS_OS_MAC_OSX; +import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS_7; +import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS_8; +import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS_10; import static org.fest.assertions.Assertions.assertThat; import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; /** * https://issues.apache.org/jira/browse/SUREFIRE-1295 @@ -42,67 +46,72 @@ import static org.junit.Assume.assumeTrue; * @author michaeltandy * @since 2.20 */ +@RunWith( Theories.class ) public class Surefire1295AttributeJvmCrashesToTestsIT extends SurefireJUnit4IntegrationTestCase { - @Before - public void skipWindows() + public enum ForkMode { - assumeTrue( IS_OS_LINUX || IS_OS_MAC_OSX ); + DEFAULT, + ONE_FORK_NO_REUSE, + ONE_FORK_REUSE } - @Test - public void crashInFork() throws VerificationException, InterruptedException - { - SurefireLauncher launcher = unpack( "crash-during-test" ); + @DataPoints( "crashStyle" ) + public static String[] crashStyle = { "exit", "abort", "segfault" }; - checkCrashTypes( launcher ); - } + @DataPoints( "forkStyle" ) + public static ForkMode[] forkStyle = ForkMode.values(); - @Test - public void crashInSingleUseFork() throws VerificationException, InterruptedException + @Theory + public void test( @FromDataPoints( "crashStyle" ) String crashStyle, + @FromDataPoints( "forkStyle" ) ForkMode forkStyle ) + throws Exception { - SurefireLauncher launcher = unpack( "crash-during-test" ) - .forkCount( 1 ) - .reuseForks( false ); - - checkCrashTypes( launcher ); - } + // JUnit Assumptions not supported by Theories runner. + if ( !IS_OS_LINUX && !IS_OS_MAC_OSX && !( IS_OS_WINDOWS_7 || IS_OS_WINDOWS_8 || IS_OS_WINDOWS_10 ) ) + { + return; + } - @Test - public void crashInReusableFork() throws VerificationException, InterruptedException - { - SurefireLauncher launcher = unpack( "crash-during-test" ) - .forkPerThread() - .reuseForks( true ) - .threadCount( 1 ); + SurefireLauncher launcher = + unpack( "crash-during-test", "_" + crashStyle + "_" + forkStyle.ordinal() ) + .setForkJvm(); - checkCrashTypes( launcher ); - } + switch ( forkStyle ) + { + case DEFAULT: + break; + case ONE_FORK_NO_REUSE: + launcher.forkCount( 1 ) + .reuseForks( false ); + break; + case ONE_FORK_REUSE: + launcher.forkPerThread() + .reuseForks( true ) + .threadCount( 1 ); + break; + default: + fail(); + } - private static void checkCrashTypes( SurefireLauncher launcher ) - throws VerificationException, InterruptedException - { - checkCrash( launcher.addGoal( "-DcrashType=exit" ) ); - checkCrash( launcher.addGoal( "-DcrashType=abort" ) ); - checkCrash( launcher.addGoal( "-DcrashType=segfault" ) ); + checkCrash( launcher.addGoal( "-DcrashType=" + crashStyle ) ); } - private static void checkCrash( SurefireLauncher launcher ) throws VerificationException, InterruptedException + private static void checkCrash( SurefireLauncher launcher ) throws Exception { OutputValidator validator = launcher.maven() - .withFailure() - .executeTest() - .verifyTextInLog( "The forked VM terminated without properly saying " - + "goodbye. VM crash or System.exit called?" - ) - .verifyTextInLog( "Crashed tests:" ); + .withFailure() + .executeTest() + .verifyTextInLog( "The forked VM terminated without properly saying " + + "goodbye. VM crash or System.exit called?" ) + .verifyTextInLog( "Crashed tests:" ); // Cannot flush log.txt stream because it is consumed internally by Verifier. // Waiting for the stream to become flushed on disk. - TimeUnit.SECONDS.sleep( 1L ); + SECONDS.sleep( 1L ); - for ( Iterator it = validator.loadLogLines().iterator(); it.hasNext(); ) + for ( Iterator< String > it = validator.loadLogLines().iterator(); it.hasNext(); ) { String line = it.next(); if ( line.contains( "Crashed tests:" ) ) @@ -110,7 +119,8 @@ public class Surefire1295AttributeJvmCrashesToTestsIT line = it.next(); if ( it.hasNext() ) { - assertThat( line ).contains( "junit44.environment.BasicTest" ); + assertThat( line ) + .contains( "junit44.environment.Test1CrashedTest" ); } else { @@ -118,8 +128,5 @@ public class Surefire1295AttributeJvmCrashesToTestsIT } } } - } - - } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-its/src/test/resources/crash-during-test/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/crash-during-test/pom.xml b/surefire-its/src/test/resources/crash-during-test/pom.xml index 0d9e3e7..3929e83 100644 --- a/surefire-its/src/test/resources/crash-during-test/pom.xml +++ b/surefire-its/src/test/resources/crash-during-test/pom.xml @@ -51,12 +51,25 @@ + + + + + maven-clean-plugin + 3.0.0 + + + maven-surefire-plugin ${surefire.version} once + alphabetical http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/BasicTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/BasicTest.java b/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/BasicTest.java deleted file mode 100644 index 57d57bb..0000000 --- a/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/BasicTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package junit44.environment; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import static org.junit.Assert.*; -import org.junit.Test; -import uk.me.mjt.CrashJvm; - -public class BasicTest -{ - @Test - public void testCrashJvm() - { - assertTrue(CrashJvm.loadedOk()); - - String crashType = System.getProperty("crashType"); - assertNotNull(crashType); - if ( crashType.equals( "exit" ) ) - { - CrashJvm.exit(); - } - else if ( crashType.equals( "abort" ) ) - { - CrashJvm.abort(); - } - else if (crashType.equals( "segfault" )) - { - CrashJvm.segfault(); - } - else - { - fail("Don't recognise crashType " + crashType); - } - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/SomeOtherTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/SomeOtherTest.java b/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/SomeOtherTest.java deleted file mode 100644 index e10f6aa..0000000 --- a/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/SomeOtherTest.java +++ /dev/null @@ -1,28 +0,0 @@ - -package junit44.environment; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.junit.Test; - -public class SomeOtherTest { - @Test - public void nonCrashingTest() {} -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/Test1CrashedTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/Test1CrashedTest.java b/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/Test1CrashedTest.java new file mode 100644 index 0000000..28fe637 --- /dev/null +++ b/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/Test1CrashedTest.java @@ -0,0 +1,52 @@ +package junit44.environment; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import static org.junit.Assert.*; +import org.junit.Test; +import uk.me.mjt.CrashJvm; + +public class Test1CrashedTest +{ + @Test + public void testCrashJvm() + { + assertTrue(CrashJvm.loadedOk()); + + String crashType = System.getProperty("crashType"); + assertNotNull(crashType); + if ( crashType.equals( "exit" ) ) + { + CrashJvm.exit(); + } + else if ( crashType.equals( "abort" ) ) + { + CrashJvm.abort(); + } + else if (crashType.equals( "segfault" )) + { + CrashJvm.segfault(); + } + else + { + fail("Don't recognise crashType " + crashType); + } + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/Test2WaitingTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/Test2WaitingTest.java b/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/Test2WaitingTest.java new file mode 100644 index 0000000..dc3ce47 --- /dev/null +++ b/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/Test2WaitingTest.java @@ -0,0 +1,34 @@ +package junit44.environment; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.junit.Test; + +import static java.util.concurrent.TimeUnit.MILLISECONDS; + +public class Test2WaitingTest +{ + @Test + public void nonCrashingTest() + throws InterruptedException + { + MILLISECONDS.sleep( 1500L ); + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/Test3FastTest.java ---------------------------------------------------------------------- diff --git a/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/Test3FastTest.java b/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/Test3FastTest.java new file mode 100644 index 0000000..3a4d88e --- /dev/null +++ b/surefire-its/src/test/resources/crash-during-test/src/test/java/junit44/environment/Test3FastTest.java @@ -0,0 +1,30 @@ +package junit44.environment; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.junit.Test; + +public class Test3FastTest +{ + @Test + public void emptyTest() + { + } +} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-providers/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-providers/pom.xml b/surefire-providers/pom.xml index 65ae76f..de5214a 100644 --- a/surefire-providers/pom.xml +++ b/surefire-providers/pom.xml @@ -56,7 +56,6 @@ maven-surefire-plugin - 2.12.4 org.apache.maven.surefire http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-providers/surefire-junit3/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit3/pom.xml b/surefire-providers/surefire-junit3/pom.xml index 2e906da..93375b2 100644 --- a/surefire-providers/surefire-junit3/pom.xml +++ b/surefire-providers/surefire-junit3/pom.xml @@ -72,7 +72,6 @@ - http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-providers/surefire-junit4/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit4/pom.xml b/surefire-providers/surefire-junit4/pom.xml index 870f13c..fe1496f 100644 --- a/surefire-providers/surefire-junit4/pom.xml +++ b/surefire-providers/surefire-junit4/pom.xml @@ -55,12 +55,6 @@ - maven-surefire-plugin - - ${java.home}/bin/java - - - org.apache.maven.plugins maven-shade-plugin 1.4 http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java index a198887..2e4104c 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputer.java @@ -67,7 +67,7 @@ public abstract class ParallelComputer protected abstract ShutdownResult describeStopped( boolean shutdownNow ); - abstract boolean shutdownThreadPoolsAwaitingKilled(); + protected abstract boolean shutdownThreadPoolsAwaitingKilled(); protected final void beforeRunQuietly() { @@ -249,19 +249,23 @@ public abstract class ParallelComputer { if ( testsBeforeShutdown != null ) { - for ( final Description test : testsBeforeShutdown.get().getTriggeredTests() ) + final ShutdownResult shutdownResult = testsBeforeShutdown.get(); + if ( shutdownResult != null ) { - if ( test != null && test.getDisplayName() != null ) + for ( final Description test : shutdownResult.getTriggeredTests() ) { - executedTests.add( test.getDisplayName() ); + if ( test != null && test.getDisplayName() != null ) + { + executedTests.add( test.getDisplayName() ); + } } - } - for ( final Description test : testsBeforeShutdown.get().getIncompleteTests() ) - { - if ( test != null && test.getDisplayName() != null ) + for ( final Description test : shutdownResult.getIncompleteTests() ) { - incompleteTests.add( test.getDisplayName() ); + if ( test != null && test.getDisplayName() != null ) + { + incompleteTests.add( test.getDisplayName() ); + } } } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java index fd0cab3..22d7eab 100755 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java @@ -333,7 +333,7 @@ public final class ParallelComputerBuilder } @Override - boolean shutdownThreadPoolsAwaitingKilled() + protected boolean shutdownThreadPoolsAwaitingKilled() { boolean notInterrupted = notThreadSafeTests.shutdownThreadPoolsAwaitingKilled(); final Scheduler m = master; http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java index 212e157..b90da87 100755 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java +++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java @@ -26,9 +26,7 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.Stopwatch; import org.junit.runner.Description; import org.junit.runner.JUnitCore; import org.junit.runner.Result; @@ -54,7 +52,6 @@ import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; import static org.apache.maven.surefire.junitcore.pc.RangeMatcher.between; import static org.junit.Assert.*; -import static java.util.concurrent.TimeUnit.MILLISECONDS; /** * @author Tibor Digana (tibor17) @@ -70,9 +67,6 @@ public class ParallelComputerBuilderTest private static final ConsoleStream logger = new DefaultDirectConsoleReporter( System.out ); - @Rule - public final Stopwatch stopwatch = new Stopwatch() {}; - private static void testKeepBeforeAfter( ParallelComputerBuilder builder, Class... classes ) { JUnitCore core = new JUnitCore(); @@ -94,8 +88,16 @@ public class ParallelComputerBuilderTest } } + @BeforeClass + public static void cleanup() throws InterruptedException + { + System.gc(); + Thread.sleep( 500L ); + } + @Before - public void beforeTest() throws InterruptedException { + public void beforeTest() + { Class1.maxConcurrentMethods = 0; Class1.concurrentMethods = 0; shutdownTask = null; @@ -104,8 +106,6 @@ public class ParallelComputerBuilderTest NotThreadSafeTest3.t = null; NormalTest1.t = null; NormalTest2.t = null; - System.gc(); - Thread.sleep( 50L ); } @Test @@ -136,8 +136,11 @@ public class ParallelComputerBuilderTest assertFalse( parallelComputerBuilder.isOptimized() ); ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - Result result = new JUnitCore().run( computer, TestSuite.class ); - long timeSpent = stopwatch.runtime( MILLISECONDS ); + final JUnitCore core = new JUnitCore(); + final long t1 = System.currentTimeMillis(); + final Result result = core.run( computer, TestSuite.class ); + final long t2 = System.currentTimeMillis(); + final long timeSpent = t2 - t1; assertThat( computer.getSuites().size(), is( 1 ) ); assertThat( computer.getClasses().size(), is( 0 ) ); @@ -171,8 +174,11 @@ public class ParallelComputerBuilderTest assertFalse( parallelComputerBuilder.isOptimized() ); ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - Result result = new JUnitCore().run( computer, TestSuite.class, Class1.class ); - long timeSpent = stopwatch.runtime( MILLISECONDS ); + final JUnitCore core = new JUnitCore(); + final long t1 = System.currentTimeMillis(); + final Result result = core.run( computer, TestSuite.class, Class1.class ); + final long t2 = System.currentTimeMillis(); + final long timeSpent = t2 - t1; assertThat( computer.getSuites().size(), is( 1 ) ); assertThat( computer.getClasses().size(), is( 1 ) ); @@ -197,8 +203,11 @@ public class ParallelComputerBuilderTest assertFalse( parallelComputerBuilder.isOptimized() ); ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - Result result = new JUnitCore().run( computer, TestSuite.class, Class1.class ); - long timeSpent = stopwatch.runtime( MILLISECONDS ); + final JUnitCore core = new JUnitCore(); + final long t1 = System.currentTimeMillis(); + final Result result = core.run( computer, TestSuite.class, Class1.class ); + final long t2 = System.currentTimeMillis(); + final long timeSpent = t2 - t1; assertThat( computer.getSuites().size(), is( 1 ) ); assertThat( computer.getClasses().size(), is( 1 ) ); @@ -229,8 +238,11 @@ public class ParallelComputerBuilderTest assertFalse( parallelComputerBuilder.isOptimized() ); ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - Result result = new JUnitCore().run( computer, TestSuite.class ); - long timeSpent = stopwatch.runtime( MILLISECONDS ); + final JUnitCore core = new JUnitCore(); + final long t1 = System.currentTimeMillis(); + final Result result = core.run( computer, TestSuite.class ); + final long t2 = System.currentTimeMillis(); + final long timeSpent = t2 - t1; assertThat( computer.getSuites().size(), is( 1 ) ); assertThat( computer.getClasses().size(), is( 0 ) ); @@ -253,8 +265,11 @@ public class ParallelComputerBuilderTest assertFalse( parallelComputerBuilder.isOptimized() ); ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - Result result = new JUnitCore().run( computer, TestSuite.class ); - long timeSpent = stopwatch.runtime( MILLISECONDS ); + final JUnitCore core = new JUnitCore(); + final long t1 = System.currentTimeMillis(); + final Result result = core.run( computer, TestSuite.class ); + final long t2 = System.currentTimeMillis(); + final long timeSpent = t2 - t1; assertThat( computer.getSuites().size(), is( 1 ) ); assertThat( computer.getClasses().size(), is( 0 ) ); @@ -280,8 +295,11 @@ public class ParallelComputerBuilderTest // 2 groups with 3 threads. // Each group takes 0.5s. ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - Result result = new JUnitCore().run( computer, TestSuite.class, Class1.class ); - long timeSpent = stopwatch.runtime( MILLISECONDS ); + final JUnitCore core = new JUnitCore(); + final long t1 = System.currentTimeMillis(); + final Result result = core.run( computer, TestSuite.class, Class1.class ); + final long t2 = System.currentTimeMillis(); + final long timeSpent = t2 - t1; assertThat( computer.getSuites().size(), is( 1 ) ); assertThat( computer.getClasses().size(), is( 1 ) ); @@ -304,8 +322,11 @@ public class ParallelComputerBuilderTest assertFalse( parallelComputerBuilder.isOptimized() ); ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer(); - Result result = new JUnitCore().run( computer, TestSuite.class, Class1.class ); - long timeSpent = stopwatch.runtime( MILLISECONDS ); + final JUnitCore core = new JUnitCore(); + final long t1 = System.currentTimeMillis(); + final Result result = core.run( computer, TestSuite.class, Class1.class ); + final long t2 = System.currentTimeMillis(); + final long timeSpent = t2 - t1; assertThat( computer.getSuites().size(), is( 1 ) ); assertThat( computer.getClasses().size(), is( 1 ) ); @@ -321,8 +342,10 @@ public class ParallelComputerBuilderTest @Test( timeout = 2000 ) public void shutdown() { - Result result = new ShutdownTest().run( false ); - long timeSpent = stopwatch.runtime( MILLISECONDS ); + final long t1 = System.currentTimeMillis(); + final Result result = new ShutdownTest().run( false ); + final long t2 = System.currentTimeMillis(); + final long timeSpent = t2 - t1; assertTrue( result.wasSuccessful() ); assertTrue( beforeShutdown ); assertThat( timeSpent, between( 450, 1250 ) ); @@ -331,8 +354,10 @@ public class ParallelComputerBuilderTest @Test( timeout = 2000 ) public void shutdownWithInterrupt() { + final long t1 = System.currentTimeMillis(); new ShutdownTest().run( true ); - long timeSpent = stopwatch.runtime( MILLISECONDS ); + final long t2 = System.currentTimeMillis(); + final long timeSpent = t2 - t1; assertTrue( beforeShutdown ); assertThat( timeSpent, between( 450, 1250 ) ); } @@ -717,11 +742,12 @@ public class ParallelComputerBuilderTest public static class ReportOneTestAtRuntimeRunner extends ParentRunner { - private final Class testClass; + private final Class testClass; private final Description suiteDescription; private Description myTestMethodDescr; - public ReportOneTestAtRuntimeRunner( Class testClass ) throws InitializationError + @SuppressWarnings( "unchecked" ) + public ReportOneTestAtRuntimeRunner( Class testClass ) throws InitializationError { super( Object.class ); this.testClass = testClass; http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java index e41dbaa..df6ca1c 100644 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java +++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java @@ -32,7 +32,6 @@ import org.junit.experimental.theories.DataPoint; import org.junit.experimental.theories.Theories; import org.junit.experimental.theories.Theory; import org.junit.rules.ExpectedException; -import org.junit.rules.Stopwatch; import org.junit.runner.JUnitCore; import org.junit.runner.Result; import org.junit.runner.RunWith; @@ -46,7 +45,6 @@ import static org.apache.maven.surefire.junitcore.pc.ParallelComputerUtil.*; import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.*; import static org.hamcrest.core.Is.is; import static org.junit.Assert.*; -import static java.util.concurrent.TimeUnit.MILLISECONDS; /** * Testing an algorithm in {@link ParallelComputerUtil} which configures @@ -70,9 +68,6 @@ public final class ParallelComputerUtilTest @Rule public final ExpectedException exception = ExpectedException.none(); - @Rule - public final Stopwatch stopwatch = new Stopwatch() {}; - @BeforeClass public static void beforeClass() { @@ -968,7 +963,6 @@ public final class ParallelComputerUtilTest @Test public void withoutShutdown() - throws TestSetFailedException, ExecutionException, InterruptedException { Map properties = new HashMap(); properties.put(PARALLEL_KEY, "methods"); @@ -976,9 +970,12 @@ public final class ParallelComputerUtilTest JUnitCoreParameters params = new JUnitCoreParameters( properties ); ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( logger, params ); ParallelComputer pc = pcBuilder.buildComputer(); - Result result = new JUnitCore().run( pc, TestClass.class ); - long timeSpent = stopwatch.runtime( MILLISECONDS ); - long deltaTime = 500L; + final JUnitCore core = new JUnitCore(); + final long t1 = System.currentTimeMillis(); + final Result result = core.run( pc, TestClass.class ); + final long t2 = System.currentTimeMillis(); + long timeSpent = t2 - t1; + final long deltaTime = 500L; assertTrue( result.wasSuccessful() ); assertThat( result.getRunCount(), is( 3 ) ); @@ -989,7 +986,7 @@ public final class ParallelComputerUtilTest @Test public void shutdown() - throws TestSetFailedException, ExecutionException, InterruptedException + throws TestSetFailedException { // The JUnitCore returns after 2.5s. // The test-methods in TestClass are NOT interrupted, and return normally after 5s. @@ -1000,9 +997,12 @@ public final class ParallelComputerUtilTest JUnitCoreParameters params = new JUnitCoreParameters( properties ); ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( logger, params ); ParallelComputer pc = pcBuilder.buildComputer(); - new JUnitCore().run( pc, TestClass.class ); - long timeSpent = stopwatch.runtime( MILLISECONDS ); - long deltaTime = 500L; + final JUnitCore core = new JUnitCore(); + final long t1 = System.currentTimeMillis(); + core.run( pc, TestClass.class ); + final long t2 = System.currentTimeMillis(); + final long timeSpent = t2 - t1; + final long deltaTime = 500L; assertEquals( 5000L, timeSpent, deltaTime ); String description = pc.describeElapsedTimeout(); @@ -1013,19 +1013,22 @@ public final class ParallelComputerUtilTest @Test public void forcedShutdown() - throws TestSetFailedException, ExecutionException, InterruptedException + throws TestSetFailedException { // The JUnitCore returns after 2.5s, and the test-methods in TestClass are interrupted. Map properties = new HashMap(); properties.put(PARALLEL_KEY, "methods"); properties.put(THREADCOUNTMETHODS_KEY, "2"); - properties.put(PARALLEL_TIMEOUTFORCED_KEY, Double.toString(2.5d)); + properties.put(PARALLEL_TIMEOUTFORCED_KEY, Double.toString( 2.5d )); JUnitCoreParameters params = new JUnitCoreParameters( properties ); ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( logger, params ); ParallelComputer pc = pcBuilder.buildComputer(); - new JUnitCore().run( pc, TestClass.class ); - long timeSpent = stopwatch.runtime( MILLISECONDS ); - long deltaTime = 500L; + final JUnitCore core = new JUnitCore(); + final long t1 = System.currentTimeMillis(); + core.run( pc, TestClass.class ); + final long t2 = System.currentTimeMillis(); + final long timeSpent = t2 - t1; + final long deltaTime = 500L; assertEquals( 2500L, timeSpent, deltaTime ); String description = pc.describeElapsedTimeout(); @@ -1036,7 +1039,7 @@ public final class ParallelComputerUtilTest @Test public void timeoutAndForcedShutdown() - throws TestSetFailedException, ExecutionException, InterruptedException + throws TestSetFailedException { // The JUnitCore returns after 3.5s and the test-methods in TestClass are timed out after 2.5s. // No new test methods are scheduled for execution after 2.5s. @@ -1044,14 +1047,17 @@ public final class ParallelComputerUtilTest Map properties = new HashMap(); properties.put(PARALLEL_KEY, "methods"); properties.put(THREADCOUNTMETHODS_KEY, "2"); - properties.put(PARALLEL_TIMEOUT_KEY, Double.toString(2.5d)); - properties.put(PARALLEL_TIMEOUTFORCED_KEY, Double.toString(3.5d)); + properties.put(PARALLEL_TIMEOUT_KEY, Double.toString( 2.5d )); + properties.put(PARALLEL_TIMEOUTFORCED_KEY, Double.toString( 3.5d )); JUnitCoreParameters params = new JUnitCoreParameters( properties ); ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( logger, params ); ParallelComputer pc = pcBuilder.buildComputer(); - new JUnitCore().run( pc, TestClass.class ); - long timeSpent = stopwatch.runtime( MILLISECONDS ); - long deltaTime = 500L; + final JUnitCore core = new JUnitCore(); + final long t1 = System.currentTimeMillis(); + core.run( pc, TestClass.class ); + final long t2 = System.currentTimeMillis(); + final long timeSpent = t2 - t1; + final long deltaTime = 500L; assertEquals( 3500L, timeSpent, deltaTime ); String description = pc.describeElapsedTimeout(); @@ -1073,9 +1079,12 @@ public final class ParallelComputerUtilTest JUnitCoreParameters params = new JUnitCoreParameters( properties ); ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( logger, params ); ParallelComputer pc = pcBuilder.buildComputer(); - new JUnitCore().run( pc, TestClass.class ); - long timeSpent = stopwatch.runtime( MILLISECONDS ); - long deltaTime = 500L; + final JUnitCore core = new JUnitCore(); + final long t1 = System.currentTimeMillis(); + core.run( pc, TestClass.class ); + final long t2 = System.currentTimeMillis(); + final long timeSpent = t2 - t1; + final long deltaTime = 500L; assertEquals( 3500L, timeSpent, deltaTime ); String description = pc.describeElapsedTimeout(); http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-report-parser/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-report-parser/pom.xml b/surefire-report-parser/pom.xml index 60d570f..c91a9ed 100644 --- a/surefire-report-parser/pom.xml +++ b/surefire-report-parser/pom.xml @@ -54,16 +54,18 @@ maven-surefire-plugin - - true - org.apache.maven.surefire - surefire-junit47 - 2.12.4 + surefire-shadefire + 2.12.4 + + + **/JUnit4SuiteTest.java + + http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/eb210e08/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/JUnit4SuiteTest.java ---------------------------------------------------------------------- diff --git a/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/JUnit4SuiteTest.java b/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/JUnit4SuiteTest.java new file mode 100644 index 0000000..142ca9d --- /dev/null +++ b/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/JUnit4SuiteTest.java @@ -0,0 +1,46 @@ +package org.apache.maven.plugins.surefire.report; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.JUnit4TestAdapter; +import junit.framework.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Adapt the JUnit4 tests which use only annotations to the JUnit3 test suite. + * + * @author Tibor Digana (tibor17) + * @since 2.21.0 + */ +@Suite.SuiteClasses( { + ReportTestCaseTest.class, + ReportTestSuiteTest.class, + SurefireReportParserTest.class, + TestSuiteXmlParserTest.class +} ) +@RunWith( Suite.class ) +public class JUnit4SuiteTest +{ + public static Test suite() + { + return new JUnit4TestAdapter( JUnit4SuiteTest.class ); + } +}