// Copyright 2015 The Bazel Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package com.google.devtools.build.lib.analysis.select; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.packages.Attribute; import com.google.devtools.build.lib.packages.AttributeMap; import com.google.devtools.build.lib.packages.BuildType; import com.google.devtools.build.lib.packages.RawAttributeMapper; import com.google.devtools.build.lib.packages.Rule; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import java.util.List; /** * Unit tests for {@link RawAttributeMapper}. */ @RunWith(JUnit4.class) public class RawAttributeMapperTest extends AbstractAttributeMapperTest { @Before public final void createMapper() throws Exception { // Run AbstractAttributeMapper tests through a RawAttributeMapper. mapper = RawAttributeMapper.of(rule); } private Rule setupGenRule() throws Exception { return createRule("x", "myrule", "sh_binary(", " name = 'myrule',", " srcs = select({", " '//conditions:a': ['a.sh'],", " '//conditions:b': ['b.sh'],", " '" + BuildType.Selector.DEFAULT_CONDITION_KEY + "': ['default.sh'],", " }),", " data = [ ':data_a', ':data_b' ])"); } @Test public void testGetAttribute() throws Exception { RawAttributeMapper rawMapper = RawAttributeMapper.of(setupGenRule()); List