diff options
author | John Cater <jcater@google.com> | 2017-05-25 22:31:39 +0200 |
---|---|---|
committer | Irina Iancu <elenairina@google.com> | 2017-05-26 09:37:53 +0200 |
commit | 04c090adfafd5d6715c4cb17446b7d62607e9a0b (patch) | |
tree | dacb0b00f0479e9b13614197df1b7cc63d4a0f95 /src/test/java/com | |
parent | 3a035d0d76cb46f9ac5fe314b42cfda123ddd9b9 (diff) |
Make platform providers creatable from Skylark.
This will allow custom rules to interact more fully with the platform system.
Change-Id: I22dd2efab55b1c6e6129b1ba99fb5f0aa9c2d6b2
PiperOrigin-RevId: 157145828
Diffstat (limited to 'src/test/java/com')
8 files changed, 390 insertions, 166 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/platform/BUILD b/src/test/java/com/google/devtools/build/lib/analysis/platform/BUILD index 1e752eeab8..6bacfd18c5 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/platform/BUILD +++ b/src/test/java/com/google/devtools/build/lib/analysis/platform/BUILD @@ -9,6 +9,7 @@ java_test( srcs = glob(["*.java"]), test_class = "com.google.devtools.build.lib.AllTests", deps = [ + "//src/main/java/com/google/devtools/build/lib:build-base", "//src/main/java/com/google/devtools/build/lib:events", "//src/main/java/com/google/devtools/build/lib:os_util", "//src/main/java/com/google/devtools/build/lib:packages-internal", @@ -16,6 +17,7 @@ java_test( "//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", "//src/test/java/com/google/devtools/build/lib:packages_testutil", "//src/test/java/com/google/devtools/build/lib/skylark:testutil", diff --git a/src/test/java/com/google/devtools/build/lib/analysis/platform/ConstraintSettingInfoTest.java b/src/test/java/com/google/devtools/build/lib/analysis/platform/ConstraintSettingInfoTest.java new file mode 100644 index 0000000000..ddc66d71b3 --- /dev/null +++ b/src/test/java/com/google/devtools/build/lib/analysis/platform/ConstraintSettingInfoTest.java @@ -0,0 +1,65 @@ +// Copyright 2017 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.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; +import com.google.devtools.build.lib.rules.platform.ConstraintSetting; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests of {@link ConstraintSettingInfo}. */ +@RunWith(JUnit4.class) +public class ConstraintSettingInfoTest extends BuildViewTestCase { + + @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 constraintSettingInfoConstructor() throws Exception { + scratch.file( + "test/platform/my_constraint_setting.bzl", + "def _impl(ctx):", + " constraint_setting = platform_common.ConstraintSettingInfo(label = ctx.label)", + " return [constraint_setting]", + "my_constraint_setting = rule(", + " implementation = _impl,", + " attrs = {", + " }", + ")"); + scratch.file( + "test/platform/BUILD", + "load('//test/platform:my_constraint_setting.bzl', 'my_constraint_setting')", + "my_constraint_setting(name = 'custom')"); + + ConfiguredTarget setting = getConfiguredTarget("//test/platform:custom"); + assertThat(setting).isNotNull(); + assertThat(ConstraintSetting.constraintSetting(setting)).isNotNull(); + assertThat(ConstraintSetting.constraintSetting(setting).label()) + .isEqualTo(Label.parseAbsolute("//test/platform:custom")); + } +} diff --git a/src/test/java/com/google/devtools/build/lib/analysis/platform/ConstraintValueInfoTest.java b/src/test/java/com/google/devtools/build/lib/analysis/platform/ConstraintValueInfoTest.java new file mode 100644 index 0000000000..9a6e6d21c3 --- /dev/null +++ b/src/test/java/com/google/devtools/build/lib/analysis/platform/ConstraintValueInfoTest.java @@ -0,0 +1,82 @@ +// Copyright 2017 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.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; +import com.google.devtools.build.lib.rules.platform.ConstraintValue; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests of {@link ConstraintValueInfo}. */ +@RunWith(JUnit4.class) +public class ConstraintValueInfoTest extends BuildViewTestCase { + + @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:otherValue"))) + .testEquals(); + } + + @Test + public void constraintValueInfoConstructor() throws Exception { + scratch.file( + "test/platform/my_constraint_value.bzl", + "def _impl(ctx):", + " setting = ctx.attr.setting[platform_common.ConstraintSettingInfo]", + " constraint_value = platform_common.ConstraintValueInfo(", + " label = ctx.label, constraint_setting = setting)", + " return [constraint_value]", + "my_constraint_value = rule(", + " implementation = _impl,", + " attrs = {", + " 'setting': attr.label(providers = [platform_common.ConstraintSettingInfo]),", + " }", + ")"); + scratch.file( + "test/platform/BUILD", + "load('//test/platform:my_constraint_value.bzl', 'my_constraint_value')", + "constraint_setting(name = 'basic')", + "my_constraint_value(", + " name = 'custom',", + " setting = ':basic',", + ")"); + + ConfiguredTarget value = getConfiguredTarget("//test/platform:custom"); + assertThat(value).isNotNull(); + assertThat(ConstraintValue.constraintValue(value)).isNotNull(); + assertThat(ConstraintValue.constraintValue(value).constraint().label()) + .isEqualTo(Label.parseAbsolute("//test/platform:basic")); + assertThat(ConstraintValue.constraintValue(value).label()) + .isEqualTo(Label.parseAbsolute("//test/platform:custom")); + } +} diff --git a/src/test/java/com/google/devtools/build/lib/analysis/platform/PlatformInfoTest.java b/src/test/java/com/google/devtools/build/lib/analysis/platform/PlatformInfoTest.java new file mode 100644 index 0000000000..d8f0029011 --- /dev/null +++ b/src/test/java/com/google/devtools/build/lib/analysis/platform/PlatformInfoTest.java @@ -0,0 +1,154 @@ +// Copyright 2017 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.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.rules.platform.Platform; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests of {@link PlatformInfo}. */ +@RunWith(JUnit4.class) +public class PlatformInfoTest extends BuildViewTestCase { + @Rule public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void createPlatform() throws Exception { + scratch.file( + "constraint/BUILD", + "constraint_setting(name = 'basic')", + "constraint_value(name = 'foo',", + " constraint_setting = ':basic',", + " )"); + } + + @Test + public void platformInfo_overlappingConstraintsError() throws Exception { + 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(PlatformInfo.DuplicateConstraintException.class); + expectedException.expectMessage( + "Duplicate constraint_values for constraint_setting //constraint:basic: " + + "//constraint:foo, //constraint:bar"); + builder.build(); + } + + @Test + public void platformInfo_equalsTester() throws Exception { + 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(); + } + + @Test + public void platformInfoConstructor() throws Exception { + scratch.file( + "test/platform/my_platform.bzl", + "def _impl(ctx):", + " constraints = [val[platform_common.ConstraintValueInfo] " + + "for val in ctx.attr.constraints]", + " platform = platform_common.PlatformInfo(constraint_values = constraints)", + " return [platform]", + "my_platform = rule(", + " implementation = _impl,", + " attrs = {", + " 'constraints': attr.label_list(providers = [platform_common.ConstraintValueInfo])", + " }", + ")"); + scratch.file( + "test/platform/BUILD", + "load('//test/platform:my_platform.bzl', 'my_platform')", + "my_platform(name = 'custom',", + " constraints = [", + " '//constraint:foo',", + " ])"); + + ConfiguredTarget platform = getConfiguredTarget("//test/platform:custom"); + assertThat(platform).isNotNull(); + + PlatformInfo provider = Platform.platform(platform); + assertThat(provider).isNotNull(); + assertThat(provider.constraints()).hasSize(1); + ConstraintSettingInfo constraintSetting = + ConstraintSettingInfo.create(makeLabel("//constraint:basic")); + ConstraintValueInfo constraintValue = + ConstraintValueInfo.create(constraintSetting, makeLabel("//constraint:foo")); + assertThat(provider.constraints()).containsExactly(constraintValue); + assertThat(provider.remoteExecutionProperties()).isEmpty(); + } + + @Test + public void platformInfoConstructor_error_duplicateConstraints() throws Exception { + scratch.file( + "test/platform/my_platform.bzl", + "def _impl(ctx):", + " platform = platform_common.PlatformInfo()", + " return [platform]", + "my_platform = rule(", + " implementation = _impl,", + " attrs = {", + " 'constraints': attr.label_list(providers = [platform_common.ConstraintValueInfo])", + " }", + ")"); + checkError( + "test/platform", + "custom", + "Label '//constraint:foo' is duplicated in the 'constraints' attribute of rule 'custom'", + "load('//test/platform:my_platform.bzl', 'my_platform')", + "my_platform(name = 'custom',", + " constraints = [", + " '//constraint:foo',", + " '//constraint:foo',", + " ])"); + } +} diff --git a/src/test/java/com/google/devtools/build/lib/analysis/platform/PlatformProvidersTest.java b/src/test/java/com/google/devtools/build/lib/analysis/platform/PlatformProvidersTest.java deleted file mode 100644 index 35f60cd662..0000000000 --- a/src/test/java/com/google/devtools/build/lib/analysis/platform/PlatformProvidersTest.java +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright 2017 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.platform; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.testing.EqualsTester; -import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; -import com.google.devtools.build.lib.events.Location; -import com.google.devtools.build.lib.packages.ClassObjectConstructor; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Tests of platform providers. */ -@RunWith(JUnit4.class) -public class PlatformProvidersTest extends BuildViewTestCase { - @Rule public ExpectedException expectedException = ExpectedException.none(); - - @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(); - } - - @Test - public void platformInfo_overlappingConstraintsError() throws Exception { - 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(PlatformInfo.DuplicateConstraintException.class); - expectedException.expectMessage( - "Duplicate constraint_values for constraint_setting //constraint:basic: " - + "//constraint:foo, //constraint:bar"); - builder.build(); - } - - @Test - public void platformInfo_equalsTester() throws Exception { - 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(); - } - - @Test - public void toolchainInfo_equalsTester() throws Exception { - ClassObjectConstructor.Key key = new ClassObjectConstructor.Key() {}; - 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. - new ToolchainInfo( - key, - ImmutableList.of(value1, value2), - ImmutableList.of(value1, value3), - ImmutableMap.<String, Object>of("foo", "val1", "bar", "val2"), - Location.BUILTIN), - new ToolchainInfo( - key, - ImmutableList.of(value1, value2), - ImmutableList.of(value1, value3), - ImmutableMap.<String, Object>of("foo", "val1", "bar", "val2"), - Location.BUILTIN)) - .addEqualityGroup( - // Different type. - new ToolchainInfo( - new ClassObjectConstructor.Key() {}, - ImmutableList.of(value1, value2), - ImmutableList.of(value1, value3), - ImmutableMap.<String, Object>of("foo", "val1", "bar", "val2"), - Location.BUILTIN)) - .addEqualityGroup( - // Different target constraints. - new ToolchainInfo( - key, - ImmutableList.of(value1, value2), - ImmutableList.of(value1, value2), - ImmutableMap.<String, Object>of("foo", "val1", "bar", "val2"), - Location.BUILTIN)) - .addEqualityGroup( - // Different data. - new ToolchainInfo( - key, - ImmutableList.of(value1, value2), - ImmutableList.of(value1, value3), - ImmutableMap.<String, Object>of("foo", "val1", "bar", "val3"), - Location.BUILTIN)) - .testEquals(); - } -} diff --git a/src/test/java/com/google/devtools/build/lib/analysis/platform/ToolchainInfoTest.java b/src/test/java/com/google/devtools/build/lib/analysis/platform/ToolchainInfoTest.java new file mode 100644 index 0000000000..289f72a28b --- /dev/null +++ b/src/test/java/com/google/devtools/build/lib/analysis/platform/ToolchainInfoTest.java @@ -0,0 +1,85 @@ +// Copyright 2017 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.platform; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.testing.EqualsTester; +import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; +import com.google.devtools.build.lib.events.Location; +import com.google.devtools.build.lib.packages.ClassObjectConstructor; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests of {@link ToolchainInfo}. */ +@RunWith(JUnit4.class) +public class ToolchainInfoTest extends BuildViewTestCase { + + @Test + public void toolchainInfo_equalsTester() throws Exception { + ClassObjectConstructor.Key key = new ClassObjectConstructor.Key() {}; + 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. + new ToolchainInfo( + key, + ImmutableList.of(value1, value2), + ImmutableList.of(value1, value3), + ImmutableMap.<String, Object>of("foo", "val1", "bar", "val2"), + Location.BUILTIN), + new ToolchainInfo( + key, + ImmutableList.of(value1, value2), + ImmutableList.of(value1, value3), + ImmutableMap.<String, Object>of("foo", "val1", "bar", "val2"), + Location.BUILTIN)) + .addEqualityGroup( + // Different type. + new ToolchainInfo( + new ClassObjectConstructor.Key() {}, + ImmutableList.of(value1, value2), + ImmutableList.of(value1, value3), + ImmutableMap.<String, Object>of("foo", "val1", "bar", "val2"), + Location.BUILTIN)) + .addEqualityGroup( + // Different target constraints. + new ToolchainInfo( + key, + ImmutableList.of(value1, value2), + ImmutableList.of(value1, value2), + ImmutableMap.<String, Object>of("foo", "val1", "bar", "val2"), + Location.BUILTIN)) + .addEqualityGroup( + // Different data. + new ToolchainInfo( + key, + ImmutableList.of(value1, value2), + ImmutableList.of(value1, value3), + ImmutableMap.<String, Object>of("foo", "val1", "bar", "val3"), + Location.BUILTIN)) + .testEquals(); + } +} 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 130e1dd1fa..fbf1e196cb 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 @@ -75,7 +75,7 @@ public class ConstraintTest extends BuildViewTestCase { " setting = constraint_value.constraint.label,", " value = constraint_value.label)", "my_rule = rule(", - " _impl,", + " implementation = _impl,", " attrs = { 'constraint': attr.label(providers = [platform_common.ConstraintValueInfo])},", ")"); 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 1b17491440..ee430b51e5 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 @@ -153,7 +153,7 @@ public class PlatformTest extends BuildViewTestCase { " first_setting = platform.constraints[0].constraint.label,", " first_value = platform.constraints[0].label)", "my_rule = rule(", - " _impl,", + " implementation = _impl,", " attrs = { 'platform': attr.label(providers = [platform_common.PlatformInfo])},", ")"); |