Skip to content

Commit

Permalink
Remove test references to java/constraints.
Browse files Browse the repository at this point in the history
This has been removed from real usage and so doesn't need to exist for tests, either.

PiperOrigin-RevId: 427460940
  • Loading branch information
katre authored and copybara-github committed Feb 9, 2022
1 parent 30fed68 commit 91c8085
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,34 +115,15 @@ public static void setup(
// default value for simplicity.
" '" + constraintsPackageRoot + "cpu:x86_64',",
" '" + constraintsPackageRoot + "os:linux',",
" '" + platformPackageRoot + "/java/constraints:jdk11',",
" ],",
")",
"platform(",
" name = 'default_host',",
" constraint_values = [",
" '" + constraintsPackageRoot + "cpu:x86_64',",
" '" + constraintsPackageRoot + "os:linux',",
" '" + platformPackageRoot + "/java/constraints:jdk11',",
" ],",
")");
mockToolsConfig.create(
platformsPath + "/java/constraints/BUILD",
"package(default_visibility = ['//visibility:public'])",
"constraint_setting(name = 'runtime')",
"constraint_value(",
" name = 'jdk8',",
" constraint_setting = ':runtime',",
")",
"constraint_value(",
" name = 'jdk11',",
" constraint_setting = ':runtime',",
")",
"constraint_setting(name = 'language')",
"constraint_value(",
" name = 'java8',",
" constraint_setting = ':language',",
")");
}

/** Adds a mock K8 platform. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,12 @@ public void testJavaRuntimeProviderJavaAbsolute() throws Exception {
"java_runtime(name='jvm', srcs=[], java_home='/foo/bar')",
"java_runtime_alias(name='alias')",
"jrule(name='r')",
"constraint_value(",
" name = 'constraint',",
" constraint_setting = '"
+ TestConstants.PLATFORM_PACKAGE_ROOT
+ "/java/constraints:runtime',",
")",
"toolchain(",
" name = 'java_runtime_toolchain',",
" toolchain = ':jvm',",
" toolchain_type = '"
+ TestConstants.TOOLS_REPOSITORY
+ "//tools/jdk:runtime_toolchain_type',",
" target_compatible_with = [':constraint'],",
")",
"platform(",
" name = 'platform',",
" constraint_values = [':constraint'],",
")");

scratch.file(
Expand All @@ -114,7 +103,7 @@ public void testJavaRuntimeProviderJavaAbsolute() throws Exception {
" )",
"jrule = rule(_impl, attrs = { '_java_runtime': attr.label(default=Label('//a:alias'))})");

useConfiguration("--extra_toolchains=//a:all", "--platforms=//a:platform");
useConfiguration("--extra_toolchains=//a:all");
ConfiguredTarget ct = getConfiguredTarget("//a:r");
StructImpl myInfo = getMyInfoFromTarget(ct);
String javaHomeExecPath = (String) myInfo.getValue("java_home_exec_path");
Expand All @@ -138,23 +127,12 @@ public void testJavaRuntimeProviderJavaHermetic() throws Exception {
"java_runtime(name='jvm', srcs=[], java_home='foo/bar')",
"java_runtime_alias(name='alias')",
"jrule(name='r')",
"constraint_value(",
" name = 'constraint',",
" constraint_setting = '"
+ TestConstants.PLATFORM_PACKAGE_ROOT
+ "/java/constraints:runtime',",
")",
"toolchain(",
" name = 'java_runtime_toolchain',",
" toolchain = ':jvm',",
" toolchain_type = '"
+ TestConstants.TOOLS_REPOSITORY
+ "//tools/jdk:runtime_toolchain_type',",
" target_compatible_with = [':constraint'],",
")",
"platform(",
" name = 'platform',",
" constraint_values = [':constraint'],",
")");

scratch.file(
Expand All @@ -170,7 +148,7 @@ public void testJavaRuntimeProviderJavaHermetic() throws Exception {
" )",
"jrule = rule(_impl, attrs = { '_java_runtime': attr.label(default=Label('//a:alias'))})");

useConfiguration("--extra_toolchains=//a:all", "--platforms=//a:platform");
useConfiguration("--extra_toolchains=//a:all");
ConfiguredTarget ct = getConfiguredTarget("//a:r");
StructImpl myInfo = getMyInfoFromTarget(ct);
String javaHomeExecPath = (String) myInfo.getValue("java_home_exec_path");
Expand All @@ -195,23 +173,12 @@ public void testJavaRuntimeProviderJavaGenerated() throws Exception {
"java_runtime(name='jvm', srcs=[], java='foo/bar/bin/java')",
"java_runtime_alias(name='alias')",
"jrule(name='r')",
"constraint_value(",
" name = 'constraint',",
" constraint_setting = '"
+ TestConstants.PLATFORM_PACKAGE_ROOT
+ "/java/constraints:runtime',",
")",
"toolchain(",
" name = 'java_runtime_toolchain',",
" toolchain = ':jvm',",
" toolchain_type = '"
+ TestConstants.TOOLS_REPOSITORY
+ "//tools/jdk:runtime_toolchain_type',",
" target_compatible_with = [':constraint'],",
")",
"platform(",
" name = 'platform',",
" constraint_values = [':constraint'],",
")");

scratch.file(
Expand All @@ -227,7 +194,7 @@ public void testJavaRuntimeProviderJavaGenerated() throws Exception {
" )",
"jrule = rule(_impl, attrs = { '_java_runtime': attr.label(default=Label('//a:alias'))})");

useConfiguration("--extra_toolchains=//a:all", "--platforms=//a:platform");
useConfiguration("--extra_toolchains=//a:all");
ConfiguredTarget genrule = getConfiguredTarget("//a:gen");
ConfiguredTarget ct = getConfiguredTarget("//a:r");
StructImpl myInfo = getMyInfoFromTarget(ct);
Expand Down Expand Up @@ -2587,9 +2554,7 @@ public void javaToolchainFlag_set() throws Exception {
+ "//tools/jdk:java_toolchain_alias.bzl', 'java_toolchain_alias')",
"java_toolchain_alias(name='alias')",
"myrule(name='myrule')");
useConfiguration(
"--extra_toolchains=//java/com/google/test:all",
"--platforms=//java/com/google/test:platform");
useConfiguration("--extra_toolchains=//java/com/google/test:all");
ConfiguredTarget configuredTarget = getConfiguredTarget("//foo:myrule");
StructImpl info =
(StructImpl)
Expand Down Expand Up @@ -2911,23 +2876,12 @@ public void testJavaRuntimeProviderFiles() throws Exception {
"java_runtime(name='jvm', srcs=['a.txt'], java_home='foo/bar')",
"java_runtime_alias(name='alias')",
"jrule(name='r')",
"constraint_value(",
" name = 'constraint',",
" constraint_setting = '"
+ TestConstants.PLATFORM_PACKAGE_ROOT
+ "/java/constraints:runtime',",
")",
"toolchain(",
" name = 'java_runtime_toolchain',",
" toolchain = ':jvm',",
" toolchain_type = '"
+ TestConstants.TOOLS_REPOSITORY
+ "//tools/jdk:runtime_toolchain_type',",
" target_compatible_with = [':constraint'],",
")",
"platform(",
" name = 'platform',",
" constraint_values = [':constraint'],",
")");

scratch.file(
Expand All @@ -2939,7 +2893,7 @@ public void testJavaRuntimeProviderFiles() throws Exception {
" )",
"jrule = rule(_impl, attrs = { '_java_runtime': attr.label(default=Label('//a:alias'))})");

useConfiguration("--extra_toolchains=//a:all", "--platforms=//a:platform");
useConfiguration("--extra_toolchains=//a:all");
ConfiguredTarget ct = getConfiguredTarget("//a:r");
Depset files = (Depset) ct.get("files");
assertThat(prettyArtifactNames(files.toList(Artifact.class))).containsExactly("a/a.txt");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,10 @@ static void writeBuildFileForJavaToolchain(Scratch scratch) throws Exception {
" ], ",
" java_home = 'k8',",
")",
"constraint_value(",
" name = 'constraint',",
" constraint_setting = '"
+ TestConstants.PLATFORM_PACKAGE_ROOT
+ "/java/constraints:runtime',",
")",
"toolchain(",
" name = 'java_toolchain',",
" toolchain = ':toolchain',",
" toolchain_type = '" + TestConstants.TOOLS_REPOSITORY + "//tools/jdk:toolchain_type',",
" target_compatible_with = [':constraint'],",
")",
"platform(",
" name = 'platform',",
" constraint_values = [':constraint'],",
")");
}
}

0 comments on commit 91c8085

Please sign in to comment.