Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C0D07200C1D for ; Thu, 2 Feb 2017 04:17:09 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id BF778160B63; Thu, 2 Feb 2017 03:17:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E7014160B46 for ; Thu, 2 Feb 2017 04:17:08 +0100 (CET) Received: (qmail 33315 invoked by uid 500); 2 Feb 2017 03:17:08 -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 33291 invoked by uid 99); 2 Feb 2017 03:17:07 -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; Thu, 02 Feb 2017 03:17:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CB932DFBDA; Thu, 2 Feb 2017 03:17:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: schulte@apache.org To: commits@maven.apache.org Date: Thu, 02 Feb 2017 03:17:07 -0000 Message-Id: <65a81e55f5e647ccaadd00d7cfe86856@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/5] maven-integration-testing git commit: Provide a mechanism whereby tests can indicate versions of Maven expected to fail [Forced Update!] archived-at: Thu, 02 Feb 2017 03:17:09 -0000 Repository: maven-integration-testing Updated Branches: refs/heads/DEPMGMT-IMPORT 11c330f9c -> e8745ea46 (forced update) Provide a mechanism whereby tests can indicate versions of Maven expected to fail - This will let us fix broken tests while confirming that the versions of Maven that were released using the broken test contain the bug that escaped the broken test Project: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/commit/92a11a96 Tree: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/tree/92a11a96 Diff: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/diff/92a11a96 Branch: refs/heads/DEPMGMT-IMPORT Commit: 92a11a96877c275d90d3502ff1df70c637850f6c Parents: 63bb518 Author: Stephen Connolly Authored: Wed Feb 1 22:30:25 2017 +0000 Committer: Stephen Connolly Committed: Wed Feb 1 22:30:25 2017 +0000 ---------------------------------------------------------------------- .../it/AbstractMavenIntegrationTestCase.java | 78 +++++++++++++++++++- 1 file changed, 76 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/92a11a96/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java ---------------------------------------------------------------------- diff --git a/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java b/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java index 8966dce..78c6e63 100644 --- a/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java +++ b/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java @@ -60,6 +60,8 @@ public abstract class AbstractMavenIntegrationTestCase private boolean skip; + private BrokenMavenVersionException invert; + private static ArtifactVersion javaVersion; private ArtifactVersion mavenVersion; @@ -213,11 +215,16 @@ public abstract class AbstractMavenIntegrationTestCase setupLocalRepo(); } + invert = null; long milliseconds = System.currentTimeMillis(); try { super.runTest(); milliseconds = System.currentTimeMillis() - milliseconds; + if ( invert != null ) + { + throw invert; + } out.println( "OK " + formatTime( milliseconds ) ); } catch ( UnsupportedJavaVersionException e ) @@ -230,11 +237,25 @@ public abstract class AbstractMavenIntegrationTestCase out.println( "SKIPPED - Maven version " + e.mavenVersion + " not in range " + e.supportedRange ); return; } + catch ( BrokenMavenVersionException e ) + { + out.println( "UNEXPECTED OK - Maven version " + e.mavenVersion + " expected to fail " + + formatTime( milliseconds ) ); + fail( "Expected failure when with Maven version " + e.mavenVersion ); + } catch ( Throwable t ) { milliseconds = System.currentTimeMillis() - milliseconds; - out.println( "FAILURE " + formatTime( milliseconds ) ); - throw t; + if ( invert != null ) + { + out.println( "EXPECTED FAIL - Maven version " + invert.mavenVersion + " expected to fail " + + formatTime( milliseconds ) ); + } + else + { + out.println( "FAILURE " + formatTime( milliseconds ) ); + throw t; + } } } @@ -300,6 +321,42 @@ public abstract class AbstractMavenIntegrationTestCase } } + /** + * Inverts the execution of a test case for cases where we discovered a bug in the test case, have corrected the + * test case and shipped versions of Maven with a bug because of the faulty test case. This method allows the + * tests to continue passing against the historical releases as they historically would, as well as verifying that + * the test is no longer providing a false positive. + * + * @param versionRange + */ + protected void failingMavenVersions( String versionRange ) + { + assertNull( "Only call failingMavenVersions at most once per test", invert ); + VersionRange range; + try + { + range = VersionRange.createFromVersionSpec( versionRange ); + } + catch ( InvalidVersionSpecificationException e ) + { + throw (RuntimeException) new IllegalArgumentException( "Invalid version range: " + versionRange, e ); + } + + ArtifactVersion version = getMavenVersion(); + if ( version != null ) + { + if ( range.containsVersion( removePattern( version ) ) ) + { + invert = new BrokenMavenVersionException( version, range ); + } + } + else + { + out.println( "WARNING: " + getITName() + ": version range '" + versionRange + + "' supplied but no Maven version found - not marking test as expected to fail." ); + } + } + private class UnsupportedJavaVersionException extends RuntimeException { @@ -334,6 +391,23 @@ public abstract class AbstractMavenIntegrationTestCase } + private class BrokenMavenVersionException + extends RuntimeException + { + @SuppressWarnings( "checkstyle:visibilitymodifier" ) + public ArtifactVersion mavenVersion; + + @SuppressWarnings( "checkstyle:visibilitymodifier" ) + public VersionRange supportedRange; + + public BrokenMavenVersionException( ArtifactVersion mavenVersion, VersionRange supportedRange ) + { + this.mavenVersion = mavenVersion; + this.supportedRange = supportedRange; + } + + } + private String getITName() { String simpleName = getClass().getName();