Permalink
Browse files

385613 low-level compiler error should fail the build

boolean success was ignored and we relied on
parsing the compiler output instead.
Low-level compiler errors are not caught by the 
compiler output parser, so fail the build with
a CompilationException if success == false but
no errors/warnings found in the parsed output.

Change-Id: I99445a08ac8c611788bbe09cee3aa51584ff4944
  • Loading branch information...
jsievers committed Nov 16, 2012
1 parent 4d148f0 commit 8d8f578eece076be41208f024fe727941228b0e1
@@ -344,7 +344,7 @@ private static boolean suppressEncoding(CompilerConfiguration config) {
}
compiler.setBootclasspathAccessRules(custom.bootclasspathAccessRules);
getLogger().debug("Boot classpath access rules: " + custom.bootclasspathAccessRules);
- compiler.compile(args);
+ boolean success = compiler.compile(args);
try {
String output = err.toString();
@@ -353,6 +353,10 @@ private static boolean suppressEncoding(CompilerConfiguration config) {
} catch (IOException e) {
throw new RuntimeException(e);
}
+ if (!success && messages.isEmpty()) {
+ // low-level, e.g. configuration error
+ throw new CompilerException(err.toString());
+ }
return messages;
}
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: testMisconfiguration
+Bundle-Version: 1.0.0.qualifier
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
@@ -0,0 +1,29 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.eclipse.tychoits</groupId>
+ <artifactId>testMisconfiguration</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <packaging>eclipse-plugin</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-maven-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-compiler-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <compilerArgument>-boo boo</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2012 SAP AG and others.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+
+public class Test
+{
+
+}
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2012 SAP AG and others.
+ * 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:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tycho.test.compiler;
+
+import static org.junit.Assert.fail;
+
+import org.apache.maven.it.VerificationException;
+import org.apache.maven.it.Verifier;
+import org.eclipse.tycho.test.AbstractTychoIntegrationTest;
+import org.junit.Test;
+
+public class MisconfigurationTest extends AbstractTychoIntegrationTest {
+
+ @Test
+ public void testCompilerMisconfigured() throws Exception {
+ Verifier verifier = getVerifier("compiler.misconfiguration", false);
+ try {
+ verifier.executeGoal("compile");
+ fail();
+ } catch (VerificationException e) {
+ // expected
+ verifier.verifyTextInLog("org.codehaus.plexus.compiler.CompilerException: Unrecognized option : -boo boo");
+ }
+ }
+}

0 comments on commit 8d8f578

Please sign in to comment.