Search in sources :

Example 1 with GlobList

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"));
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) GlobList(com.google.devtools.build.lib.syntax.GlobList) Test(org.junit.Test)

Example 2 with GlobList

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"));
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) GlobList(com.google.devtools.build.lib.syntax.GlobList) Target(com.google.devtools.build.lib.packages.Target) Rule(com.google.devtools.build.lib.packages.Rule) Test(org.junit.Test)

Aggregations

GlobList (com.google.devtools.build.lib.syntax.GlobList)2 Path (com.google.devtools.build.lib.vfs.Path)2 Test (org.junit.Test)2 Rule (com.google.devtools.build.lib.packages.Rule)1 Target (com.google.devtools.build.lib.packages.Target)1