diff options
author | Ulf Adams <ulfjack@google.com> | 2016-02-10 11:39:31 +0000 |
---|---|---|
committer | Dmitry Lomov <dslomov@google.com> | 2016-02-10 16:34:40 +0000 |
commit | 4224fc020c94fb363cad0c0b5dfcc225cd8e2c1a (patch) | |
tree | d40727fb5c5404e0c5a432dc66822b08389e032e /src/test/java | |
parent | caf1477087748b636b7be2bb112ea35f6f2140f4 (diff) |
SkyframeLoadingPhaseRunner: implement --compile_one_dependency.
Also fix a bug in the LoadingPhaseRunner - we weren't printing an error for
failed targets, duh!
--
MOS_MIGRATED_REVID=114310591
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java index e56117e454..1e0b234d89 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java @@ -550,6 +550,52 @@ public class LoadingPhaseRunnerTest { tester.assertContainsEventWithFrequency("invalid value in 'bash_version' attribute", 1); } + @Test + public void testCompileOneDependency() throws Exception { + tester.addFile("base/BUILD", + "cc_library(name = 'hello', srcs = ['hello.cc'])"); + tester.useLoadingOptions("--compile_one_dependency"); + LoadingResult loadingResult = assertNoErrors(tester.load("base/hello.cc")); + assertThat(loadingResult.getTargets()).containsExactlyElementsIn(getTargets("//base:hello")); + } + + @Test + public void testCompileOneDependencyNonExistentSource() throws Exception { + tester.addFile("base/BUILD", + "cc_library(name = 'hello', srcs = ['hello.cc', '//bad:bad.cc'])"); + tester.useLoadingOptions("--compile_one_dependency"); + try { + tester.load("base/hello.cc"); + fail(); + } catch (TargetParsingException expected) { + tester.assertContainsError("no such package 'bad'"); + } + } + + @Test + public void testCompileOneDependencyNonExistentSourceKeepGoing() throws Exception { + tester.addFile("base/BUILD", + "cc_library(name = 'hello', srcs = ['hello.cc', '//bad:bad.cc'])"); + tester.useLoadingOptions("--compile_one_dependency"); + if (runsLoadingPhase()) { + // The LegacyLoadingPhaseRunner throws an exception if it can't load any of the sources in the + // same rule as the source we're looking for even with --keep_going. + // In general, we probably want --compile_one_dependency to be compatible with --keep_going + // for consistency, but it's unclear if this is actually a problem for anyone. The most common + // use case for compile_one_dependency is to iterate quickly on a single file, without + // --keep_going. + try { + tester.load("base/hello.cc"); + fail(); + } catch (TargetParsingException expected) { + tester.assertContainsError("no such package 'bad'"); + } + } else { + LoadingResult loadingResult = tester.loadKeepGoing("base/hello.cc"); + assertThat(loadingResult.hasTargetPatternError()).isTrue(); + } + } + private void assertCircularSymlinksDuringTargetParsing(String targetPattern) throws Exception { try { tester.load(targetPattern); |