From: Andy Clement
Date: Thu, 13 Aug 2020 21:24:40 +0000 (-0700)
Subject: Trying to reduce test verbosity
X-Git-Tag: V1_9_7M1~26
X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1e2096910fc68c01f0be634721020ceee88d797c;p=aspectj.git
Trying to reduce test verbosity
---
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index ebfdd0a30..9aae7dbf9 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -23,4 +23,4 @@ jobs:
with:
java-version: ${{ matrix.java }}
- name: Build with Maven
- run: mvn -B package --file pom.xml
+ run: mvn -Dorg.aspectj.tools.ajc.Ajc.verbose=false -B package --file pom.xml
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java
index 088ff78f9..ebef7661a 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java
@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2004 IBM Corporation
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Adrian Colyer,
+ * 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Adrian Colyer,
* ******************************************************************/
package org.aspectj.tools.ajc;
@@ -17,12 +17,9 @@ import java.io.FilenameFilter;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
-import junit.framework.AssertionFailedError;
-
import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IProgramElement;
import org.aspectj.asm.IRelationship;
@@ -31,9 +28,9 @@ import org.aspectj.asm.internal.Relationship;
import org.aspectj.bridge.AbortException;
import org.aspectj.bridge.ICommand;
import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.IMessage.Kind;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.MessageHandler;
-import org.aspectj.bridge.IMessage.Kind;
import org.aspectj.bridge.context.CompilationAndWeavingContext;
import org.aspectj.testing.util.TestUtil;
import org.aspectj.util.FileUtil;
@@ -45,13 +42,13 @@ import org.aspectj.util.FileUtil;
* The expected usage of Ajc is through the TestCase superclass, AjcTestCase, which provides helper methods that conveniently drive
* the base functions exposed by this class.
*
- *
+ *
* @see org.aspectj.tools.ajc.AjcTestCase
*/
public class Ajc {
private static final String BUILD_OUTPUT_FOLDER = "target";
-
+
public static final String outputFolder(String module) {
return File.pathSeparator + ".." +File.separator + module + File.separator + "target" + File.separator + "classes";
}
@@ -63,54 +60,54 @@ public class Ajc {
}
return s.toString();
}
-
+
// ALSO SEE ANTSPEC AND AJCTESTCASE
- private static final String TESTER_PATH = outputFolder("testing-client") + outputFolder("runtime") + outputFolder("bcel-builder")
-// + File.pathSeparator + ".." + File.separator + "runtime" + File.separator + BUILD_OUTPUT_FOLDER //
-// + File.pathSeparator + ".." + File.separator + "aspectj5rt" + File.separator + BUILD_OUTPUT_FOLDER //
- + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "junit" + File.separator + "junit.jar" //
-// + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "bcel" + File.separator + "bcel.jar" //
-// + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "bcel" + File.separator
-// + "bcel-verifier.jar" +
-
- + outputFolder("bridge")
- + outputFolder("loadtime")
- + outputFolder("weaver")
- + outputFolder("org.aspectj.matcher")
- + outputFolder("bridge");
-// File.pathSeparator + ".." + File.separator + "bridge" + File.separator + "bin" + File.pathSeparator + ".."
-// + File.separator + "loadtime" + File.separator + "bin" + File.pathSeparator
-// + ".."
-// + File.separator
-// + "weaver"
-// + File.separator
-// + "bin"
-// + File.pathSeparator
-// + ".."
-// + File.separator
-// + "weaver5"
-// + File.separator
-// + "bin"
-// + File.pathSeparator
-// + ".."
-// + File.separator
-// + "org.aspectj.matcher"
-// + File.separator
-// + "bin"
-
- // When the build machine executes the tests, it is using code built into jars rather than code build into
- // bin directories. This means for the necessary types to be found we have to put these jars on the classpath:
-// + File.pathSeparator + ".." + File.separator + "aj-build" + File.separator + "jars" + File.separator + "bridge.jar"
-// + File.pathSeparator + ".." + File.separator + "aj-build" + File.separator + "jars" + File.separator
-// + "org.aspectj.matcher.jar" + File.pathSeparator + ".." + File.separator + "aj-build" + File.separator + "jars"
-// + File.separator + "util.jar" + File.pathSeparator + ".." + File.separator + "aj-build" + File.separator + "jars"
-// + File.separator + "loadtime.jar" + File.pathSeparator + ".." + File.separator + "aj-build" + File.separator + "jars"
-// + File.separator + "weaver.jar" + File.pathSeparator + ".." + File.separator + "aj-build" + File.separator + "jars"
-// + File.separator + "weaver5.jar" + File.pathSeparator + ".." + File.separator + "aj-build" + File.separator + "jars"
-// + File.separator + "asm.jar" + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "test"
-// + File.separator + "testing-client.jar"
-// // hmmm, this next one should perhaps point to an aj-build jar...
-// + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "test" + File.separator + "aspectjrt.jar";
+ private static final String TESTER_PATH = outputFolder("testing-client") + outputFolder("runtime") + outputFolder("bcel-builder")
+ // + File.pathSeparator + ".." + File.separator + "runtime" + File.separator + BUILD_OUTPUT_FOLDER //
+ // + File.pathSeparator + ".." + File.separator + "aspectj5rt" + File.separator + BUILD_OUTPUT_FOLDER //
+ + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "junit" + File.separator + "junit.jar" //
+ // + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "bcel" + File.separator + "bcel.jar" //
+ // + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "bcel" + File.separator
+ // + "bcel-verifier.jar" +
+
+ + outputFolder("bridge")
+ + outputFolder("loadtime")
+ + outputFolder("weaver")
+ + outputFolder("org.aspectj.matcher")
+ + outputFolder("bridge");
+ // File.pathSeparator + ".." + File.separator + "bridge" + File.separator + "bin" + File.pathSeparator + ".."
+ // + File.separator + "loadtime" + File.separator + "bin" + File.pathSeparator
+ // + ".."
+ // + File.separator
+ // + "weaver"
+ // + File.separator
+ // + "bin"
+ // + File.pathSeparator
+ // + ".."
+ // + File.separator
+ // + "weaver5"
+ // + File.separator
+ // + "bin"
+ // + File.pathSeparator
+ // + ".."
+ // + File.separator
+ // + "org.aspectj.matcher"
+ // + File.separator
+ // + "bin"
+
+ // When the build machine executes the tests, it is using code built into jars rather than code build into
+ // bin directories. This means for the necessary types to be found we have to put these jars on the classpath:
+ // + File.pathSeparator + ".." + File.separator + "aj-build" + File.separator + "jars" + File.separator + "bridge.jar"
+ // + File.pathSeparator + ".." + File.separator + "aj-build" + File.separator + "jars" + File.separator
+ // + "org.aspectj.matcher.jar" + File.pathSeparator + ".." + File.separator + "aj-build" + File.separator + "jars"
+ // + File.separator + "util.jar" + File.pathSeparator + ".." + File.separator + "aj-build" + File.separator + "jars"
+ // + File.separator + "loadtime.jar" + File.pathSeparator + ".." + File.separator + "aj-build" + File.separator + "jars"
+ // + File.separator + "weaver.jar" + File.pathSeparator + ".." + File.separator + "aj-build" + File.separator + "jars"
+ // + File.separator + "weaver5.jar" + File.pathSeparator + ".." + File.separator + "aj-build" + File.separator + "jars"
+ // + File.separator + "asm.jar" + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "test"
+ // + File.separator + "testing-client.jar"
+ // // hmmm, this next one should perhaps point to an aj-build jar...
+ // + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "test" + File.separator + "aspectjrt.jar";
private CompilationResult result;
private File sandbox;
@@ -120,7 +117,7 @@ public class Ajc {
private int incrementalStage = 10;
private boolean shouldEmptySandbox = true;
private final AjcCommandController controller;
- private static boolean verbose = System.getProperty("org.aspectj.tools.ajc.Ajc.verbose", "true").equals("true");
+ public static boolean verbose = System.getProperty("org.aspectj.tools.ajc.Ajc.verbose", "true").equals("true");
/**
* Constructs a new Ajc instance, with a new AspectJ compiler inside.
@@ -156,16 +153,16 @@ public class Ajc {
*
*
* For example, given a baseDir of "tests/pr12345" and a compile command: "ajc src/A.java src/B.java", the files in
- *
+ *
*
* tests/pr12345/
* src/
* A.java
* B.java
*
- *
+ *
* are copied to:
- *
+ *
*
* ajcSandbox/ajcTestxxx.tmp/
* src/
@@ -185,7 +182,7 @@ public class Ajc {
*
*
- *
+ *
* @param args The compiler arguments.
* @return a CompilationResult object with all the messages produced by the compiler, a description of the ajc command that was
* issued, and the standard output and error of the compile (excluding messages which are provided separately)
@@ -272,7 +269,7 @@ public class Ajc {
* Throws an IllegalStateException if you try and call this method without first doing a compile that specified the -incremental
* option.
*
- *
+ *
* @return A CompilationResult giving the results of the most recent increment.
* @throws IOException
*/
@@ -408,10 +405,10 @@ public class Ajc {
String relativeToPath = (fromParent != null) ? (fromParent.getPath() + File.separator) : "";
if (baseDir != null) {
from = new File(baseDir, from.getPath());
-// if (ensureDirsExist) {
-// File toMkdir = (ret.getPath().endsWith(".jar") || ret.getPath().endsWith(".zip"))?ret.getParentFile():ret;
-// toMkdir.mkdirs();
-// }
+ // if (ensureDirsExist) {
+ // File toMkdir = (ret.getPath().endsWith(".jar") || ret.getPath().endsWith(".zip"))?ret.getParentFile():ret;
+ // toMkdir.mkdirs();
+ // }
}
if (!from.exists())
return ret;
@@ -421,6 +418,7 @@ public class Ajc {
if (from.isFile()) {
final String prefix = from.getName().substring(0, from.getName().lastIndexOf('.'));
String[] toCopy = from.getParentFile().list(new FilenameFilter() {
+ @Override
public boolean accept(File dir, String name) {
if (name.indexOf('.') == -1)
return false;
@@ -488,9 +486,10 @@ class AjcCommandController extends Main.CommandController {
/*
* (non-Javadoc)
- *
+ *
* @see org.aspectj.tools.ajc.Main.CommandController#doRepeatCommand()
*/
+ @Override
boolean doRepeatCommand(ICommand command) {
this.command = command;
return false; // ensure that control returns to caller
@@ -498,9 +497,10 @@ class AjcCommandController extends Main.CommandController {
/*
* (non-Javadoc)
- *
+ *
* @see org.aspectj.tools.ajc.Main.CommandController#running()
*/
+ @Override
public boolean running() {
return false; // so that we can come back for more...
}
@@ -514,6 +514,7 @@ class AjcCommandController extends Main.CommandController {
class AbortInterceptor implements IMessageHandler {
+ @Override
public boolean handleMessage(IMessage message) throws AbortException {
if (message.getKind() == IMessage.ABORT) {
System.err.println("***** Abort Message Received ******");
@@ -527,15 +528,18 @@ class AbortInterceptor implements IMessageHandler {
return false;
}
+ @Override
public boolean isIgnoring(Kind kind) {
if (kind != IMessage.ABORT)
return true;
return false;
}
+ @Override
public void dontIgnore(Kind kind) {
}
+ @Override
public void ignore(Kind kind) {
}
}
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
index 5488ab1b2..6ef5ff14a 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
@@ -26,7 +26,6 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
@@ -673,7 +672,9 @@ public abstract class AjcTestCase extends TestCase {
cp.append(TestUtil.aspectjrtPath().getPath()).append(File.pathSeparator);
}
String command = LangUtil.getJavaExecutable().getAbsolutePath() + " " +vmargs+ (cp.length()==0?"":" -classpath " + cp) + " -p "+mp+" --module "+moduleName ;
- System.out.println("Command is "+command);
+ if (Ajc.verbose) {
+ System.out.println("Command is "+command);
+ }
// Command is executed using ProcessBuilder to allow setting CWD for ajc sandbox compliance
ProcessBuilder pb = new ProcessBuilder(tokenizeCommand(command));
pb.directory( new File(ajc.getSandboxDirectory().getAbsolutePath()));
@@ -697,7 +698,9 @@ public abstract class AjcTestCase extends TestCase {
cp.append(File.pathSeparator).append(TestUtil.aspectjrtPath().getPath());
}
String command = LangUtil.getJavaExecutable().getAbsolutePath() + " " +vmargs+ (cp.length()==0?"":" -classpath " + cp) + " " + className ;
- System.out.println("Command is "+command);
+ if (Ajc.verbose) {
+ System.out.println("\nCommand is "+command);
+ }
// Command is executed using ProcessBuilder to allow setting CWD for ajc sandbox compliance
ProcessBuilder pb = new ProcessBuilder(tokenizeCommand(command));
pb.directory( new File(ajc.getSandboxDirectory().getAbsolutePath()));
@@ -756,6 +759,7 @@ public abstract class AjcTestCase extends TestCase {
Class> toRun = sandboxLoader.loadClass(className);
Method mainMethod = toRun.getMethod("main", new Class[] { String[].class });
+
mainMethod.invoke(null, new Object[] { args });
} catch (ClassNotFoundException cnf) {
fail("Can't find class: " + className);
@@ -803,15 +807,21 @@ public abstract class AjcTestCase extends TestCase {
PrintWriter stdOutWriter = new PrintWriter(baosOut);
PrintWriter stdErrWriter = new PrintWriter(baosErr);
+ if (Ajc.verbose) {
+ System.out.println();
+ }
while ((line = stdInput.readLine()) != null) {
stdOutWriter.println(line);
- System.out.println(line);
+ if (Ajc.verbose) {
+ System.out.println(line);
+ }
}
stdOutWriter.flush();
while ((line = stdError.readLine()) != null) {
stdErrWriter.println(line);
- System.err.println(line);
-
+ if (Ajc.verbose) {
+ System.err.println(line);
+ }
}
stdErrWriter.flush();
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/CompilationResult.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/CompilationResult.java
index a7d661038..047879a32 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/CompilationResult.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/CompilationResult.java
@@ -1,18 +1,17 @@
/* *******************************************************************
* Copyright (c) 2004 IBM Corporation
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Adrian Colyer,
+ * 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Adrian Colyer,
* ******************************************************************/
package org.aspectj.tools.ajc;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import org.aspectj.bridge.IMessage;
@@ -20,7 +19,7 @@ import org.aspectj.bridge.IMessage;
/**
* Utility class that makes the results of a compiler run available.
*
- * Instances of this class are returned by the Ajc.compile() and
+ * Instances of this class are returned by the Ajc.compile() and
* doIncrementalCompile() methods (and the AjcTestCase.ajc() wrapper).
*
*
@@ -33,7 +32,7 @@ import org.aspectj.bridge.IMessage;
*
*/
public class CompilationResult {
-
+
private String[] args;
private String stdOut;
private String stdErr;
@@ -46,7 +45,7 @@ public class CompilationResult {
/**
* Build a compilation result - called by the Ajc.compile and
* Ajc.doIncrementalCompile methods. Should be no need for you
- * to construct an instance yourself.
+ * to construct an instance yourself.
*/
protected CompilationResult(
String[] args,
@@ -62,24 +61,24 @@ public class CompilationResult {
this.stdErr = stdErr;
this.infoMessages = (infoMessages == null) ? Collections.emptyList() : infoMessages;
this.errorMessages = (errorMessages == null) ? Collections.emptyList() : errorMessages;
- this.warningMessages = (warningMessages == null) ? Collections.emptyList() : warningMessages;
- this.failMessages = (failMessages == null) ? Collections.emptyList() : failMessages;
- this.weaveMessages = (weaveMessages == null) ? Collections.emptyList() : weaveMessages;
+ this.warningMessages = (warningMessages == null) ? Collections.emptyList() : warningMessages;
+ this.failMessages = (failMessages == null) ? Collections.emptyList() : failMessages;
+ this.weaveMessages = (weaveMessages == null) ? Collections.emptyList() : weaveMessages;
}
-
+
/**
* The arguments that were passed to the compiler.
*/
public String[] getArgs() { return args; }
/**
- * The standard output written by the compiler, excluding any messages.
+ * The standard output written by the compiler, excluding any messages.
*/
public String getStandardOutput() { return stdOut; }
/**
- * The standard error written by the compiler, excluding any messages.
+ * The standard error written by the compiler, excluding any messages.
*/
public String getStandardError() { return stdErr; }
-
+
/**
* True if the compiler issued any messages of any kind.
*/
@@ -104,7 +103,7 @@ public class CompilationResult {
* True if the compiler issued one or more weave info messages.
*/
public boolean hasWeaveMessages() { return !weaveMessages.isEmpty(); }
-
+
/**
* The informational messages produced by the compiler. The list
* entries are the IMessage
objects created during the
@@ -145,9 +144,9 @@ public class CompilationResult {
* @see org.aspectj.tools.ajc.AjcTestCase
*/
public List getFailMessages() { return failMessages; }
-
+
public List getWeaveMessages() { return weaveMessages; }
-
+
/**
* Returns string containing message count summary, list of messages
* by type, and the actual ajc compilation command that was issued.
@@ -171,7 +170,7 @@ public class CompilationResult {
buff.append(" fail, )");
buff.append(weaveMessages.size());
buff.append(" weaveInfo");
- }
+ }
buff.append("\n");
int msgNo = 1;
for (IMessage failMessage : failMessages) {