use of com.sun.tools.javac.main.Main.Result in project error-prone by google.
the class ErrorProneCompilerIntegrationTest method fileWithError.
@Test
public void fileWithError() throws Exception {
Result exitCode = compiler.compile(compiler.fileManager().forResources(BadShiftAmount.class, "testdata/BadShiftAmountPositiveCases.java"));
assertThat(outputStream.toString(), exitCode, is(Result.ERROR));
Matcher<? super Iterable<Diagnostic<? extends JavaFileObject>>> matcher = hasItem(diagnosticMessage(containsString("[BadShiftAmount]")));
assertTrue("Error should be found. " + diagnosticHelper.describe(), matcher.matches(diagnosticHelper.getDiagnostics()));
}
use of com.sun.tools.javac.main.Main.Result in project error-prone by google.
the class ErrorProneCompilerIntegrationTest method ignoreGeneratedConstructors.
@Test
public void ignoreGeneratedConstructors() throws Exception {
compilerBuilder.report(ScannerSupplier.fromBugCheckerClasses(ConstructorMatcher.class));
compiler = compilerBuilder.build();
Result exitCode = compiler.compile(Arrays.asList(compiler.fileManager().forSourceLines("Test.java", "public class Test {}")));
Matcher<? super Iterable<Diagnostic<? extends JavaFileObject>>> matcher = not(hasItem(diagnosticMessage(containsString("[ConstructorMatcher]"))));
assertTrue("Warning should be found. " + diagnosticHelper.describe(), matcher.matches(diagnosticHelper.getDiagnostics()));
assertThat(outputStream.toString(), exitCode, is(Result.OK));
}
use of com.sun.tools.javac.main.Main.Result in project error-prone by google.
the class ErrorProneCompilerIntegrationTest method compilePolicy_simple.
@Test
public void compilePolicy_simple() throws Exception {
Result exitCode = compiler.compile(new String[] { "-XDcompilePolicy=simple" }, Arrays.asList(compiler.fileManager().forSourceLines("Test.java", "class Test {}")));
outputStream.flush();
assertThat(exitCode).named(outputStream.toString()).isEqualTo(Result.OK);
}
use of com.sun.tools.javac.main.Main.Result in project error-prone by google.
the class ErrorProneCompilerIntegrationTest method fileWithMultipleTopLevelClassesExtendsWithError.
/**
* Regression test for a bug in which multiple top-level classes may cause
* NullPointerExceptions in the matchers.
*/
@Test
public void fileWithMultipleTopLevelClassesExtendsWithError() throws Exception {
Result exitCode = compiler.compile(compiler.fileManager().forResources(getClass(), "testdata/MultipleTopLevelClassesWithErrors.java", "testdata/ExtendedMultipleTopLevelClassesWithErrors.java"));
assertThat(outputStream.toString(), exitCode, is(Result.ERROR));
Matcher<? super Iterable<Diagnostic<? extends JavaFileObject>>> matcher = hasItem(diagnosticMessage(containsString("[SelfAssignment]")));
assertTrue("Warning should be found. " + diagnosticHelper.describe(), matcher.matches(diagnosticHelper.getDiagnostics()));
assertThat(diagnosticHelper.getDiagnostics()).hasSize(4);
}
use of com.sun.tools.javac.main.Main.Result in project error-prone by google.
the class ErrorProneCompilerIntegrationTest method fileWithWarning.
@Test
public void fileWithWarning() throws Exception {
compilerBuilder.report(ScannerSupplier.fromBugCheckerClasses(NonAtomicVolatileUpdate.class));
compiler = compilerBuilder.build();
Result exitCode = compiler.compile(compiler.fileManager().forResources(NonAtomicVolatileUpdate.class, "testdata/NonAtomicVolatileUpdatePositiveCases.java"));
assertThat(outputStream.toString(), exitCode, is(Result.OK));
Matcher<? super Iterable<Diagnostic<? extends JavaFileObject>>> matcher = hasItem(diagnosticMessage(containsString("[NonAtomicVolatileUpdate]")));
assertTrue("Warning should be found. " + diagnosticHelper.describe(), matcher.matches(diagnosticHelper.getDiagnostics()));
}
Aggregations