summaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core/testsrc
diff options
context:
space:
mode:
authoraclement <aclement>2004-10-14 12:51:18 +0000
committeraclement <aclement>2004-10-14 12:51:18 +0000
commit0a77939b3286d5ac033797234741436c57ad202f (patch)
tree4cca0b8a830f9c9dc672d937d42199f69c231f03 /org.aspectj.ajdt.core/testsrc
parent9802851fe3e0c4a3e2d7aa708d64129611f412a9 (diff)
downloadaspectj-0a77939b3286d5ac033797234741436c57ad202f.tar.gz
aspectj-0a77939b3286d5ac033797234741436c57ad202f.zip
Fix for:
Bugzilla Bug 75568 : ajc changes classfile timestamps even if compilation fails (regression) and maybe: Bugzilla Bug 74245: -proceedOnError does not weave aspects on compile error
Diffstat (limited to 'org.aspectj.ajdt.core/testsrc')
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java1
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/ProceedOnErrorTestCase.java66
2 files changed, 67 insertions, 0 deletions
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java
index d89573909..23b1425e8 100644
--- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java
@@ -32,6 +32,7 @@ public class AjdtBatchTests extends TestCase {
suite.addTestSuite(JavadocTest.class);
suite.addTestSuite(PartiallyExposedHierarchyTestCase.class);
suite.addTestSuite(CompilerDumpTestCase.class);
+ suite.addTestSuite(ProceedOnErrorTestCase.class);
// XXX suite.addTestSuite(VerifyWeaveTestCase.class);
//suite.addTestSuite(WorkingCommandTestCase.class);
//$JUnit-END$
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/ProceedOnErrorTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/ProceedOnErrorTestCase.java
new file mode 100644
index 000000000..3b856570d
--- /dev/null
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/ProceedOnErrorTestCase.java
@@ -0,0 +1,66 @@
+/* *******************************************************************
+ * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Common Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * PARC initial implementation
+ * ******************************************************************/
+
+package org.aspectj.ajdt.internal.compiler.batch;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+
+
+public class ProceedOnErrorTestCase extends CommandTestCase {
+
+ public ProceedOnErrorTestCase(String name) {
+ super(name);
+ }
+
+ /**
+ * Compile C1.java that defines C.class then compile C2.java which contains another version of C.class but also
+ * contains errors. Because -proceedOnError is not supplied, the .class file should not be touched when compiling
+ * C2.java.
+ */
+ public void testNoProceedOnError() throws IOException {
+ checkCompile("src1/C1.java", NO_ERRORS);
+ File f =new File("out"+File.separator+"C.class");
+ long oldmodtime = f.lastModified();
+ pause(2);
+ checkCompile("src1/C2.java", new int[]{1});
+ f =new File("out"+File.separator+"C.class");
+ long newmodtime = f.lastModified();
+ // Without -proceedOnError supplied, we should *not* change the time stamp on the .class file
+ assertTrue("The .class file should not have been modified as '-proceedOnError' was not supplied (old="+
+ new Date(oldmodtime).toString()+")(new="+new Date(newmodtime).toString()+")",
+ oldmodtime==newmodtime);
+ }
+
+ public void testProceedOnError() throws IOException {
+ checkCompile("src1/C1.java", NO_ERRORS);
+ File f =new File("out"+File.separator+"C.class");
+ long oldmodtime = f.lastModified();
+ pause(2);
+ checkCompile("src1/C2.java",new String[]{"-proceedOnError"}, new int[]{1});
+ f =new File("out"+File.separator+"C.class");
+ long newmodtime = f.lastModified();
+ // Without -proceedOnError supplied, we should *not* change the time stamp on the .class file
+ assertTrue("The .class file should have been modified as '-proceedOnError' *was* supplied (old="+
+ new Date(oldmodtime).toString()+")(new="+new Date(newmodtime).toString()+")",
+ newmodtime>oldmodtime);
+ }
+
+
+ private void pause(int secs) {
+ try {
+ Thread.sleep(secs*1000);
+ } catch (InterruptedException ie) {}
+ }
+
+}