Skip to content

Commit

Permalink
Also test NullAway on Error Prone 2.6.0 (#471)
Browse files Browse the repository at this point in the history
Leveraging #470, add a CI job to build and test NullAway on Error Prone 2.6.0 (the latest release).  Getting our tests to pass required adjusting to some API changes in the Error Prone test helpers APIs.  Now, all tests pass on EP 2.6.0 and 2.4.0
  • Loading branch information
msridhar committed May 6, 2021
1 parent c9487c1 commit 5d4b086
Show file tree
Hide file tree
Showing 6 changed files with 248 additions and 392 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,28 @@ on:
- master
jobs:
build:
name: "JDK ${{ matrix.java }} on ${{ matrix.os }}"
name: "JDK ${{ matrix.java }} on ${{ matrix.os }} with Error Prone ${{ matrix.epVersion }}"
strategy:
matrix:
include:
- os: macos-latest
java: 8
epVersion: 2.4.0
- os: macos-latest
java: 11
epVersion: 2.4.0
- os: ubuntu-latest
java: 8
epVersion: 2.4.0
- os: ubuntu-latest
java: 8
epVersion: 2.6.0
- os: ubuntu-latest
java: 11
epVersion: 2.4.0
- os: windows-latest
java: 8
epVersion: 2.4.0
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -29,7 +37,9 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Build and test using Gradle and Java 8
- name: Build and test using Gradle, Java 8, and Error Prone ${{ matrix.epVersion }}
env:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
uses: eskatos/gradle-command-action@v1
with:
arguments: verGJF build
Expand All @@ -46,7 +56,7 @@ jobs:
with:
arguments: jacocoTestReport coverallsJacoco
continue-on-error: true
if: runner.os == 'Linux' && matrix.java == '8' && github.repository == 'uber/NullAway'
if: runner.os == 'Linux' && matrix.java == '8' && matrix.epVersion == '2.4.0' && github.repository == 'uber/NullAway'
- name: Check that Git tree is clean after build and test
run: ./.buildscript/check_git_clean.sh
publish_snapshot:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@

package com.uber.nullaway.jarinfer;

import static com.google.errorprone.BugPattern.SeverityLevel.WARNING;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ObjectArrays;
import com.google.common.collect.Sets;
import com.google.errorprone.BugPattern;
import com.google.errorprone.CompilationTestHelper;
import com.google.errorprone.bugpatterns.BugChecker;
import com.sun.tools.javac.main.Main;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
Expand Down Expand Up @@ -47,12 +53,25 @@ public class JarInferTest {
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Rule public TemporaryFolder outputFolder = new TemporaryFolder();

private CompilerUtil compilerUtil;
private CompilationTestHelper compilationTestHelper;

@BugPattern(
name = "DummyChecker",
summary = "Dummy checker to use CompilationTestHelper",
severity = WARNING)
/**
* A dummy checker to allow us to use {@link CompilationTestHelper} to compile Java code for
* testing, as it requires a {@link BugChecker} to run.
*/
public static class DummyChecker extends BugChecker {
public DummyChecker() {}
}

@Before
public void setup() {
compilerUtil = new CompilerUtil(getClass());
compilerUtil.setArgs(Arrays.asList("-d", temporaryFolder.getRoot().getAbsolutePath()));
compilationTestHelper =
CompilationTestHelper.newInstance(DummyChecker.class, getClass())
.setArgs(Arrays.asList("-d", temporaryFolder.getRoot().getAbsolutePath()));
}

/**
Expand All @@ -71,12 +90,10 @@ private void testTemplate(
Map<String, Set<Integer>> expected,
String... lines)
throws Exception {
boolean compileSucceeded =
compilerUtil
.addSourceLines(cls + ".java", ObjectArrays.concat("package " + pkg + ";\n", lines))
.run();
Assert.assertTrue(
testName + ": test compilation failed!\n" + compilerUtil.getOutput(), compileSucceeded);
compilationTestHelper
.addSourceLines(cls + ".java", ObjectArrays.concat("package " + pkg + ";\n", lines))
.expectResult(Main.Result.OK)
.doTest();
DefinitelyDerefedParamsDriver driver = new DefinitelyDerefedParamsDriver();
Map<String, Set<Integer>> result =
driver.run(
Expand Down
Loading

0 comments on commit 5d4b086

Please sign in to comment.