aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2015-03-24 17:18:02 +0000
committerGravatar Lukacs Berki <lberki@google.com>2015-03-25 10:28:52 +0000
commit2234d38fab9ad6f6a7874d54eab8779c1dbf4e9d (patch)
tree6ee11d35b7cfc08252daa66a4bf6789597155078 /src/main
parent03bad4619075aa77876698c55827aa54e7426ea9 (diff)
Skylark: kill package loading if a Skylark file has errors.
-- MOS_MIGRATED_REVID=89411484
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunction.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunction.java
index 7031e53d7a..cd997ec8f7 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunction.java
@@ -108,7 +108,7 @@ public class SkylarkImportLookupFunction implements SkyFunction {
file));
}
- SkylarkEnvironment extensionEnv = createEnv(ast, importMap, env);
+ SkylarkEnvironment extensionEnv = createEnv(ast, file, importMap, env);
// Skylark UserDefinedFunctions are sharing function definition Environments, so it's extremely
// important not to modify them from this point. Ideally they should be only used to import
// symbols and serve as global Environments of UserDefinedFunctions.
@@ -161,9 +161,9 @@ public class SkylarkImportLookupFunction implements SkyFunction {
* Creates the SkylarkEnvironment to be imported. After it's returned, the Environment
* must not be modified.
*/
- private SkylarkEnvironment createEnv(BuildFileAST ast,
+ private SkylarkEnvironment createEnv(BuildFileAST ast, PathFragment file,
Map<PathFragment, SkylarkEnvironment> importMap, Environment env)
- throws InterruptedException {
+ throws InterruptedException, SkylarkImportLookupFunctionException {
StoredEventHandler eventHandler = new StoredEventHandler();
// TODO(bazel-team): this method overestimates the changes which can affect the
// Skylark RuleClass. For example changes to comments or unused functions can modify the hash.
@@ -179,8 +179,11 @@ public class SkylarkImportLookupFunction implements SkyFunction {
}
extensionEnv.setImportedExtensions(importMap);
ast.exec(extensionEnv, eventHandler);
- // Don't fail just replay the events so the original package lookup can fail.
+
Event.replayEventsOn(env.getListener(), eventHandler.getEvents());
+ if (eventHandler.hasErrors()) {
+ throw new SkylarkImportLookupFunctionException(SkylarkImportFailedException.errors(file));
+ }
return extensionEnv;
}
@@ -194,6 +197,11 @@ public class SkylarkImportLookupFunction implements SkyFunction {
super(errorMessage);
}
+ static SkylarkImportFailedException errors(PathFragment file) {
+ return new SkylarkImportFailedException(
+ String.format("Extension file '%s' has errors", file));
+ }
+
static SkylarkImportFailedException errorReadingFile(PathFragment file, String error) {
return new SkylarkImportFailedException(
String.format("Encountered error while reading extension file '%s': %s", file, error));