From cbba6ed4e2e4f7fe61978a20d185b546f8fa3bee Mon Sep 17 00:00:00 2001 From: Xavier Bonaventura Date: Sun, 24 Apr 2022 16:25:58 +0200 Subject: [PATCH] Be explicit about alowing empty globs --- BUILD | 1 + .../build/lib/analysis/CircularDependencyTest.java | 2 +- .../build/lib/analysis/ConfigurableAttributesTest.java | 2 +- .../build/lib/analysis/mock/BazelAnalysisMock.java | 2 +- .../build/lib/packages/PackageFactoryTest.java | 2 +- .../lib/rules/android/AndroidBinaryMultidexTest.java | 10 +++++----- .../lib/rules/android/AndroidDataBindingTest.java | 2 +- .../build/lib/skyframe/PackageFunctionTest.java | 8 ++++---- .../lib/skyframe/SequencedSkyframeExecutorTest.java | 4 ++-- src/test/shell/integration/loading_phase_test.sh | 4 ++-- src/test/shell/integration/run_test.sh | 2 +- tools/android/android_sdk_repository_template.bzl | 2 +- 12 files changed, 21 insertions(+), 20 deletions(-) diff --git a/BUILD b/BUILD index b977f61223345c..603fd707b44627 100644 --- a/BUILD +++ b/BUILD @@ -38,6 +38,7 @@ filegroup( srcs = glob( [".git/**"], exclude = [".git/**/*[*"], # gitk creates temp files with [] + allow_empty = True, ), ) diff --git a/src/test/java/com/google/devtools/build/lib/analysis/CircularDependencyTest.java b/src/test/java/com/google/devtools/build/lib/analysis/CircularDependencyTest.java index 2ab108f0a72cd9..d8ac6c3ed9e4f3 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/CircularDependencyTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/CircularDependencyTest.java @@ -365,7 +365,7 @@ public void testInvalidVisibilityWithSelect() throws Exception { " hdrs = select({", " ':fastbuild': glob([", " '*.h',", - " ]),", + " ], allow_empty = True),", " }),", ")"); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/ConfigurableAttributesTest.java b/src/test/java/com/google/devtools/build/lib/analysis/ConfigurableAttributesTest.java index 3a174ad6c09eae..7bac90052bfd0a 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/ConfigurableAttributesTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/ConfigurableAttributesTest.java @@ -961,7 +961,7 @@ public void selectsWithGlobsWrongType() throws Exception { " cmd = 'echo' + select({", " '//conditions:a': 'a',", " '//conditions:b': 'b',", - " }) + glob(['globbed.java']))"); + " }) + glob(['globbed.java'], allow_empty = True))"); reporter.removeHandler(failFastHandler); assertThrows(NoSuchTargetException.class, () -> getTarget("//foo:binary")); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java b/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java index 6b5d0d57517c62..fff53814627f0c 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java @@ -186,7 +186,7 @@ public void setupMockClient(MockToolsConfig config, List workspaceConten "java_host_runtime_alias(name = 'current_host_java_runtime')", "filegroup(name='langtools', srcs=['jdk/lib/tools.jar'])", "filegroup(name='bootclasspath', srcs=['jdk/jre/lib/rt.jar'])", - "filegroup(name='extdir', srcs=glob(['jdk/jre/lib/ext/*']))", + "filegroup(name='extdir', srcs=glob(['jdk/jre/lib/ext/*'], allow_empty = True))", "filegroup(name='java', srcs = ['jdk/jre/bin/java'])", "filegroup(name='JacocoCoverage', srcs = ['JacocoCoverage_deploy.jar'])", "exports_files([", diff --git a/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java b/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java index bf3af25ca5c38b..f733c118beb5f8 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java +++ b/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java @@ -1353,7 +1353,7 @@ private Package evaluateGlob( scratch.file( "globs/BUILD", Starlark.format( - "result = glob(%r, exclude=%r, exclude_directories=%r)", + "result = glob(%r, exclude=%r, exclude_directories=%r, allow_empty = True)", includes, excludes, excludeDirs ? 1 : 0), resultAssertion); return loadPackage("globs"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryMultidexTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryMultidexTest.java index e0ff97097b526b..8806093c1022f4 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryMultidexTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryMultidexTest.java @@ -56,7 +56,7 @@ public void testNonMultidexBuildStructure() throws Exception { " name = 'nomultidex',", " srcs = ['a.java'],", " manifest = 'AndroidManifest.xml',", - " resource_files = glob(['res/**']),", + " resource_files = glob(['res/**'], allow_empty = True),", " multidex = 'off')"); internalTestNonMultidexBuildStructure("//java/foo:nomultidex"); } @@ -70,7 +70,7 @@ public void testDefaultBuildStructure() throws Exception { " name = 'default',", " srcs = ['a.java'],", " manifest = 'AndroidManifest.xml',", - " resource_files = glob(['res/**']))"); + " resource_files = glob(['res/**'], allow_empty = True))"); internalTestNonMultidexBuildStructure("//java/foo:default"); } @@ -83,7 +83,7 @@ public void testManualMainDexMode() throws Exception { " name = 'manual_main_dex',", " srcs = ['a.java'],", " manifest = 'AndroidManifest.xml',", - " resource_files = glob(['res/**']),", + " resource_files = glob(['res/**'], allow_empty = True),", " multidex = 'manual_main_dex',", " main_dex_list = 'main_dex_list.txt')"); internalTestMultidexBuildStructure("//java/foo:manual_main_dex", MultidexMode.MANUAL_MAIN_DEX); @@ -103,7 +103,7 @@ public void testLegacyMultidexBuildStructure() throws Exception { " name = 'legacy',", " srcs = ['a.java'],", " manifest = 'AndroidManifest.xml',", - " resource_files = glob(['res/**']),", + " resource_files = glob(['res/**'], allow_empty = True),", " multidex = 'legacy')"); internalTestMultidexBuildStructure("//java/foo:legacy", MultidexMode.LEGACY); } @@ -122,7 +122,7 @@ public void testNativeMultidexBuildStructure() throws Exception { " name = 'native',", " srcs = ['a.java'],", " manifest = 'AndroidManifest.xml',", - " resource_files = glob(['res/**']),", + " resource_files = glob(['res/**'], allow_empty = True),", " multidex = 'native')"); internalTestMultidexBuildStructure("//java/foo:native", MultidexMode.NATIVE); } diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidDataBindingTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidDataBindingTest.java index 697da645f21e3b..e1400c9dc62dde 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidDataBindingTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidDataBindingTest.java @@ -97,7 +97,7 @@ private void writeDataBindingFilesWithNoResourcesDep() throws Exception { " enable_data_binding = 1,", " manifest = 'AndroidManifest.xml',", " srcs = ['LibWithResourceFiles.java'],", - " resource_files = glob(['res/**']),", + " resource_files = glob(['res/**'], allow_empty = True),", ")"); scratch.file( "java/android/lib_with_resource_files/LibWithResourceFiles.java", diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java index cc0741b7e7e774..749e08354f0d21 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java @@ -572,8 +572,8 @@ private static Iterable