From 8fb374ceba1832e5beb77f707f5709ae32d04907 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 14 Aug 2020 22:45:11 -0700 Subject: [PATCH] lets have maven fail if those tests fail... --- .../ajde/core/AjdeCoreModuleTests.java | 17 +++-- .../ajde/core/TestBuildProgressMonitor.java | 43 +++++++----- .../aspectj/ajde/core/TestMessageHandler.java | 18 ++--- .../ui/utils/TestBuildProgressMonitor.java | 65 ++++++++++++------- testing-drivers/pom.xml | 2 +- tests/pom.xml | 2 +- .../aspectj/systemtest/ajc11/Ajc11Tests.java | 1 - .../systemtest/ajc150/Ajc150Tests.java | 1 - .../systemtest/ajc150/GenericITDsDesign.java | 1 - .../ajc152/SynchronizationTransformTests.java | 1 - .../ajc153/JDTLikeHandleProviderTests.java | 1 - .../ajc154/CustomMungerExtensionTest.java | 1 - .../systemtest/ajc161/Ajc161Tests.java | 1 - .../systemtest/ajc164/Ajc164Tests.java | 1 - ...jectIncrementalAjdeInteractionTestbed.java | 1 - .../tools/MoreOutputLocationManagerTests.java | 1 - .../systemtest/java14/Java14Tests.java | 1 - .../systemtest/model/ModelTestCase.java | 1 - .../org/aspectj/tests/TestsModuleTests.java | 1 - 19 files changed, 90 insertions(+), 70 deletions(-) diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreModuleTests.java b/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreModuleTests.java index 0e9991eeb..45d70a845 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreModuleTests.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreModuleTests.java @@ -1,11 +1,11 @@ /******************************************************************** - * Copyright (c) 2007 Contributors. All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation + * Copyright (c) 2007 Contributors. All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation * Helen Hawkins - initial version *******************************************************************/ package org.aspectj.ajde.core; @@ -30,6 +30,8 @@ import junit.framework.TestSuite; public class AjdeCoreModuleTests extends TestCase { + static boolean verbose = System.getProperty("aspectj.tests.verbose", "false").equalsIgnoreCase("true"); + public static TestSuite suite() { TestSuite suite = new TestSuite(AjdeCoreModuleTests.class.getName()); suite.addTestSuite(ShowWeaveMessagesTest.class); @@ -49,6 +51,7 @@ public class AjdeCoreModuleTests extends TestCase { return suite; } + public AjdeCoreModuleTests(String name) { super(name); } diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java b/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java index 5269a586a..e25632cf9 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java @@ -20,7 +20,6 @@ import java.util.List; */ public class TestBuildProgressMonitor implements IBuildProgressMonitor { - private static boolean verbose = System.getProperty("aspectj.tests.verbose","false").equalsIgnoreCase("true"); private static boolean debugTests = false; public int numWovenClassMessages = 0; @@ -34,31 +33,43 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { private boolean isCancelRequested = false; public void finish(boolean wasFullBuild) { - System.out.println("build finished. Was full build: " + wasFullBuild); + info("build finished. Was full build: " + wasFullBuild); } public boolean isCancelRequested() { return isCancelRequested; } + private void info(String message) { + if (AjdeCoreModuleTests.verbose) { + System.out.println(message); + } + } + public void setProgress(double percentDone) { - System.out.println("progress. Completed " + percentDone + " percent"); + info("progress. Completed " + percentDone + " percent"); } public void setProgressText(String text) { - if (verbose) { - System.out.println("progress text: " + text); - } + info("progress text: " + text); String newText = text+" [Percentage="+currentVal+"%]"; messagesReceived.add(newText); - if (text.startsWith("woven aspect ")) numWovenAspectMessages++; - if (text.startsWith("woven class ")) numWovenClassMessages++; - if (text.startsWith("compiled:")) numCompiledMessages++; + if (text.startsWith("woven aspect ")) { + numWovenAspectMessages++; + } + if (text.startsWith("woven class ")) { + numWovenClassMessages++; + } + if (text.startsWith("compiled:")) { + numCompiledMessages++; + } if (programmableString != null && text.contains(programmableString)) { count--; if (count==0) { - if (debugTests) System.out.println("Just got message '"+newText+"' - asking build to cancel"); + if (debugTests) { + System.out.println("Just got message '"+newText+"' - asking build to cancel"); + } isCancelRequested = true; programmableString = null; } @@ -66,9 +77,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { } public void begin() { - if (verbose) { - System.out.println("build started"); - } + info("build started"); currentVal = 0; } @@ -81,15 +90,15 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { public boolean containsMessage(String prefix,String distinguishingMarks) { for (String element: messagesReceived) { if (element.startsWith(prefix) && - element.contains(distinguishingMarks)) return true; + element.contains(distinguishingMarks)) { + return true; + } } return false; } public void dumpMessages() { - if (verbose) { - System.out.println("ProgressMonitorMessages"); - } + System.out.println("ProgressMonitorMessages"); for (String element: messagesReceived) { System.out.println(element); } diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/TestMessageHandler.java b/ajde.core/src/test/java/org/aspectj/ajde/core/TestMessageHandler.java index 662971cfe..8b707d1b7 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/TestMessageHandler.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/TestMessageHandler.java @@ -1,11 +1,11 @@ /******************************************************************** - * Copyright (c) 2007 Contributors. All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation + * Copyright (c) 2007 Contributors. All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation * Helen Hawkins - initial version *******************************************************************/ package org.aspectj.ajde.core; @@ -50,7 +50,9 @@ public class TestMessageHandler implements IBuildMessageHandler { } else if (kind.equals(IMessage.ERROR)) { errors.add(t); } - System.out.println("> " + message); //$NON-NLS-1$ + if (AjdeCoreModuleTests.verbose) { + System.out.println("> " + message); //$NON-NLS-1$ + } return true; } diff --git a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java index 09d794191..ef70388ad 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java +++ b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java @@ -1,17 +1,16 @@ /******************************************************************** - * Copyright (c) 2007 Contributors. All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation + * Copyright (c) 2007 Contributors. All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation * Helen Hawkins - initial version (bug 148190) *******************************************************************/ package org.aspectj.ajde.ui.utils; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.aspectj.ajde.core.IBuildProgressMonitor; @@ -23,20 +22,24 @@ import org.aspectj.ajde.core.IBuildProgressMonitor; */ public class TestBuildProgressMonitor implements IBuildProgressMonitor { + private final static boolean verbose = System.getProperty("aspectj.tests.verbose", "true") + .equalsIgnoreCase("false"); private static boolean debugTests = false; - + public int numWovenClassMessages = 0; public int numWovenAspectMessages = 0; public int numCompiledMessages = 0; - + private String programmableString; private int count; - private List messagesReceived = new ArrayList(); + private List messagesReceived = new ArrayList<>(); private int currentVal; private boolean isCancelRequested = false; - + public void finish(boolean wasFullBuild) { - System.out.println("build finished. Was full build: " + wasFullBuild); + if (verbose) { + System.out.println("build finished. Was full build: " + wasFullBuild); + } } public boolean isCancelRequested() { @@ -44,21 +47,33 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { } public void setProgress(double percentDone) { - System.out.println("progress. Completed " + percentDone + " percent"); + if (verbose) { + System.out.println("progress. Completed " + percentDone + " percent"); + } } public void setProgressText(String text) { - System.out.println("progress text: " + text); + if (verbose) { + System.out.println("progress text: " + text); + } String newText = text+" [Percentage="+currentVal+"%]"; messagesReceived.add(newText); - if (text.startsWith("woven aspect ")) numWovenAspectMessages++; - if (text.startsWith("woven class ")) numWovenClassMessages++; - if (text.startsWith("compiled:")) numCompiledMessages++; + if (text.startsWith("woven aspect ")) { + numWovenAspectMessages++; + } + if (text.startsWith("woven class ")) { + numWovenClassMessages++; + } + if (text.startsWith("compiled:")) { + numCompiledMessages++; + } if (programmableString != null && text.contains(programmableString)) { count--; if (count==0) { - if (debugTests) System.out.println("Just got message '"+newText+"' - asking build to cancel"); + if (debugTests) { + System.out.println("Just got message '"+newText+"' - asking build to cancel"); + } isCancelRequested = true; programmableString = null; } @@ -66,7 +81,9 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { } public void begin() { - System.out.println("build started"); + if (verbose) { + System.out.println("build started"); + } currentVal = 0; } @@ -75,16 +92,18 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { programmableString = string; this.count = count; } - + public boolean containsMessage(String prefix,String distinguishingMarks) { for (Object o : messagesReceived) { String element = (String) o; if (element.startsWith(prefix) && - element.contains(distinguishingMarks)) return true; + element.contains(distinguishingMarks)) { + return true; + } } return false; } - + public void dumpMessages() { System.out.println("ProgressMonitorMessages"); for (Object o : messagesReceived) { diff --git a/testing-drivers/pom.xml b/testing-drivers/pom.xml index 84593580c..e93bb57ff 100644 --- a/testing-drivers/pom.xml +++ b/testing-drivers/pom.xml @@ -80,7 +80,7 @@ org.apache.maven.plugins maven-surefire-plugin - true + false **/*AjcTestSpecAsTest* diff --git a/tests/pom.xml b/tests/pom.xml index e3f7700ab..dac9a25f6 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -138,7 +138,7 @@ org.apache.maven.plugins maven-surefire-plugin - true + false **/TestsModuleTests* diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc11/Ajc11Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc11/Ajc11Tests.java index 47c64f2f5..5bbfbfbdf 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc11/Ajc11Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc11/Ajc11Tests.java @@ -10,7 +10,6 @@ package org.aspectj.systemtest.ajc11; import org.aspectj.testing.XMLBasedAjcTestCase; -import org.aspectj.util.LangUtil; import junit.framework.Test; diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java index 62e96d0df..87950db0a 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -19,7 +19,6 @@ import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.apache.bcel.classfile.Signature; import org.aspectj.asm.AsmManager; import org.aspectj.testing.XMLBasedAjcTestCase; -import org.aspectj.util.LangUtil; import junit.framework.Test; diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericITDsDesign.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericITDsDesign.java index 210f5f44d..fd3152558 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericITDsDesign.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericITDsDesign.java @@ -2,7 +2,6 @@ package org.aspectj.systemtest.ajc150; import java.io.File; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; import org.aspectj.apache.bcel.classfile.Attribute; diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java index 8c277a906..e05662ce8 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java @@ -18,7 +18,6 @@ import java.io.FileReader; import java.io.PrintStream; import java.net.URL; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.aspectj.apache.bcel.classfile.JavaClass; diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java index b728b8862..6fa9818ae 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java @@ -12,7 +12,6 @@ package org.aspectj.systemtest.ajc153; import java.io.IOException; import java.net.URL; -import java.util.Iterator; import java.util.List; import org.aspectj.asm.AsmManager; diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java b/tests/src/test/java/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java index 4f50cefca..9482c921e 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java @@ -15,7 +15,6 @@ package org.aspectj.systemtest.ajc154; import java.io.File; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; import java.util.List; import java.util.Map; diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java index 621c1917c..8641fcb26 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.aspectj.systemtest.ajc161; -import java.util.Iterator; import java.util.Set; import org.aspectj.asm.AsmManager; diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc164/Ajc164Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc164/Ajc164Tests.java index 1b1181535..c8f6e58b9 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc164/Ajc164Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc164/Ajc164Tests.java @@ -11,7 +11,6 @@ package org.aspectj.systemtest.ajc164; import java.io.PrintWriter; -import java.util.Iterator; import java.util.List; import org.aspectj.apache.bcel.classfile.LocalVariable; diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java index 1b8e5c69a..dd340c770 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java @@ -23,7 +23,6 @@ import java.io.PrintWriter; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Set; diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java index 3c13ccb71..dc19e2993 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java @@ -14,7 +14,6 @@ import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; diff --git a/tests/src/test/java/org/aspectj/systemtest/java14/Java14Tests.java b/tests/src/test/java/org/aspectj/systemtest/java14/Java14Tests.java index aa9531979..f0e65acd2 100644 --- a/tests/src/test/java/org/aspectj/systemtest/java14/Java14Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/java14/Java14Tests.java @@ -10,7 +10,6 @@ package org.aspectj.systemtest.java14; import org.aspectj.testing.XMLBasedAjcTestCase; -import org.aspectj.util.LangUtil; import junit.framework.Test; diff --git a/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java b/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java index c0cf11977..b18d9a5f7 100644 --- a/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java +++ b/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java @@ -15,7 +15,6 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.aspectj.asm.AsmManager; diff --git a/tests/src/test/java/org/aspectj/tests/TestsModuleTests.java b/tests/src/test/java/org/aspectj/tests/TestsModuleTests.java index b08e42aed..72e31e121 100644 --- a/tests/src/test/java/org/aspectj/tests/TestsModuleTests.java +++ b/tests/src/test/java/org/aspectj/tests/TestsModuleTests.java @@ -1,6 +1,5 @@ package org.aspectj.tests; -import org.aspectj.systemtest.AllTests17; import org.aspectj.systemtest.AllTests18; import org.aspectj.systemtest.AllTests19; import org.aspectj.util.LangUtil; -- 2.39.5