diff options
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/rules/platform')
4 files changed, 17 insertions, 90 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/platform/BUILD b/src/test/java/com/google/devtools/build/lib/rules/platform/BUILD index 39b1617172..daf896eea9 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/platform/BUILD +++ b/src/test/java/com/google/devtools/build/lib/rules/platform/BUILD @@ -13,6 +13,7 @@ java_test( "//src/main/java/com/google/devtools/build/lib:os_util", "//src/main/java/com/google/devtools/build/lib:syntax", "//src/main/java/com/google/devtools/build/lib:util", + "//src/main/java/com/google/devtools/build/lib/analysis/platform", "//src/main/java/com/google/devtools/build/lib/cmdline", "//src/main/java/com/google/devtools/build/lib/rules/platform", "//src/test/java/com/google/devtools/build/lib:analysis_testutil", diff --git a/src/test/java/com/google/devtools/build/lib/rules/platform/ConstraintTest.java b/src/test/java/com/google/devtools/build/lib/rules/platform/ConstraintTest.java index 5029953037..130e1dd1fa 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/platform/ConstraintTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/platform/ConstraintTest.java @@ -16,7 +16,6 @@ package com.google.devtools.build.lib.rules.platform; import static com.google.common.truth.Truth.assertThat; -import com.google.common.testing.EqualsTester; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; import com.google.devtools.build.lib.cmdline.Label; @@ -46,22 +45,22 @@ public class ConstraintTest extends BuildViewTestCase { public void testConstraint() throws Exception { ConfiguredTarget setting = getConfiguredTarget("//constraint:basic"); assertThat(setting).isNotNull(); - assertThat(ConstraintSettingInfo.fromTarget(setting)).isNotNull(); - assertThat(ConstraintSettingInfo.fromTarget(setting)).isNotNull(); - assertThat(ConstraintSettingInfo.fromTarget(setting).label()) + assertThat(ConstraintSetting.constraintSetting(setting)).isNotNull(); + assertThat(ConstraintSetting.constraintSetting(setting)).isNotNull(); + assertThat(ConstraintSetting.constraintSetting(setting).label()) .isEqualTo(Label.parseAbsolute("//constraint:basic")); ConfiguredTarget fooValue = getConfiguredTarget("//constraint:foo"); assertThat(fooValue).isNotNull(); - assertThat(ConstraintValueInfo.fromTarget(fooValue)).isNotNull(); - assertThat(ConstraintValueInfo.fromTarget(fooValue).constraint().label()) + assertThat(ConstraintValue.constraintValue(fooValue)).isNotNull(); + assertThat(ConstraintValue.constraintValue(fooValue).constraint().label()) .isEqualTo(Label.parseAbsolute("//constraint:basic")); - assertThat(ConstraintValueInfo.fromTarget(fooValue).label()) + assertThat(ConstraintValue.constraintValue(fooValue).label()) .isEqualTo(Label.parseAbsolute("//constraint:foo")); ConfiguredTarget barValue = getConfiguredTarget("//constraint:bar"); assertThat(barValue).isNotNull(); - assertThat(ConstraintValueInfo.fromTarget(barValue).constraint().label()) + assertThat(ConstraintValue.constraintValue(barValue).constraint().label()) .isEqualTo(Label.parseAbsolute("//constraint:basic")); - assertThat(ConstraintValueInfo.fromTarget(barValue).label()) + assertThat(ConstraintValue.constraintValue(barValue).label()) .isEqualTo(Label.parseAbsolute("//constraint:bar")); } @@ -96,32 +95,4 @@ public class ConstraintTest extends BuildViewTestCase { assertThat(valueLabel).isNotNull(); assertThat(valueLabel).isEqualTo(makeLabel("//constraint:foo")); } - - @Test - public void constraintSetting_equalsTester() { - new EqualsTester() - .addEqualityGroup( - ConstraintSettingInfo.create(makeLabel("//constraint:basic")), - ConstraintSettingInfo.create(makeLabel("//constraint:basic"))) - .addEqualityGroup(ConstraintSettingInfo.create(makeLabel("//constraint:other"))) - .testEquals(); - } - - @Test - public void constraintValue_equalsTester() { - ConstraintSettingInfo setting1 = ConstraintSettingInfo.create(makeLabel("//constraint:basic")); - ConstraintSettingInfo setting2 = ConstraintSettingInfo.create(makeLabel("//constraint:other")); - new EqualsTester() - .addEqualityGroup( - // Base case. - ConstraintValueInfo.create(setting1, makeLabel("//constraint:value")), - ConstraintValueInfo.create(setting1, makeLabel("//constraint:value"))) - .addEqualityGroup( - // Different label. - ConstraintValueInfo.create(setting1, makeLabel("//constraint:otherValue"))) - .addEqualityGroup( - // Different setting. - ConstraintValueInfo.create(setting2, makeLabel("//constraint:ovalue"))) - .testEquals(); - } } diff --git a/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformCommonTest.java index b30432891c..f3cd8255b1 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformCommonTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformCommonTest.java @@ -18,6 +18,8 @@ import static com.google.common.truth.Truth.assertThat; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; +import com.google.devtools.build.lib.analysis.platform.ConstraintSettingInfo; +import com.google.devtools.build.lib.analysis.platform.ConstraintValueInfo; import com.google.devtools.build.lib.skylark.util.SkylarkTestCase; import java.util.List; import org.junit.Test; diff --git a/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformTest.java b/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformTest.java index 5cb0991dfc..1b17491440 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformTest.java @@ -17,11 +17,12 @@ package com.google.devtools.build.lib.rules.platform; import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.ImmutableMap; -import com.google.common.testing.EqualsTester; import com.google.devtools.build.lib.analysis.ConfiguredTarget; +import com.google.devtools.build.lib.analysis.platform.ConstraintSettingInfo; +import com.google.devtools.build.lib.analysis.platform.ConstraintValueInfo; +import com.google.devtools.build.lib.analysis.platform.PlatformInfo; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; import com.google.devtools.build.lib.cmdline.Label; -import com.google.devtools.build.lib.rules.platform.PlatformInfo.DuplicateConstraintException; import com.google.devtools.build.lib.util.CPU; import com.google.devtools.build.lib.util.OS; import org.junit.Before; @@ -56,7 +57,7 @@ public class PlatformTest extends BuildViewTestCase { ConfiguredTarget platform = getConfiguredTarget("//constraint:plat1"); assertThat(platform).isNotNull(); - PlatformInfo provider = PlatformInfo.fromTarget(platform); + PlatformInfo provider = Platform.platform(platform); assertThat(provider).isNotNull(); assertThat(provider.constraints()).hasSize(1); ConstraintSettingInfo constraintSetting = @@ -88,7 +89,7 @@ public class PlatformTest extends BuildViewTestCase { ConfiguredTarget platform = getConfiguredTarget("//host:host_platform"); assertThat(platform).isNotNull(); - PlatformInfo provider = PlatformInfo.fromTarget(platform); + PlatformInfo provider = Platform.platform(platform); assertThat(provider).isNotNull(); // Check the CPU and OS. @@ -134,7 +135,7 @@ public class PlatformTest extends BuildViewTestCase { ConfiguredTarget platform = getConfiguredTarget("//constraint/remote:plat_remote"); assertThat(platform).isNotNull(); - PlatformInfo provider = PlatformInfo.fromTarget(platform); + PlatformInfo provider = Platform.platform(platform); assertThat(provider).isNotNull(); assertThat(provider.remoteExecutionProperties()) .containsExactlyEntriesIn(ImmutableMap.of("foo", "val1", "bar", "val2")); @@ -175,52 +176,4 @@ public class PlatformTest extends BuildViewTestCase { assertThat(valueLabel).isNotNull(); assertThat(valueLabel).isEqualTo(makeLabel("//constraint:foo")); } - - @Test - public void platformInfo_overlappingConstraintsError() throws DuplicateConstraintException { - ConstraintSettingInfo setting = ConstraintSettingInfo.create(makeLabel("//constraint:basic")); - - ConstraintValueInfo value1 = ConstraintValueInfo.create(setting, makeLabel("//constraint:foo")); - ConstraintValueInfo value2 = ConstraintValueInfo.create(setting, makeLabel("//constraint:bar")); - - PlatformInfo.Builder builder = - PlatformInfo.builder().addConstraint(value1).addConstraint(value2); - - expectedException.expect(DuplicateConstraintException.class); - expectedException.expectMessage( - "Duplicate constraint_values for constraint_setting //constraint:basic: " - + "//constraint:foo, //constraint:bar"); - builder.build(); - } - - @Test - public void platformInfo_equalsTester() throws DuplicateConstraintException { - ConstraintSettingInfo setting1 = ConstraintSettingInfo.create(makeLabel("//constraint:basic")); - ConstraintSettingInfo setting2 = ConstraintSettingInfo.create(makeLabel("//constraint:other")); - - ConstraintValueInfo value1 = - ConstraintValueInfo.create(setting1, makeLabel("//constraint:value1")); - ConstraintValueInfo value2 = - ConstraintValueInfo.create(setting2, makeLabel("//constraint:value2")); - ConstraintValueInfo value3 = - ConstraintValueInfo.create(setting2, makeLabel("//constraint:value3")); - - new EqualsTester() - .addEqualityGroup( - // Base case. - PlatformInfo.builder().addConstraint(value1).addConstraint(value2).build(), - PlatformInfo.builder().addConstraint(value1).addConstraint(value2).build(), - PlatformInfo.builder() - .addConstraint(value1) - .addConstraint(value2) - .addRemoteExecutionProperty("key", "val") // execution properties are ignored. - .build()) - .addEqualityGroup( - // Extra constraint. - PlatformInfo.builder().addConstraint(value1).addConstraint(value3).build()) - .addEqualityGroup( - // Missing constraint. - PlatformInfo.builder().addConstraint(value1).build()) - .testEquals(); - } } |