]> source.dussan.org Git - aspectj.git/commitdiff
Remove some cruft from test classes Ajc, AjcTestCase, AntSpec
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Fri, 16 Apr 2021 06:52:07 +0000 (13:52 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Fri, 16 Apr 2021 06:52:07 +0000 (13:52 +0700)
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java
org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
testing/src/test/java/org/aspectj/testing/AntSpec.java

index 138e6538cec004ca4a6f337b8e73f11cb122f676..b6abb38ab0ba0a517fe76b4c0b5f3fb52d2f5a54 100644 (file)
@@ -51,64 +51,28 @@ 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";
+               return File.pathSeparator + ".." +File.separator + module + File.separator + BUILD_OUTPUT_FOLDER + File.separator + "classes";
        }
 
        public static final String outputFolders(String... modules) {
                StringBuilder s = new StringBuilder();
                for (String module: modules) {
-                       s.append(File.pathSeparator + ".." +File.separator + module + File.separator + "target" + File.separator + "classes");
+                       s.append(File.pathSeparator + ".." +File.separator + module + File.separator + BUILD_OUTPUT_FOLDER + File.separator + "classes");
                }
                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 + "lib" + File.separator + "junit" + File.separator + "junit.jar"
+                       + outputFolder("bridge")
+                       + outputFolder("loadtime")
+                       + outputFolder("weaver")
+                       + outputFolder("org.aspectj.matcher")
+                       + outputFolder("bridge");
 
        private CompilationResult result;
        private File sandbox;
@@ -238,8 +202,8 @@ public class Ajc {
                        addMessagesTo(errors, holder.getErrors());
                        addMessagesTo(fails, holder.getMessages(IMessage.FAIL, true));
                        addMessagesTo(weaves, holder.getMessages(IMessage.WEAVEINFO, false));
-                       String stdOut = new String(out.toByteArray());
-                       String stdErr = new String(err.toByteArray());
+                       String stdOut = out.toString();
+                       String stdErr = err.toString();
                        result = new CompilationResult(args, stdOut, stdErr, infos, errors, warnings, fails, weaves);
                } finally {
                        System.setOut(systemOut);
index e13f9e2243fa4ceeed499feaccba0c4a1abf8d32..6a93731a58fba4f2db5117dc3cddf68287a69df6 100644 (file)
@@ -77,15 +77,6 @@ public abstract class AjcTestCase extends TestCase {
                                + 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"
                                + File.pathSeparator + CLASSPATH_ASM_RENAMED
-                               // When the build machine executes the tests, it is using code built into jars rather than code build into
-                               // target/classes 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 + "util.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 + "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.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"
index b87f60894686efd5b9c463adc2a5f921c2f8575e..f3bf7cc44fb60e6589458fe308baf91ad009216c 100644 (file)
@@ -1,11 +1,11 @@
 /*******************************************************************************
  * Copyright (c) 2005 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 
- * 
+ * 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:
  *   Alexandre Vasseur         initial implementation
  *******************************************************************************/
@@ -53,29 +53,23 @@ import static org.aspectj.util.LangUtil.is16VMOrGreater;
  * Element {@code <stdout><line text="..">} and {@code <stderr><line text="..">} can be used. For now, a full match is
  * performed on the output of the runned target only (not the whole Ant invocation). This is experimental and you are
  * advised to use a {@code <junit>} task instead or a {@code <java>} whose main throws some exception upon failure.
- * 
+ *
  * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
  */
 public class AntSpec implements ITestStep {
 
-       
-       public static final String outputFolders(String... modules) {
+       public static String outputFolders(String... modules) {
                StringBuilder s = new StringBuilder();
                for (String module: modules) {
                        s.append(File.pathSeparator + ".." +File.separator + module + File.separator + "target" + File.separator + "classes");
                }
                return s.toString();
        }
-       
-       
+
+
        // ALSO SEE AJC
        private final static String DEFAULT_LTW_CLASSPATH_ENTRIES =
                        outputFolders("asm", "bridge", "loadtime", "weaver", "org.aspectj.matcher", "bcel-builder");
-//     private final static String DEFAULT_LTW_CLASSPATH_ENTRIES = ".." + File.separator + "asm/bin" + File.pathSeparator + ".."
-//                     + File.separator + "bridge/bin" + File.pathSeparator + ".." + File.separator + "loadtime/bin" + File.pathSeparator
-//                     + ".." + File.separator + "loadtime5/bin" + File.pathSeparator + ".." + File.separator + "weaver/bin"
-//                     + File.pathSeparator + ".." + File.separator + "org.aspectj.matcher/bin" + File.pathSeparator + ".." + File.separator
-//                     + "lib/bcel/bcel.jar" + File.pathSeparator + ".." + File.separator + "lib/bcel/bcel-verifier.jar";;
 
        private boolean m_verbose = false;
        private AjcTest m_ajcTest;
@@ -107,9 +101,9 @@ public class AntSpec implements ITestStep {
                        // On Java 16+, LTW no longer works without this parameter. Add the argument here and not in AjcTestCase::run,
                        // because even if 'useLTW' and 'useFullLTW' are not set, we might in the future have tests for weaver attachment
                        // during runtime. See also docs/dist/doc/README-187.html.
-                       // 
+                       //
                        // Attention: Ant 1.6.3 under Linux neither likes "" (empty string) nor " " (space), on Windows it would not be
-                       // a problem. So we use "_dummy" Java system properties, even though they pollute the command line. 
+                       // a problem. So we use "_dummy" Java system properties, even though they pollute the command line.
                        p.setUserProperty("aj.addOpensKey", is16VMOrGreater() ? "--add-opens" : "-D_dummy");
                        p.setUserProperty("aj.addOpensValue", is16VMOrGreater() ? "java.base/java.lang=ALL-UNNAMED" : "-D_dummy");
 
@@ -164,18 +158,14 @@ public class AntSpec implements ITestStep {
                                                                fr.close();
                                                        }
                                                } catch (Exception e) {
-                                                       System.out.println("Exception whilst loading forked java task output " + e.getMessage() + "\n");
+                                                       String exceptionMessage = "Exception whilst loading forked java task output " + e.getMessage() + "\n";
+                                                       System.out.println(exceptionMessage);
                                                        e.printStackTrace();
-                                                       stdout.append("Exception whilst loading forked java task output " + e.getMessage() + "\n");
+                                                       stdout.append(exceptionMessage);
                                                }
 
-                                               StringBuffer message = new StringBuffer();
-                                               message.append(event.getException().toString()).append("\n");
-                                               message.append(verboseLog);
-                                               message.append(stdout);
-                                               message.append(stderr);
                                                // AjcTestCase.fail(failMessage + "failure " + event.getException());
-                                               AjcTestCase.fail(message.toString());
+                                               AjcTestCase.fail(event.getException() + "\n" + verboseLog + stdout + stderr);
                                        }
                                }
 
@@ -239,7 +229,7 @@ public class AntSpec implements ITestStep {
 //                             WARNING: Please consider reporting this to the maintainers of org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor
 //                             WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
 //                             WARNING: All illegal access operations will be denied in a future release
-                               
+
                                stderr2 = stderr2.replaceAll("WARNING: An illegal reflective access operation has occurred\n","");
                                stderr2 = stderr2.replaceAll("WARNING: Illegal reflective access using Lookup on org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor[^\n]*\n","");
                                stderr2 = stderr2.replaceAll("WARNING: Please consider reporting this to the maintainers of org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor\n","");
@@ -266,7 +256,7 @@ public class AntSpec implements ITestStep {
        }
 
        public void setVerbose(String verbose) {
-               if (verbose != null && "true".equalsIgnoreCase(verbose)) {
+               if ("true".equalsIgnoreCase(verbose)) {
                        m_verbose = true;
                }
        }