-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support alternate JavaCompilers (such as ECJ) in CompilationRule #71
base: main
Are you sure you want to change the base?
Conversation
It does not work for me when I use the Rule: @Rule
public CompilationRule compilationRule = new CompilationRule(() -> new EclipseCompiler()); By debugging, I realized that in the Compilation class, we are still fetching the compiler from |
I think you're confusing two things: the CompilationRule and the Truth assertions. The CompilationRule doesn't change the behavior of the assertions. |
@tbroyer You're right, what I need is more something like: Truth.ASSERT.about(JavaSourceSubjectFactory.javaSource())
.that(loadClass(XXX.class))
.withCompiler(new EclipseCompiler())
.withCompilerOptions("-nowarn", "-1.8")
.processedWith(this)
.compilesWithoutError(); For that, we need to add a new method I'll do a pull request for that |
Hey, @tbroyer. Sorry it took me quite so long to get back to you. The biggest problem with this p/r is that we can't use a file-based file manager (at least for the default). For most small projects, whether your tests access the disk or not is inconsequential, but for our test infrastructure it makes a very big difference in the aggregate. I hate making special provisions just for how broken ecj is, but this might be a reasonable place to do a reflective check and fall back to their file manager iff we know it's eclipse. Seem reasonable? |
Hmm, not sure I follow… The tests won't reach the disk (and wrapping the file manager in an |
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
ECJ expects all JavaFileObjects to be Files, so the rule no longer uses Compilation.compile() but instead directly uses the JavaCompiler, and processes a class rather than compiling a dummy (in-memory) source.
35ae925
to
c09dd40
Compare
Rebased, and cherry-picked @doanduyhai's commit from #80 (effectively merging both PRs). PTAL. |
I don't know the status of this, but for CLA purposes: tbroyer appears to be the only author now: c09dd40 leads to https://github.com/google/compile-testing/commits?author=doanduyhai ("No commits found for 'doanduyhai'") |
ECJ expects all JavaFileObjects to be Files, so the rule no longer
uses Compilation.compile() but instead directly uses the JavaCompiler,
and processes a class rather than compiling a dummy (in-memory) source.