Some Ajc196 tests are using preview features (see .../ajc196.xml), i.e.
they will fail on Java 15+ because code compiled with '--enable-preview'
can only run on the same JVM version, not on a more recent one. Hence,
the preview-using tests are now being excluded in order to make the
build run on Java 15, even though no Java 15 features are present in the
current 1.9.7 snapshot.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
--- /dev/null
+/* *******************************************************************
+ * Copyright (c) 2021 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://www.eclipse.org/legal/epl-v10.html
+ * ******************************************************************/
+package org.aspectj.testing;
+
+import org.aspectj.util.LangUtil;
+
+/**
+ * Makes sure tests are running on the right level of JDK.
+ *
+ * @author Alexander Kriegisch
+ */
+public abstract class XMLBasedAjcTestCaseForJava14Only extends XMLBasedAjcTestCase {
+
+ @Override
+ public void runTest(String title) {
+ if (!LangUtil.is14VMOrGreater() || LangUtil.is15VMOrGreater()) {
+ throw new IllegalStateException(
+ "These tests should be run on Java 14 only " +
+ "(e.g. because they use version-specific preview features)"
+ );
+ }
+ super.runTest(title);
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2021 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://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc196;
+
+import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava14Only;
+
+import junit.framework.Test;
+
+/**
+ * @author Alexander Kriegisch
+ */
+public class Ajc196PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava14Only {
+
+ public void testRecords2() {
+ runTest("using a record");
+ }
+
+ public void testInstanceofPatterns() {
+ runTest("instanceof patterns");
+ }
+
+ public void testAdvisingRecords() {
+ runTest("advising records");
+ }
+
+ public void testTextBlock1() {
+ runTest("textblock 1");
+ }
+
+ public void testTextBlock2() {
+ runTest("textblock 2");
+ }
+
+ // ---
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Ajc196PreviewFeaturesTests.class);
+ }
+
+ @Override
+ protected java.net.URL getSpecFile() {
+ return getClassResource("ajc196.xml");
+ }
+
+}
*/
public class Ajc196Tests extends XMLBasedAjcTestCaseForJava14OrLater {
- public void testNPE_558995() {
- runTest("early resolution of supporting interfaces");
- }
-
- public void testRecords() {
- runTest("simple record");
- checkVersion("Person", Constants.MAJOR_14, Constants.PREVIEW_MINOR_VERSION);
- }
-
- public void testRecords2() {
- runTest("using a record");
- }
-
- public void testInstanceofPatterns() {
- runTest("instanceof patterns");
- }
-
- public void testAdvisingRecords() {
- runTest("advising records");
- }
-
- public void testSwitch1() {
- runTest("switch 1");
- checkVersion("Switch1", Constants.MAJOR_14, 0);
- }
-
- public void testSwitch2() {
- runTest("switch 2");
- checkVersion("Switch2", Constants.MAJOR_14, 0);
- }
-
- public void testSwitch3() {
- runTest("switch 3");
- checkVersion("Switch3", Constants.MAJOR_14, 0);
- }
-
- public void testTextBlock1() {
- runTest("textblock 1");
- }
-
- public void testTextBlock2() {
- runTest("textblock 2");
- }
- // ---
-
- public static Test suite() {
- return XMLBasedAjcTestCase.loadSuite(Ajc196Tests.class);
- }
-
- @Override
- protected java.net.URL getSpecFile() {
- return getClassResource("ajc196.xml");
- }
+ public void testNPE_558995() {
+ runTest("early resolution of supporting interfaces");
+ }
+
+ public void testRecords() {
+ runTest("simple record");
+ checkVersion("Person", Constants.MAJOR_14, Constants.PREVIEW_MINOR_VERSION);
+ }
+
+ public void testSwitch1() {
+ runTest("switch 1");
+ checkVersion("Switch1", Constants.MAJOR_14, 0);
+ }
+
+ public void testSwitch2() {
+ runTest("switch 2");
+ checkVersion("Switch2", Constants.MAJOR_14, 0);
+ }
+
+ public void testSwitch3() {
+ runTest("switch 3");
+ checkVersion("Switch3", Constants.MAJOR_14, 0);
+ }
+
+ // ---
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Ajc196Tests.class);
+ }
+
+ @Override
+ protected java.net.URL getSpecFile() {
+ return getClassResource("ajc196.xml");
+ }
}
suite.addTest(Ajc196Tests.suite());
suite.addTest(SanityTestsJava14.suite());
}
+ if (LangUtil.is14VMOrGreater() && !LangUtil.is15VMOrGreater()) {
+ suite.addTest(Ajc196PreviewFeaturesTests.suite());
+ }
return suite;
}
}
<ajc-test dir="features193" vm="14" title="switch 1">
<compile files="Switch1.java" options="-14">
</compile>
- <run class="Switch1" vmargs="--enable-preview">
+ <run class="Switch1">
<stdout>
<line text="0" />
<line text="1" />
<run class="Code" vmargs="--enable-preview">
<stdout>
<line text="this is a text" />
- <!-- the incidental space is removed with a trim in output matching but
- the test app doesn't remove it when printing it, why? -->
<line text="block" />
</stdout>
</run>
</compile>
<run class="Code2" vmargs="--enable-preview">
<stdout>
- <!-- why is the incidental space not removed here?? -->
<line text="this is a text" />
<line text="block in advice" />
</stdout>