From 4c4fbd0a244ca1d9e8de4a32c05ac2f72b899ff8 Mon Sep 17 00:00:00 2001 From: Luca Di Grazia Date: Sun, 4 Sep 2022 19:44:34 +0200 Subject: [PATCH] Flip the flag --incompatible_static_name_resolution_in_build_files Fixes https://github.com/bazelbuild/bazel/issues/8022 RELNOTES: --incompatible_static_name_resolution_in_build_files is now enabled by default PiperOrigin-RevId: 249521083 --- .../packages/StarlarkSemanticsOptions.java | 16 ++ .../build/lib/syntax/StarlarkSemantics.java | 5 + .../build/lib/analysis/BuildViewTest.java | 20 +- .../lib/analysis/util/BuildViewTestBase.java | 57 +++--- .../lib/packages/PackageFactoryTest.java | 6 +- .../packages/util/PackageFactoryTestBase.java | 8 +- .../lib/pkgcache/LoadingPhaseRunnerTest.java | 174 +----------------- .../skyframe/WorkspaceFileFunctionTest.java | 3 +- .../build/lib/syntax/EvaluationTest.java | 7 +- 9 files changed, 64 insertions(+), 232 deletions(-) diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java index f1ee3b41df9..edcfbf31dbc 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java @@ -359,6 +359,21 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl + "instead return a list of provider instances.") public boolean incompatibleDisallowStructProviderSyntax; + @Option( + name = "incompatible_disallow_old_octal_notation", + defaultValue = "true", + category = "incompatible changes", + documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS, + effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, + help = + "If set to true, octal numbers like `0123` are forbidden, they should be written " + + "`0o123` instead. See https://github.com/bazelbuild/bazel/issues/8059") + public boolean incompatibleDisallowOldOctalNotation; + /** Controls legacy arguments to ctx.actions.Args#add. */ @Option( name = "incompatible_disallow_old_style_args_add", @@ -619,6 +634,7 @@ public StarlarkSemantics toSkylarkSemantics() { .incompatibleDisallowLoadLabelsToCrossPackageBoundaries( incompatibleDisallowLoadLabelsToCrossPackageBoundaries) .incompatibleDisallowNativeInBuildFile(incompatibleDisallowNativeInBuildFile) + .incompatibleDisallowOldOctalNotation(incompatibleDisallowOldOctalNotation) .incompatibleDisallowOldStyleArgsAdd(incompatibleDisallowOldStyleArgsAdd) .incompatibleDisallowStructProviderSyntax(incompatibleDisallowStructProviderSyntax) .incompatibleDisallowRuleExecutionPlatformConstraintsAllowed( diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java index 8a58b3d7a02..3d1d3e66751 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java @@ -157,6 +157,8 @@ public boolean flagValue(FlagIdentifier flagIdentifier) { public abstract boolean incompatibleDisallowNativeInBuildFile(); + public abstract boolean incompatibleDisallowOldOctalNotation(); + public abstract boolean incompatibleDisallowOldStyleArgsAdd(); public abstract boolean incompatibleDisallowRuleExecutionPlatformConstraintsAllowed(); @@ -232,6 +234,7 @@ public static Builder builderWithDefaults() { .incompatibleDisallowLegacyJavaInfo(false) .incompatibleDisallowLoadLabelsToCrossPackageBoundaries(true) .incompatibleDisallowNativeInBuildFile(true) + .incompatibleDisallowOldOctalNotation(true) .incompatibleDisallowOldStyleArgsAdd(true) .incompatibleDisallowRuleExecutionPlatformConstraintsAllowed(false) .incompatibleDisallowStructProviderSyntax(false) @@ -297,6 +300,8 @@ public abstract static class Builder { public abstract Builder incompatibleDisallowLoadLabelsToCrossPackageBoundaries(boolean value); + public abstract Builder incompatibleDisallowOldOctalNotation(boolean value); + public abstract Builder incompatibleDisallowOldStyleArgsAdd(boolean value); public abstract Builder incompatibleDisallowNativeInBuildFile(boolean value); diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java index dcee940df06..9379951222b 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java @@ -166,24 +166,6 @@ public void testGeneratedArtifact() throws Exception { assertThat(action.getClass()).isSameInstanceAs(FailAction.class); } - @Test - public void testGetArtifactOwnerInStarlark() throws Exception { - scratch.file( - "foo/rule.bzl", - "def _impl(ctx):", - " f = ctx.actions.declare_file('rule_output')", - " print('f owner is ' + str(f.owner))", - " ctx.actions.write(", - " output = f,", - " content = 'foo',", - " )", - "gen = rule(implementation = _impl)"); - scratch.file("foo/BUILD", "load(':rule.bzl', 'gen')", "gen(name = 'a')"); - - update("//foo:a"); - assertContainsEvent("DEBUG /workspace/foo/rule.bzl:3:3: f owner is //foo:a"); - } - @Test public void testSyntaxErrorInDepPackage() throws Exception { // Check that a loading error in a dependency is properly reported. @@ -466,7 +448,7 @@ public void testOutputFilterWithDebug() throws Exception { "java/b/rules.bzl", "def _impl(ctx):", " print('debug in b')", - " ctx.actions.write(", + " ctx.file_action(", " output = ctx.outputs.my_output,", " content = 'foo',", " )", diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestBase.java b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestBase.java index 4c124e693e6..6678bf45722 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestBase.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestBase.java @@ -16,30 +16,23 @@ import static com.google.common.truth.Truth.assertThat; -import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.eventbus.Subscribe; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.util.ActionsTestUtil; import com.google.devtools.build.lib.analysis.AnalysisFailureEvent; -import com.google.devtools.build.lib.analysis.BuildView.AnalysisResult; +import com.google.devtools.build.lib.analysis.AnalysisResult; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.RunfilesProvider; -import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.EventCollector; import com.google.devtools.build.lib.events.OutputFilter.RegexOutputFilter; import com.google.devtools.build.lib.pkgcache.LoadingFailureEvent; -import com.google.devtools.build.lib.query2.output.OutputFormatter; -import com.google.devtools.build.lib.rules.genquery.GenQuery; -import com.google.devtools.build.lib.skyframe.PrecomputedValue; -import com.google.devtools.build.lib.skyframe.PrecomputedValue.Injected; -import com.google.devtools.build.lib.util.Pair; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; +import com.google.devtools.build.skyframe.DeterministicHelper; import com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator; -import com.google.devtools.build.skyframe.NotifyingInMemoryGraph; - +import com.google.devtools.build.skyframe.NotifyingHelper.Listener; import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; @@ -62,15 +55,6 @@ protected static int getFrequencyOfErrorsWithLocation( return frequency; } - @Override - protected ImmutableList getPrecomputedValues() { - ImmutableList.Builder result = ImmutableList.builder(); - result.addAll(super.getPrecomputedValues()); - result.add(PrecomputedValue.injected( - GenQuery.QUERY_OUTPUT_FORMATTERS, OutputFormatter.getDefaultFormatters())); - return result.build(); - } - protected final void setupDummyRule() throws Exception { scratch.file("pkg/BUILD", "testing_dummy_rule(name='foo', ", @@ -105,43 +89,54 @@ protected void runTestDepOnGoodTargetInBadPkgAndTransitiveCycle(boolean incremen Path symlinkcycleBuildFile = scratch.file("symlinkcycle/BUILD", "sh_library(name = 'cycle', srcs = glob(['*.sh']))"); Path dirPath = symlinkcycleBuildFile.getParentDirectory(); - dirPath.getRelative("foo.sh").createSymbolicLink(new PathFragment("foo.sh")); + dirPath.getRelative("foo.sh").createSymbolicLink(PathFragment.create("foo.sh")); scratch.file("okaypkg/BUILD", "sh_library(name = 'transitively-a-cycle',", " srcs = ['//symlinkcycle:cycle'])"); - Path badpkgBuildFile = scratch.file("badpkg/BUILD", - "exports_files(['okay-target'])", - "invalidbuildsyntax"); + Path badpkgBuildFile = scratch.file("badpkg/BUILD", "exports_files(['okay-target'])", "fail()"); if (incremental) { update(defaultFlags().with(Flag.KEEP_GOING), "//okaypkg:transitively-a-cycle"); assertContainsEvent("circular symlinks detected"); eventCollector.clear(); } update(defaultFlags().with(Flag.KEEP_GOING), "//parent:foo"); - assertEquals(1, getFrequencyOfErrorsWithLocation(badpkgBuildFile.asFragment(), eventCollector)); + assertThat(getFrequencyOfErrorsWithLocation(badpkgBuildFile.asFragment(), eventCollector)) + .isEqualTo(1); // TODO(nharmata): This test currently only works because each BuildViewTest#update call // dirties all FileNodes that are in error. There is actually a skyframe bug with cycle // reporting on incremental builds (see b/14622820). assertContainsEvent("circular symlinks detected"); } - protected void setGraphForTesting(NotifyingInMemoryGraph notifyingInMemoryGraph) { + protected void injectGraphListenerForTesting(Listener listener, boolean deterministic) { InMemoryMemoizingEvaluator memoizingEvaluator = (InMemoryMemoizingEvaluator) skyframeExecutor.getEvaluatorForTesting(); - memoizingEvaluator.setGraphForTesting(notifyingInMemoryGraph); + memoizingEvaluator.injectGraphTransformerForTesting( + DeterministicHelper.makeTransformer(listener, deterministic)); } protected void runTestForMultiCpuAnalysisFailure(String badCpu, String goodCpu) throws Exception { reporter.removeHandler(failFastHandler); useConfiguration("--experimental_multi_cpu=" + badCpu + "," + goodCpu); scratch.file("multi/BUILD", - "cc_library(name='cpu', abi='$(TARGET_CPU)', abi_deps={'" + badCpu + "':[':fail']})", - "genrule(name='fail', outs=['file1', 'file2'], executable = 1, cmd='touch $@')"); + "config_setting(", + " name = 'config',", + " values = {'cpu': '" + badCpu + "'})", + "cc_library(", + " name = 'cpu',", + " deps = select({", + " ':config': [':fail'],", + " '//conditions:default': []}))", + "genrule(", + " name = 'fail',", + " outs = ['file1', 'file2'],", + " executable = 1,", + " cmd = 'touch $@')"); update(defaultFlags().with(Flag.KEEP_GOING), "//multi:cpu"); AnalysisResult result = getAnalysisResult(); assertThat(result.getTargetsToBuild()).hasSize(1); ConfiguredTarget targetA = Iterables.get(result.getTargetsToBuild(), 0); - assertEquals(goodCpu, targetA.getConfiguration().getCpu()); + assertThat(getConfiguration(targetA).getCpu()).isEqualTo(goodCpu); // Unfortunately, we get the same error twice - we can't distinguish the configurations. assertContainsEvent("if genrules produce executables, they are allowed only one output"); } @@ -164,9 +159,9 @@ public void analysisFailure(AnalysisFailureEvent event) { public static class LoadingFailureRecorder { @Subscribe public void loadingFailure(LoadingFailureEvent event) { - events.add(Pair.of(event.getFailedTarget(), event.getFailureReason())); + events.add(event); } - public final List> events = new ArrayList<>(); + public final List events = new ArrayList<>(); } } diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java index be4f723dfe2..bdd7d35490e 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java @@ -661,7 +661,7 @@ public void testInsufficientArgumentGlobErrors() throws Exception { "glob()", "insufficient arguments received by glob(include: sequence of strings, " + "*, exclude: sequence of strings = [], exclude_directories: int = 1, " - + "allow_empty: bool = ) (got 0, expected at least 1)"); + + "allow_empty: bool = True) (got 0, expected at least 1)"); } @Test @@ -671,7 +671,7 @@ public void testGlobUnamedExclude() throws Exception { "glob(['a'], ['b'])", "too many (2) positional arguments in call to glob(include: sequence of strings, " + "*, exclude: sequence of strings = [], exclude_directories: int = 1, " - + "allow_empty: bool = )"); + + "allow_empty: bool = True)"); } @Test @@ -681,7 +681,7 @@ public void testTooManyArgumentsGlobErrors() throws Exception { "glob(1,2,3,4)", "too many (4) positional arguments in call to glob(include: sequence of strings, " + "*, exclude: sequence of strings = [], exclude_directories: int = 1, " - + "allow_empty: bool = )"); + + "allow_empty: bool = True)"); } @Test diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/packages/util/PackageFactoryTestBase.java b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/packages/util/PackageFactoryTestBase.java index adfd8b78ece..ec9425036ee 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/packages/util/PackageFactoryTestBase.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/packages/util/PackageFactoryTestBase.java @@ -18,7 +18,6 @@ import static org.junit.Assert.fail; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.devtools.build.lib.cmdline.PackageIdentifier; import com.google.devtools.build.lib.events.Event; @@ -33,7 +32,7 @@ import com.google.devtools.build.lib.packages.Package; import com.google.devtools.build.lib.packages.RawAttributeMapper; import com.google.devtools.build.lib.packages.Rule; -import com.google.devtools.build.lib.syntax.Starlark; +import com.google.devtools.build.lib.syntax.Printer; import com.google.devtools.build.lib.testutil.Scratch; import com.google.devtools.build.lib.testutil.TestUtils; import com.google.devtools.build.lib.util.Pair; @@ -114,7 +113,6 @@ protected static void assertEvaluates( new GlobCache( pkg.getFilename().asPath().getParentDirectory(), pkg.getPackageIdentifier(), - ImmutableSet.of(), PackageFactoryApparatus.createEmptyLocator(), null, TestUtils.getPool(), @@ -206,7 +204,7 @@ protected void assertGlobMatches( includes, excludes, excludeDirs, - Starlark.format("(result == sorted(%r)) or fail('incorrect glob result')", result)); + Printer.format("(result == sorted(%r)) or fail('incorrect glob result')", result)); Package pkg = evaluated.first; GlobCache globCache = evaluated.second; @@ -238,7 +236,7 @@ private Pair evaluateGlob( Path file = scratch.file( "/globs/BUILD", - Starlark.format( + Printer.format( "result = glob(%r, exclude=%r, exclude_directories=%r)", includes, excludes, excludeDirs ? 1 : 0), resultAssertion); diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java index 307426bfed9..ad872a660ae 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java @@ -27,7 +27,6 @@ import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; -import com.google.common.collect.Maps; import com.google.common.collect.MoreCollectors; import com.google.devtools.build.lib.actions.ActionKeyContext; import com.google.devtools.build.lib.analysis.BlazeDirectories; @@ -59,6 +58,7 @@ import com.google.devtools.build.lib.testutil.MoreAsserts; import com.google.devtools.build.lib.testutil.TestConstants; import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor; +import com.google.devtools.build.lib.vfs.FileSystem; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.ModifiedFileSet; import com.google.devtools.build.lib.vfs.Path; @@ -70,10 +70,8 @@ import com.google.devtools.common.options.OptionsParser; import com.google.devtools.common.options.OptionsParsingException; import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; @@ -1028,147 +1026,8 @@ public void testPackageLoadingError_NoKeepGoing_TargetsBeneathDirectory() throws runTestPackageLoadingError(/*keepGoing=*/ false, "//bad/..."); } - @Test - public void testPackageLoadingError_KeepGoing_SomeGoodTargetsBeneathDirectory() throws Exception { - tester.addFile("good/BUILD", "sh_library(name = 't')\n"); - runTestPackageLoadingError(/*keepGoing=*/ true, "//..."); - } - - @Test - public void testPackageLoadingError_NoKeepGoing_SomeGoodTargetsBeneathDirectory() - throws Exception { - tester.addFile("good/BUILD", "sh_library(name = 't')\n"); - runTestPackageLoadingError(/*keepGoing=*/ false, "//..."); - } - - private void runTestPackageFileInconsistencyError(boolean keepGoing, String... patterns) - throws Exception { - tester.addFile("bad/BUILD", "sh_library(name = 't')\n"); - IOException ioExn = new IOException("nope"); - tester.throwExceptionOnGetInputStream(tester.getWorkspace().getRelative("bad/BUILD"), ioExn); - if (keepGoing) { - TargetPatternPhaseValue value = tester.loadKeepGoing(patterns); - assertThat(value.hasError()).isTrue(); - tester.assertContainsWarning("Target pattern parsing failed"); - tester.assertContainsError("error loading package 'bad': nope"); - } else { - TargetParsingException exn = - assertThrows(TargetParsingException.class, () -> tester.load(patterns)); - assertThat(exn).hasCauseThat().isInstanceOf(BuildFileContainsErrorsException.class); - assertThat(exn).hasCauseThat().hasMessageThat().contains("error loading package 'bad': nope"); - } - } - - @Test - public void testPackageFileInconsistencyError_KeepGoing_ExplicitTarget() throws Exception { - runTestPackageFileInconsistencyError(true, "//bad:BUILD"); - } - - @Test - public void testPackageFileInconsistencyError_NoKeepGoing_ExplicitTarget() throws Exception { - runTestPackageFileInconsistencyError(false, "//bad:BUILD"); - } - - @Test - public void testPackageFileInconsistencyError_KeepGoing_TargetsInPackage() throws Exception { - runTestPackageFileInconsistencyError(true, "//bad:all"); - } - - @Test - public void testPackageFileInconsistencyError_NoKeepGoing_TargetsInPackage() throws Exception { - runTestPackageFileInconsistencyError(false, "//bad:all"); - } - - @Test - public void testPackageFileInconsistencyError_KeepGoing_argetsBeneathDirectory() - throws Exception { - runTestPackageFileInconsistencyError(true, "//bad/..."); - } - - @Test - public void testPackageFileInconsistencyError_NoKeepGoing_TargetsBeneathDirectory() - throws Exception { - runTestPackageFileInconsistencyError(false, "//bad/..."); - } - - @Test - public void testPackageFileInconsistencyError_KeepGoing_SomeGoodTargetsBeneathDirectory() - throws Exception { - tester.addFile("good/BUILD", "sh_library(name = 't')\n"); - runTestPackageFileInconsistencyError(true, "//..."); - } - - @Test - public void testPackageFileInconsistencyError_NoKeepGoing_SomeGoodTargetsBeneathDirectory() - throws Exception { - tester.addFile("good/BUILD", "sh_library(name = 't')\n"); - runTestPackageFileInconsistencyError(false, "//..."); - } - - private void runTestExtensionLoadingError(boolean keepGoing, String... patterns) - throws Exception { - tester.addFile("bad/f1.bzl", "nope"); - tester.addFile("bad/BUILD", "load(\":f1.bzl\", \"not_a_symbol\")"); - if (keepGoing) { - TargetPatternPhaseValue value = tester.loadKeepGoing(patterns); - assertThat(value.hasError()).isTrue(); - tester.assertContainsWarning("Target pattern parsing failed"); - } else { - TargetParsingException exn = - assertThrows(TargetParsingException.class, () -> tester.load(patterns)); - assertThat(exn).hasCauseThat().isInstanceOf(BuildFileContainsErrorsException.class); - assertThat(exn).hasCauseThat().hasMessageThat().contains("Extension 'bad/f1.bzl' has errors"); - } - tester.assertContainsError("/workspace/bad/f1.bzl:1:1: name 'nope' is not defined"); - } - - @Test - public void testExtensionLoadingError_KeepGoing_ExplicitTarget() throws Exception { - runTestExtensionLoadingError(/*keepGoing=*/ true, "//bad:BUILD"); - } - - @Test - public void testExtensionLoadingError_NoKeepGoing_ExplicitTarget() throws Exception { - runTestExtensionLoadingError(/*keepGoing=*/ false, "//bad:BUILD"); - } - - @Test - public void testExtensionLoadingError_KeepGoing_TargetsInPackage() throws Exception { - runTestExtensionLoadingError(/*keepGoing=*/ true, "//bad:all"); - } - - @Test - public void testExtensionLoadingError_NoKeepGoing_TargetsInPackage() throws Exception { - runTestExtensionLoadingError(/*keepGoing=*/ false, "//bad:all"); - } - - @Test - public void testExtensionLoadingError_KeepGoing_TargetsBeneathDirectory() throws Exception { - runTestExtensionLoadingError(/*keepGoing=*/ true, "//bad/..."); - } - - @Test - public void testExtensionLoadingError_NoKeepGoing_TargetsBeneathDirectory() throws Exception { - runTestExtensionLoadingError(/*keepGoing=*/ false, "//bad/..."); - } - - @Test - public void testExtensionLoadingError_KeepGoing_SomeGoodTargetsBeneathDirectory() - throws Exception { - tester.addFile("good/BUILD", "sh_library(name = 't')\n"); - runTestExtensionLoadingError(/*keepGoing=*/ true, "//..."); - } - - @Test - public void testExtensionLoadingError_NoKeepGoing_SomeGoodTargetsBeneathDirectory() - throws Exception { - tester.addFile("good/BUILD", "sh_library(name = 't')\n"); - runTestExtensionLoadingError(/*keepGoing=*/ false, "//..."); - } - private static class LoadingPhaseTester { private final ManualClock clock = new ManualClock(); - private final CustomInMemoryFs fs = new CustomInMemoryFs(clock); private final Path workspace; private final AnalysisMock analysisMock; @@ -1188,6 +1047,7 @@ private static class LoadingPhaseTester { private MockToolsConfig mockToolsConfig; public LoadingPhaseTester() throws IOException { + FileSystem fs = new InMemoryFileSystem(clock); this.workspace = fs.getPath("/workspace"); workspace.createDirectory(); mockToolsConfig = new MockToolsConfig(workspace); @@ -1374,10 +1234,6 @@ public ImmutableSet