use of com.google.devtools.build.lib.syntax.GlobList in project bazel by bazelbuild.
the class PackageFactoryTest method testTransientErrorsInGlobbing.
@Test
public void testTransientErrorsInGlobbing() throws Exception {
events.setFailFast(false);
Path buildFile = scratch.file("/e/BUILD", "sh_library(name = 'e', data = glob(['*.txt']))");
Path parentDir = buildFile.getParentDirectory();
scratch.file("/e/data.txt");
throwOnReaddir = parentDir;
Package pkg = packages.createPackage("e", buildFile);
assertTrue(pkg.containsErrors());
events.setFailFast(true);
throwOnReaddir = null;
pkg = packages.createPackage("e", buildFile);
assertFalse(pkg.containsErrors());
assertNotNull(pkg.getRule("e"));
GlobList globList = (GlobList) pkg.getRule("e").getAttributeContainer().getAttr("data");
assertThat(globList).containsExactly(Label.parseAbsolute("//e:data.txt"));
}
use of com.google.devtools.build.lib.syntax.GlobList in project bazel by bazelbuild.
the class IncrementalLoadingTest method testTransientErrorsInGlobbing.
@Test
public void testTransientErrorsInGlobbing() throws Exception {
Path buildFile = tester.addFile("e/BUILD", "sh_library(name = 'e', data = glob(['*.txt']))");
Path parentDir = buildFile.getParentDirectory();
tester.addFile("e/data.txt");
throwOnReaddir = parentDir;
tester.sync();
Target target = tester.getTarget("//e:e");
assertThat(((Rule) target).containsErrors()).isTrue();
GlobList<?> globList = (GlobList<?>) ((Rule) target).getAttributeContainer().getAttr("data");
assertThat(globList).isEmpty();
throwOnReaddir = null;
tester.sync();
target = tester.getTarget("//e:e");
assertThat(((Rule) target).containsErrors()).isFalse();
globList = (GlobList<?>) ((Rule) target).getAttributeContainer().getAttr("data");
assertThat(globList).containsExactly(Label.parseAbsolute("//e:data.txt"));
}