Search in sources :

Example 21 with TargetParsingException

use of com.google.devtools.build.lib.cmdline.TargetParsingException in project bazel by bazelbuild.

the class TestTargetUtilsTest method testExpandTestSuitesInterrupted.

@Test
public void testExpandTestSuitesInterrupted() throws Exception {
    reporter.removeHandler(failFastHandler);
    scratch.file("broken/BUILD", "test_suite(name = 'broken', tests = ['//missing:missing_test'])");
    try {
        TestTargetUtils.expandTestSuites(new TargetProvider() {

            @Override
            public Target getTarget(ExtendedEventHandler eventHandler, Label label) throws InterruptedException {
                throw new InterruptedException();
            }
        }, reporter, Sets.newHashSet(getTarget("//broken")), /*strict=*/
        false, /*keep_going=*/
        true);
    } catch (TargetParsingException e) {
        assertNotNull(e.getMessage());
    }
    assertTrue(Thread.currentThread().isInterrupted());
}
Also used : TargetParsingException(com.google.devtools.build.lib.cmdline.TargetParsingException) TargetProvider(com.google.devtools.build.lib.pkgcache.TargetProvider) Label(com.google.devtools.build.lib.cmdline.Label) ExtendedEventHandler(com.google.devtools.build.lib.events.ExtendedEventHandler) Test(org.junit.Test)

Example 22 with TargetParsingException

use of com.google.devtools.build.lib.cmdline.TargetParsingException in project bazel by bazelbuild.

the class TargetPatternEvaluatorTest method testAddedFilesAndDotDotDot.

@Test
public void testAddedFilesAndDotDotDot() throws Exception {
    invalidate(ModifiedFileSet.EVERYTHING_MODIFIED);
    reporter.removeHandler(failFastHandler);
    scratch.dir("h");
    try {
        parseList("//h/...");
        fail("TargetParsingException expected");
    } catch (TargetParsingException e) {
    // expected
    }
    scratch.file("h/i/j/k/BUILD", "sh_library(name='l')");
    ModifiedFileSet modifiedFileSet = ModifiedFileSet.builder().modify(new PathFragment("h")).modify(new PathFragment("h/i")).modify(new PathFragment("h/i/j")).modify(new PathFragment("h/i/j/k")).modify(new PathFragment("h/i/j/k/BUILD")).build();
    invalidate(modifiedFileSet);
    reporter.addHandler(failFastHandler);
    Set<Label> nonEmptyResult = parseList("//h/...");
    assertThat(nonEmptyResult).containsExactly(Label.parseAbsolute("//h/i/j/k:l"));
}
Also used : TargetParsingException(com.google.devtools.build.lib.cmdline.TargetParsingException) ModifiedFileSet(com.google.devtools.build.lib.vfs.ModifiedFileSet) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Label(com.google.devtools.build.lib.cmdline.Label) Test(org.junit.Test)

Aggregations

TargetParsingException (com.google.devtools.build.lib.cmdline.TargetParsingException)22 SkyKey (com.google.devtools.build.skyframe.SkyKey)9 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)7 Label (com.google.devtools.build.lib.cmdline.Label)6 Target (com.google.devtools.build.lib.packages.Target)6 ImmutableList (com.google.common.collect.ImmutableList)5 TargetPattern (com.google.devtools.build.lib.cmdline.TargetPattern)5 TargetPatternSkyKeyOrException (com.google.devtools.build.lib.skyframe.TargetPatternValue.TargetPatternSkyKeyOrException)5 ResolvedTargets (com.google.devtools.build.lib.cmdline.ResolvedTargets)4 ParseFailureListener (com.google.devtools.build.lib.pkgcache.ParseFailureListener)4 TargetPatternKey (com.google.devtools.build.lib.skyframe.TargetPatternValue.TargetPatternKey)4 Test (org.junit.Test)4 ThreadSafe (com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe)3 MissingDepException (com.google.devtools.build.lib.skyframe.EnvironmentBackedRecursivePackageProvider.MissingDepException)3 ValueOrException (com.google.devtools.build.skyframe.ValueOrException)3 ArrayList (java.util.ArrayList)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 ViewCreationFailedException (com.google.devtools.build.lib.analysis.ViewCreationFailedException)2 ExtendedEventHandler (com.google.devtools.build.lib.events.ExtendedEventHandler)2 LoadingFailedException (com.google.devtools.build.lib.pkgcache.LoadingFailedException)2