Search in sources :

Example 6 with ConversionException

use of com.google.devtools.build.lib.syntax.Type.ConversionException in project bazel by bazelbuild.

the class BuildTypeTest method testLabelKeyedStringDictErrorConvertingMapWithMultipleEquivalentKeysIncludesContext.

@Test
public void testLabelKeyedStringDictErrorConvertingMapWithMultipleEquivalentKeysIncludesContext() throws Exception {
    Label context = Label.parseAbsolute("//current/package:this");
    Map<String, String> input = new ImmutableMap.Builder<String, String>().put(":reference", "value1").put("//current/package:reference", "value2").build();
    try {
        BuildType.LABEL_KEYED_STRING_DICT.convert(input, "flag map", context);
        fail("Expected a conversion exception to be thrown.");
    } catch (ConversionException expected) {
        assertThat(expected).hasMessage("duplicate labels in flag map: //current/package:reference " + "(as [\":reference\", \"//current/package:reference\"])");
    }
}
Also used : ConversionException(com.google.devtools.build.lib.syntax.Type.ConversionException) Label(com.google.devtools.build.lib.cmdline.Label) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Aggregations

ConversionException (com.google.devtools.build.lib.syntax.Type.ConversionException)6 Test (org.junit.Test)4 Label (com.google.devtools.build.lib.cmdline.Label)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 SkylarkAspect (com.google.devtools.build.lib.packages.SkylarkAspect)1 SkylarkImportFailedException (com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.SkylarkImportFailedException)1 SelectorValue (com.google.devtools.build.lib.syntax.SelectorValue)1 SkyKey (com.google.devtools.build.skyframe.SkyKey)1 BitSet (java.util.BitSet)1 Nullable (javax.annotation.Nullable)1