Add tests for Bazel sourceroot inference#967
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #444.
Adds end-to-end tests for the sourceroot inference of
-build-tool:bazelcompilations (ScipTaskListener.inferBazelSourceroot), as requested in a review comment on #439.BazelSourcerootTestdrives the real compiler with file objects that mimic the ones constructed by Bazel's Java compiler:toUri()points into a sandbox directory whiletoString()renders a human-readable workspace path. The tests assert the observable outputs: shard locations undertargetroot/META-INF/scip/andDocument.relative_path. Covered cases:toString()matching no known Bazel pattern), where inference falls back to the URI path.Notes:
ClientCodeWrapper.WrappedJavaFileObject, whosetoString()would defeat the plugin's pattern matching. Real Bazel file objects are javac-internal classes and therefore trusted/unwrapped; the test file object opts out of wrapping via@ClientCodeWrapper.Trusted. Since that annotation is an internal API,compileTestJavain scip-javac now clears--releaseand adds the same--add-exportsflags the test JVM already uses at runtime.absolutePath.subpath(0, 0)threwIllegalArgumentException. The inference now falls back to the filesystem root in that case, and the third test covers it.