Skip to content

Commit

Permalink
Refactor tests to not assume the target configuration.
Browse files Browse the repository at this point in the history
Future changes to Android rules will result in dependencies not being in the top-level target configuration, this change is to future-proof the tests.

PiperOrigin-RevId: 354359631
  • Loading branch information
katre authored and copybara-github committed Jan 28, 2021
1 parent cef82b3 commit db69c9f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,11 @@ private BuildConfiguration getConfiguration(String label) {
return config;
}

protected final BuildConfiguration getConfiguration(
BuildConfigurationValue.Key configurationKey) {
return skyframeExecutor.getConfiguration(reporter, configurationKey);
}

protected final BuildConfiguration getConfiguration(ConfiguredTarget ct) {
return skyframeExecutor.getConfiguration(reporter, ct.getConfigurationKey());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.google.devtools.build.lib.analysis.RequiredConfigFragmentsProvider;
import com.google.devtools.build.lib.analysis.actions.FileWriteAction;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.packages.BuildType;
Expand Down Expand Up @@ -4474,15 +4475,22 @@ public void androidManifestMergerOrderAlphabetical_MergeesSortedByExecPath() thr
" exports_manifest = 1,",
" resource_files = ['theme/res/values/values.xml'],",
")");
Artifact androidCoreManifest = getLibraryManifest(getConfiguredTarget("//java/android:core"));
ConfiguredTarget application = getConfiguredTarget("//java/binary:application");
BuildConfiguration appConfiguration = getConfiguration(application);
Artifact androidCoreManifest =
getLibraryManifest(getConfiguredTarget("//java/android:core", appConfiguration));
Artifact androidUtilityManifest =
getLibraryManifest(getConfiguredTarget("//java/android:utility"));
getLibraryManifest(getConfiguredTarget("//java/android:utility", appConfiguration));
Artifact binaryLibraryManifest =
getLibraryManifest(getConfiguredTarget("//java/binary:library"));
Artifact commonManifest = getLibraryManifest(getConfiguredTarget("//java/common:common"));
Artifact commonThemeManifest = getLibraryManifest(getConfiguredTarget("//java/common:theme"));
getLibraryManifest(getConfiguredTarget("//java/binary:library", appConfiguration));
Artifact commonManifest =
getLibraryManifest(getConfiguredTarget("//java/common:common", appConfiguration));
Artifact commonThemeManifest =
getLibraryManifest(getConfiguredTarget("//java/common:theme", appConfiguration));

assertThat(getBinaryMergeeManifests(getConfiguredTarget("//java/binary:application")))
assertThat(
getBinaryMergeeManifests(
getConfiguredTarget("//java/binary:application", appConfiguration)))
.containsExactlyEntriesIn(
ImmutableMap.of(
androidCoreManifest.getExecPath().toString(), "//java/android:core",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ java_test(
"//src/main/java/com/google/devtools/build/lib/actions",
"//src/main/java/com/google/devtools/build/lib/actions:artifacts",
"//src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster",
"//src/main/java/com/google/devtools/build/lib/analysis:config/build_configuration",
"//src/main/java/com/google/devtools/build/lib/analysis:configured_target",
"//src/main/java/com/google/devtools/build/lib/analysis:file_provider",
"//src/main/java/com/google/devtools/build/lib/analysis:required_config_fragments_provider",
Expand Down

0 comments on commit db69c9f

Please sign in to comment.