diff options
author | Ulf Adams <ulfjack@google.com> | 2016-01-20 10:35:19 +0000 |
---|---|---|
committer | Han-Wen Nienhuys <hanwen@google.com> | 2016-01-20 11:36:55 +0000 |
commit | a47ca0114e2ea79fa2ebfc317889377ae7e8427f (patch) | |
tree | 44f6ad6ca02220ce36e1eefcda147f8a584ec998 /src/test | |
parent | 520f3c583f6ca89041ce47dfc0178e2810e2f428 (diff) |
Fix a couple of bugs related to error handling for top-level aspects.
--
MOS_MIGRATED_REVID=112561390
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/skylark/SkylarkAspectsTest.java | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkAspectsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkAspectsTest.java index 2b97b11fc9..33ee3af822 100644 --- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkAspectsTest.java +++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkAspectsTest.java @@ -394,4 +394,67 @@ public class SkylarkAspectsTest extends AnalysisTestCase { + "The following files have no generating action:\n" + "test/missing_in_action.txt\n"); } + + @Test + public void topLevelAspectIsNotAnAspect() throws Exception { + scratch.file("test/aspect.bzl", "MyAspect = 4"); + scratch.file("test/BUILD", "java_library(name = 'xxx')"); + + reporter.removeHandler(failFastHandler); + try { + update(ImmutableList.of("test/aspect.bzl%MyAspect"), "//test:xxx"); + fail(); + } catch (ViewCreationFailedException e) { + // expect to fail. + } + assertContainsEvent("MyAspect from //test:aspect.bzl is not an aspect"); + } + + @Test + public void topLevelAspectDoesNotExist() throws Exception { + scratch.file("test/aspect.bzl", ""); + scratch.file("test/BUILD", "java_library(name = 'xxx')"); + + reporter.removeHandler(failFastHandler); + try { + update(ImmutableList.of("test/aspect.bzl%MyAspect"), "//test:xxx"); + fail(); + } catch (ViewCreationFailedException e) { + // expect to fail. + } + assertContainsEvent("MyAspect from //test:aspect.bzl is not an aspect"); + } + + @Test + public void topLevelAspectDoesNotExist2() throws Exception { + scratch.file("test/BUILD", "java_library(name = 'xxx')"); + + reporter.removeHandler(failFastHandler); + try { + update(ImmutableList.of("test/aspect.bzl%MyAspect"), "//test:xxx"); + fail(); + } catch (ViewCreationFailedException e) { + // expect to fail. + } + assertContainsEvent( + "Extension file not found. Unable to load file '//test:aspect.bzl': " + + "file doesn't exist or isn't a file"); + } + + @Test + public void topLevelAspectDoesNotExistNoBuildFile() throws Exception { + scratch.file("test/BUILD", "java_library(name = 'xxx')"); + + reporter.removeHandler(failFastHandler); + try { + update(ImmutableList.of("foo/aspect.bzl%MyAspect"), "//test:xxx"); + fail(); + } catch (ViewCreationFailedException e) { + // expect to fail. + } + assertContainsEvent( + "Every .bzl file must have a corresponding package, but 'foo' does not have one. " + + "Please create a BUILD file in the same or any parent directory. " + + "Note that this BUILD file does not need to do anything except exist."); + } } |