From 884ced970ee8d04bfb89a53ec1a40fcb848db2b6 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Sat, 15 Aug 2020 23:08:40 -0700 Subject: [PATCH] Reduce test output for incremental comp tests --- .../java/org/aspectj/systemtest/AllTests.java | 6 +- .../ajc153/JDTLikeHandleProviderTests.java | 2 - ...jectIncrementalAjdeInteractionTestbed.java | 26 ++++---- .../tools/AjdeInteractionTestbed.java | 14 +++-- .../tools/MultiProjectIncrementalTests.java | 62 ++++++++++--------- 5 files changed, 60 insertions(+), 50 deletions(-) diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests.java b/tests/src/test/java/org/aspectj/systemtest/AllTests.java index 206738dd4..f4cfe4d2c 100644 --- a/tests/src/test/java/org/aspectj/systemtest/AllTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/AllTests.java @@ -4,8 +4,8 @@ * 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://www.eclipse.org/legal/epl-v10.html - * + * http://www.eclipse.org/legal/epl-v10.html + * * ******************************************************************/ package org.aspectj.systemtest; @@ -37,6 +37,8 @@ import junit.framework.TestSuite; */ public class AllTests { + public final static boolean VERBOSE = System.getProperty("aspectj.tests.verbose", "true").equals("true"); + public static Test suite() { TestSuite suite = new TestSuite("AspectJ System Test Suite - JDK 1.3"); //$JUnit-BEGIN$ 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 6fa9818ae..2f473957e 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java @@ -535,8 +535,6 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); IProgramElement pe = top.findElementForLabel(top.getRoot(), kind, ipeName); String found = pe.getHandleIdentifier(); - System.err.println("expected: " + expectedHandle); - System.err.println("actual: " + found); assertEquals("handleIdentifier - expected " + expectedHandle + ", but found " + found, expectedHandle, found); } 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 0c864c850..0a6538ef9 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 @@ -1,11 +1,11 @@ /******************************************************************** - * Copyright (c) 2006 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: + * Copyright (c) 2006 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: * Adrian Colyer initial implementation * Helen Hawkins Converted to new interface (bug 148190) *******************************************************************/ @@ -97,7 +97,7 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeI File projDir = new File(getWorkingDir(), p); return new File(projDir, "bin" + File.separator + filename); } - + public void build(String projectName) { constructUpToDateLstFile(projectName, "build.lst"); doBuild(projectName); @@ -266,10 +266,12 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeI /** @return the number of relationship pairs */ protected void printModel(String projectName) throws Exception { - dumptree(getModelFor(projectName).getHierarchy().getRoot(), 0); - PrintWriter pw = new PrintWriter(System.out); - getModelFor(projectName).dumprels(pw); - pw.flush(); + if (AjdeInteractionTestbed.VERBOSE) { + dumptree(getModelFor(projectName).getHierarchy().getRoot(), 0); + PrintWriter pw = new PrintWriter(System.out); + getModelFor(projectName).dumprels(pw); + pw.flush(); + } } protected File getProjectRelativePath(String p, String filename) { diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java index adf4484bf..9e6f9d0a1 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java @@ -329,13 +329,15 @@ public class AjdeInteractionTestbed extends TestCase { * Make sure no errors have been recorded */ private void checkForErrors(AjCompiler compiler) { - MultiProjTestMessageHandler handler = (MultiProjTestMessageHandler) compiler.getMessageHandler(); - if (handler.hasErrorMessages()) { - System.err.println("Build errors:"); - for (IMessage message: handler.getErrorMessages()) { - System.err.println(message); + if (AjdeInteractionTestbed.VERBOSE) { + MultiProjTestMessageHandler handler = (MultiProjTestMessageHandler) compiler.getMessageHandler(); + if (handler.hasErrorMessages()) { + System.err.println("Build errors:"); + for (IMessage message : handler.getErrorMessages()) { + System.err.println(message); + } + System.err.println("---------"); } - System.err.println("---------"); } } diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index b3da88d0c..968c37ae0 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -4,7 +4,7 @@ * 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: * Andy Clement initial implementation * Helen Hawkins Converted to new interface (bug 148190) @@ -57,7 +57,7 @@ import org.aspectj.weaver.World; * overlays for incremental builds, that is in here. As is the ability to generate valid build configs based on a directory * structure. To support this we just need access to a sandbox directory - this sandbox is managed by the superclass (it only * assumes all builds occur in // ) - * + * * The idea is you can initialize multiple projects in the sandbox and they can all be built independently, hopefully exploiting * incremental compilation. Between builds you can alter the contents of a project using the alter() method that overlays some set * of new files onto the current set (adding new files/changing existing ones) - you can then drive a new build and check it behaves @@ -106,8 +106,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa checkWasFullBuild(); // Should both indicate that Location cannot be resolved assertEquals(2,getErrorMessages(p).size()); - } - + } + public void testIncrementalITDInners4() throws Exception { String p = "prInner4"; initialiseProject(p); @@ -174,7 +174,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa * public void testIncrementalAspectWhitespace() throws Exception { AjdeInteractionTestbed.VERBOSE = true; String p = "xxx"; * initialiseProject(p); configureNonStandardCompileOptions(p, "-showWeaveInfo"); configureShowWeaveInfoMessages(p, true); * build(p); - * + * * List weaveMessages = getWeavingMessages(p); if (weaveMessages.size() != 0) { for (Iterator iterator = * weaveMessages.iterator(); iterator.hasNext();) { Object object = iterator.next(); System.out.println(object); } } * checkWasFullBuild(); assertNoErrors(p); alter(p, "inc1"); build(p); checkWasntFullBuild(); assertNoErrors(p); } @@ -681,7 +681,9 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa String p = "pr278255"; initialiseProject(p); build(p); - printModelAndRelationships(p); + if (AjdeInteractionTestbed.VERBOSE) { + printModelAndRelationships(p); + } IRelationshipMap irm = getModelFor(p).getRelationshipMap(); List l = irm.get("=pr278255<{A.java'X`declare \\@type"); assertNotNull(l); @@ -959,10 +961,10 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa /* * A.aj package pack; public aspect A { pointcut p() : call( C.method before() : p() { // line 7 } } - * + * * C.java package pack; public class C { public void method1() { method2(); // line 6 } public void method2() { } public void * method3() { method2(); // line 13 } - * + * * } */ public void testDontLoseAdviceMarkers_pr134471() { @@ -970,14 +972,18 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false; initialiseProject("P4"); build("P4"); - Ajc.dumpAJDEStructureModel(getModelFor("P4"), "after full build where advice is applying"); + if (AjdeInteractionTestbed.VERBOSE) { + Ajc.dumpAJDEStructureModel(getModelFor("P4"), "after full build where advice is applying"); + } // should be 4 relationship entries // In inc1 the first advised line is 'commented out' alter("P4", "inc1"); build("P4"); checkWasntFullBuild(); - Ajc.dumpAJDEStructureModel(getModelFor("P4"), "after inc build where first advised line is gone"); + if (AjdeInteractionTestbed.VERBOSE) { + Ajc.dumpAJDEStructureModel(getModelFor("P4"), "after inc build where first advised line is gone"); + } // should now be 2 relationship entries // This will be the line 6 entry in C.java @@ -1240,7 +1246,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa /* * public void testGenericITD_pr262257() throws IOException { String p = "pr262257"; initialiseProject(p); build(p); * checkWasFullBuild(); - * + * * dumptree(getModelFor(p).getHierarchy().getRoot(), 0); PrintWriter pw = new PrintWriter(System.out); * getModelFor(p).dumprels(pw); pw.flush(); } */ @@ -1850,11 +1856,11 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa */ /* * public void testProblemCopyingResources_pr138171() { initialiseProject("PR138171"); - * + * * File f=getProjectRelativePath("PR138171","res.txt"); Map m = new HashMap(); m.put("res.txt",f); * AjdeInteractionTestbed.MyProjectPropertiesAdapter .getInstance().setSourcePathResources(m); build("PR138171"); File f2 = * getProjectOutputRelativePath("PR138171","res.txt"); boolean successful = f2.setReadOnly(); - * + * * alter("PR138171","inc1"); AjdeInteractionTestbed.MyProjectPropertiesAdapter .getInstance().setSourcePathResources(m); * build("PR138171"); List msgs = MyTaskListManager.getErrorMessages(); assertTrue("there should be one message but there are " * +(msgs==null?0:msgs.size())+":\n"+msgs,msgs!=null && msgs.size()==1); IMessage msg = (IMessage)msgs.get(0); String exp = @@ -1906,7 +1912,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("P2"); checkWasntFullBuild(); } - + public void testBuildingBrokenCode_pr240360() { initialiseProject("pr240360"); // configureNonStandardCompileOptions("pr240360","-proceedOnError"); @@ -2361,7 +2367,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa /** * The C.java file modified in this test has an inner class - this means the inner class has a this$0 field and (C) ctor * to watch out for when checking for structural changes - * + * */ public void testStateManagement3() { File binDirForInterproject1 = new File(getFile("interprojectdeps1", "bin")); @@ -2386,7 +2392,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa /** * The C.java file modified in this test has an inner class - which has two ctors - this checks how they are mangled with an * instance of C. - * + * */ public void testStateManagement4() { File binDirForInterproject2 = new File(getFile("interprojectdeps2", "bin")); @@ -2411,7 +2417,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa /** * The C.java file modified in this test has an inner class - it has two ctors but also a reference to C.this in it - which will * give rise to an accessor being created in C - * + * */ public void testStateManagement5() { File binDirForInterproject3 = new File(getFile("interprojectdeps3", "bin")); @@ -2959,37 +2965,37 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa * public void testPrReducingDependentBuilds_001_221427() { AjdeInteractionTestbed.VERBOSE=true; * IncrementalStateManager.debugIncrementalStates=true; initialiseProject("P221427_1"); initialiseProject("P221427_2"); * configureNewProjectDependency("P221427_2","P221427_1"); - * + * * build("P221427_1"); build("P221427_2"); alter("P221427_1","inc1"); // rename private class in super project * MyStateListener.reset(); build("P221427_1"); build("P221427_2"); - * + * * AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("P221427_1","bin"))); * assertTrue("There should be state for project P221427_1",ajs!=null); * //System.out.println(MyStateListener.getInstance().getDecisions()); checkWasntFullBuild(); * assertTrue("Should be one structural change but there were "+ ajs.getNumberOfStructuralChangesSinceLastFullBuild(), * ajs.getNumberOfStructuralChangesSinceLastFullBuild()==1); - * + * * } - * + * * // Case002: changing a class to final that is extended in a dependent project public void * testPrReducingDependentBuilds_002_221427() { AjdeInteractionTestbed.VERBOSE=true; * IncrementalStateManager.debugIncrementalStates=true; initialiseProject("P221427_3"); initialiseProject("P221427_4"); * configureNewProjectDependency("P221427_4","P221427_3"); - * + * * build("P221427_3"); build("P221427_4"); // build OK, type in super project is non-final alter("P221427_3","inc1"); // change * class declaration in super-project to final MyStateListener.reset(); build("P221427_3"); build("P221427_4"); // build FAIL, * type in super project is now final - * + * * AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("P221427_3","bin"))); * assertTrue("There should be state for project P221427_3",ajs!=null); * System.out.println(MyStateListener.getInstance().getDecisions()); - * + * * List errors = getErrorMessages("P221427_4"); if (errors.size()!=1) { if (errors.size()==0) * fail("Expected error about not being able to extend final class"); for (Iterator iterator = errors.iterator(); * iterator.hasNext();) { Object object = (Object) iterator.next(); System.out.println(object); } * fail("Expected 1 error but got "+errors.size()); } // assertTrue("Shouldn't be one structural change but there were "+ // * ajs.getNumberOfStructuralChangesSinceLastFullBuild(), // ajs.getNumberOfStructuralChangesSinceLastFullBuild()==1); - * + * * } */ // test for comment #6 - simulates AJDT core builder test testBug99133a - @@ -3553,7 +3559,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("PR154054"); checkWasntFullBuild(); } - + public void testIncrementalBuildAdviceChange_456801() throws Exception { initialiseProject("456801"); build("456801"); @@ -3885,7 +3891,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa /** * Retrieve program elements related to this one regardless of the relationship. A JUnit assertion is made that the number that * the 'expected' number are found. - * + * * @param programElement Program element whose related elements are to be found * @param expected the number of expected related elements */ @@ -3936,7 +3942,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } } List kids = ipe.getChildren(); - for (IProgramElement kid: kids) { + for (IProgramElement kid: kids) { IProgramElement found = findAdvice(kid, whichOne); if (found != null) { return found; -- 2.39.5