Skip to content

Commit

Permalink
Tests: change "host" -> "exec" references.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 499573581
Change-Id: Id67ae8b15cf8d21001499bb0e0ab5144f3b89d86
  • Loading branch information
gregestren authored and Copybara-Service committed Jan 4, 2023
1 parent 704027e commit f2cdf9e
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public void stampingEnabled_autoUsesStamp() throws Exception {

@Test
public void stampingEnabled_stampDisabledInToolConfig_attributeYes() throws Exception {
assertThat(AnalysisUtils.isStampingEnabled(TriState.YES, createHost("--stamp"))).isFalse();
assertThat(AnalysisUtils.isStampingEnabled(TriState.YES, createExec("--stamp"))).isFalse();
}

@Test
public void stampingEnabled_stampDisabledInToolConfig_attributeAuto() throws Exception {
assertThat(AnalysisUtils.isStampingEnabled(TriState.AUTO, createHost("--stamp"))).isFalse();
assertThat(AnalysisUtils.isStampingEnabled(TriState.AUTO, createExec("--stamp"))).isFalse();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class AspectValueTest extends AnalysisTestCase {
public void keyEquality() throws Exception {
update();
BuildConfigurationValue c1 = getTargetConfiguration();
BuildConfigurationValue c2 = getHostConfiguration();
BuildConfigurationValue c2 = getExecConfiguration();
Label l1 = Label.parseCanonical("//a:l1");
Label l1b = Label.parseCanonical("//a:l1");
Label l2 = Label.parseCanonical("//a:l2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void lateBoundAttributeInExecConfiguration() throws Exception {
"rule_with_test_fragment(",
" name = 'latebound_dep')");
update("//foo:gen");
assertThat(getConfiguredTarget("//foo:foo", getHostConfiguration())).isNotNull();
assertThat(getConfiguredTarget("//foo:foo", getExecConfiguration())).isNotNull();
// TODO(b/203203933) Fix LateboundDefault-s to return exec configuration
ImmutableList<ConfiguredTarget> deps =
ImmutableList.copyOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public void testConfigurationTransitions() throws Exception {
.getTransitionFactory()
.isTool())
.isTrue();
assertThat(getHostConfiguration().getCompilationMode()).isEqualTo(CompilationMode.OPT);
assertThat(getExecConfiguration().getCompilationMode()).isEqualTo(CompilationMode.OPT);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void equalsPassesEqualsTester() throws Exception {
Label aExplicit = Label.parseCanonical("//a:a");
Label b = Label.parseCanonical("//b");

BuildConfigurationValue host = getHostConfiguration();
BuildConfigurationValue host = getExecConfiguration();
BuildConfigurationValue target = getTargetConfiguration();

AspectDescriptor simpleAspect = new AspectDescriptor(TestAspects.SIMPLE_ASPECT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public void generatingRuleIsCorrect() throws Exception {
update("//foo:generating_rule");
OutputFileConfiguredTarget generatedSource =
(OutputFileConfiguredTarget)
getConfiguredTarget("//foo:generated.source", getHostConfiguration());
getConfiguredTarget("//foo:generated.source", getExecConfiguration());
assertThat(generatedSource.getGeneratingRule())
.isSameInstanceAs(getConfiguredTarget("//foo:generating_rule", getHostConfiguration()));
.isSameInstanceAs(getConfiguredTarget("//foo:generating_rule", getExecConfiguration()));
}

/**
Expand Down Expand Up @@ -102,7 +102,7 @@ public void hostConfigSwitch() throws Exception {
update("//foo:gen3");

ConfiguredTargetAndData hostSrc3 =
getConfiguredTargetAndData("//foo:host_src3.cc", getHostConfiguration());
getConfiguredTargetAndData("//foo:host_src3.cc", getExecConfiguration());
ConfiguredTarget hostGeneratedFileConsumer3 =
((OutputFileConfiguredTarget) hostSrc3.getConfiguredTarget()).getGeneratingRule();
assertThat(hostSrc3.getConfiguration()).isEqualTo(getConfiguration(hostGeneratedFileConsumer3));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void testHostCrosstoolTop() throws Exception {
assertThat(config.getFragment(CppConfiguration.class).getRuleProvidingCcToolchainProvider())
.isEqualTo(Label.parseAbsoluteUnchecked("//tools/cpp:toolchain"));

BuildConfigurationValue hostConfig = createHost();
BuildConfigurationValue hostConfig = createExec();
assertThat(hostConfig.getFragment(CppConfiguration.class).getRuleProvidingCcToolchainProvider())
.isEqualTo(Label.parseAbsoluteUnchecked("//tools/cpp:toolchain"));
}
Expand Down Expand Up @@ -235,26 +235,26 @@ public void testCommandLineVariablesWithFunnyCharacters() throws Exception {

@Test
public void testHostDefine() throws Exception {
BuildConfigurationValue cfg = createHost("--define=foo=bar");
BuildConfigurationValue cfg = createExec("--define=foo=bar");
assertThat(cfg.getCommandLineBuildVariables().get("foo")).isEqualTo("bar");
}

@Test
public void testHostCompilationModeDefault() throws Exception {
BuildConfigurationValue cfg = createHost();
BuildConfigurationValue cfg = createExec();
assertThat(cfg.getCompilationMode()).isEqualTo(CompilationMode.OPT);
}

@Test
public void testHostCompilationModeNonDefault() throws Exception {
BuildConfigurationValue cfg = createHost("--host_compilation_mode=dbg");
BuildConfigurationValue cfg = createExec("--host_compilation_mode=dbg");
assertThat(cfg.getCompilationMode()).isEqualTo(CompilationMode.DBG);
}

@Test
public void testIncompatibleMergeGenfilesDirectory() throws Exception {
BuildConfigurationValue target = create("--incompatible_merge_genfiles_directory");
BuildConfigurationValue host = createHost("--incompatible_merge_genfiles_directory");
BuildConfigurationValue host = createExec("--incompatible_merge_genfiles_directory");
assertThat(target.getGenfilesDirectory(RepositoryName.MAIN))
.isEqualTo(target.getBinDirectory(RepositoryName.MAIN));
assertThat(host.getGenfilesDirectory(RepositoryName.MAIN))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,7 @@ protected BuildConfigurationValue getTargetConfiguration() throws InterruptedExc
return universeConfig.getTargetConfiguration();
}

// TODO(b/496767290): rename "host" -> "exec".
protected BuildConfigurationValue getHostConfiguration() {
protected BuildConfigurationValue getExecConfiguration() {
return execConfig;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,7 @@ protected void invalidatePackages(boolean alsoConfigs)
if (alsoConfigs) {
try {
// Also invalidate all configurations. This is important: by invalidating all files we
// invalidate CROSSTOOL, which invalidates CppConfiguration (and a few other fragments). So
// we need to invalidate the {@link SkyframeBuildView#hostConfigurationCache} as well.
// invalidate CROSSTOOL, which invalidates CppConfiguration (and a few other fragments).
// Otherwise we end up with old CppConfiguration instances. Even though they're logically
// equal to the new ones, CppConfiguration has no .equals() method and some production code
// expects equality.
Expand All @@ -600,7 +599,7 @@ protected Iterable<String> getDefaultsForConfiguration() {
}

/**
* Sets host and target configuration using the specified options, falling back to the default
* Sets exec and target configuration using the specified options, falling back to the default
* options for unspecified ones, and recreates the build view.
*
* <p>TODO(juliexxia): when Starlark option parsing exists, find a way to combine these parameters
Expand Down Expand Up @@ -639,17 +638,17 @@ protected void useConfiguration(String... args) throws Exception {
}

/**
* Creates BuildView using current hostConfig/targetConfig values. Ensures that hostConfig is
* either identical to the targetConfig or has 'host' short name.
* Creates BuildView using current execConfig/targetConfig values. Ensures that execConfig is
* either identical to the targetConfig or {@code isExecConfiguration()} is true.
*/
protected final void createBuildView() {
Preconditions.checkNotNull(masterConfig);
Preconditions.checkState(
getHostConfiguration().equals(getTargetConfiguration())
|| getHostConfiguration().isExecConfiguration(),
"Host configuration %s is not an exec configuration' "
getExecConfiguration().equals(getTargetConfiguration())
|| getExecConfiguration().isExecConfiguration(),
"Exec configuration %s is not an exec configuration' "
+ "and does not match target configuration %s",
getHostConfiguration(),
getExecConfiguration(),
getTargetConfiguration());

skyframeExecutor.handleAnalysisInvalidatingChange();
Expand Down Expand Up @@ -1093,19 +1092,19 @@ protected Artifact getArtifact(String label) throws LabelSyntaxException {
}

/**
* Returns the ConfiguredTarget for the specified label, configured for the "host" configuration.
* Returns the ConfiguredTarget for the specified label, configured for the "exec" configuration.
*/
protected ConfiguredTarget getHostConfiguredTarget(String label) throws LabelSyntaxException {
return getConfiguredTarget(label, getHostConfiguration());
protected ConfiguredTarget getExecConfiguredTarget(String label) throws LabelSyntaxException {
return getConfiguredTarget(label, getExecConfiguration());
}

/**
* Returns the ConfiguredTarget for the specified file label, configured for the "host"
* Returns the ConfiguredTarget for the specified file label, configured for the "exec"
* configuration.
*/
protected FileConfiguredTarget getHostFileConfiguredTarget(String label)
protected FileConfiguredTarget getExecFileConfiguredTarget(String label)
throws LabelSyntaxException {
return (FileConfiguredTarget) getHostConfiguredTarget(label);
return (FileConfiguredTarget) getExecConfiguredTarget(label);
}

/** Returns the configurations in which the given label has already been configured. */
Expand Down Expand Up @@ -1942,8 +1941,7 @@ protected BuildConfigurationValue getTargetConfiguration() {
return masterConfig.getTargetConfiguration();
}

// TODO(b/496767290): rename "host" -> "exec".
protected BuildConfigurationValue getHostConfiguration() {
protected BuildConfigurationValue getExecConfiguration() {
return execConfig;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,12 @@ protected BuildConfigurationValue create(
}

/**
* Returns a host {@link BuildConfigurationValue} derived from a target configuration with the
* Returns an exec {@link BuildConfigurationValue} derived from a target configuration with the
* given non-default options.
*
* @param args native option name/pair descriptions in command line form (e.g. "--cpu=k8")
*/
// TODO(b/496767290): rename "host" -> "exec".
protected BuildConfigurationValue createHost(String... args) throws Exception {
protected BuildConfigurationValue createExec(String... args) throws Exception {
return skyframeExecutor.getConfiguration(
reporter,
AnalysisTestUtil.execOptions(parseBuildOptions(args), reporter),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,9 @@ public void testStampingWithNoStamp() throws Exception {
useConfiguration("--nostamp");
createStampingTargets();
assertStamped("//u:foo_stamp");
assertStamped(getHostConfiguredTarget("//u:foo_stamp"));
assertStamped(getExecConfiguredTarget("//u:foo_stamp"));
assertNotStamped("//u:foo_nostamp");
assertNotStamped(getHostConfiguredTarget("//u:foo_nostamp"));
assertNotStamped(getExecConfiguredTarget("//u:foo_nostamp"));
assertNotStamped("//u:foo_default");
}

Expand All @@ -567,9 +567,9 @@ public void testStampingWithStamp() throws Exception {
useConfiguration("--stamp");
createStampingTargets();
assertStamped("//u:foo_stamp");
assertStamped(getHostConfiguredTarget("//u:foo_stamp"));
//assertStamped("//u:foo_nostamp");
assertNotStamped(getHostConfiguredTarget("//u:foo_nostamp"));
assertStamped(getExecConfiguredTarget("//u:foo_stamp"));
// assertStamped("//u:foo_nostamp");
assertNotStamped(getExecConfiguredTarget("//u:foo_nostamp"));
assertNotStamped("//u:foo_default");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,7 @@ public void testProGuardExecutableMatchesConfiguration() throws Exception {
actionsTestUtil()
.getActionForArtifactEndingWith(getFilesToBuild(output), "_proguard.jar");
Artifact jkrunchyExecutable =
getHostConfiguredTarget("//java/com/google/devtools/build/jkrunchy")
getExecConfiguredTarget("//java/com/google/devtools/build/jkrunchy")
.getProvider(FilesToRunProvider.class)
.getExecutable();
assertWithMessage("ProGuard implementation was not correctly taken from the configuration")
Expand Down Expand Up @@ -2223,7 +2223,7 @@ public void useRTxtFromMergedResourcesForFinalRClasses() throws Exception {
+ libResources.getManifest().getExecPathString());

// the "validation artifact" shouldn't be used for creating the top-level resources.jar,
// but it's still fed as an pseudo-input to trigger validation.
// but it's still fed as a pseudo-input to trigger validation.
MoreAsserts.assertDoesNotContainSublist(
topLevelResourceClassAction.getArguments(),
"--library",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void testHostSwiftcopt() throws Exception {

useConfiguration("--swiftcopt=foo", "--host_swiftcopt=bar", "--host_swiftcopt=baz");
ConfiguredTarget target =
getConfiguredTarget("//examples/swift_starlark:my_target", getHostConfiguration());
getConfiguredTarget("//examples/swift_starlark:my_target", getExecConfiguration());

@SuppressWarnings("unchecked")
List<String> copts = (List<String>) getMyInfoFromTarget(target).getValue("copts");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2023,7 +2023,8 @@ public void testImplementationDepsConfigurationHostSucceeds() throws Exception {
" hdrs = ['implementation_dep.h'],",
")");

getHostConfiguredTarget("//foo:public_dep");
assertThat(getExecConfiguredTarget("//foo:public_dep")).isNotNull();
;
assertDoesNotContainEvent("requires --experimental_cc_implementation_deps");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void testHostPerFileCoptsAreInUserCompileFlags() throws Exception {
"--host_per_file_copt=//x:bar\\.cc@-bar",
"--per_file_copt=//x:bin@-baz");

ConfiguredTarget target = getConfiguredTarget("//x:bin", getHostConfiguration());
ConfiguredTarget target = getConfiguredTarget("//x:bin", getExecConfiguration());
CcToolchainVariables variables =
getCppCompileAction(target, "bin").getCompileCommandLine().getVariables();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void testHostGrteTop() throws Exception {
"--host_grte_top=//a/grte/top", "--noincompatible_enable_cc_toolchain_resolution");
BuildConfigurationValue target = getTargetConfiguration();
CcToolchainProvider targetCcProvider = getCcToolchainProvider(target);
BuildConfigurationValue host = getHostConfiguration();
BuildConfigurationValue host = getExecConfiguration();
CcToolchainProvider hostCcProvider = getCcToolchainProvider(host);

testCCFlagsContainsSysroot(host, "a/grte/top", true);
Expand All @@ -88,7 +88,7 @@ public void testOverrideHostGrteTop() throws Exception {
"--noincompatible_enable_cc_toolchain_resolution");
BuildConfigurationValue target = getTargetConfiguration();
CcToolchainProvider targetCcProvider = getCcToolchainProvider(target);
BuildConfigurationValue host = getHostConfiguration();
BuildConfigurationValue host = getExecConfiguration();
CcToolchainProvider hostCcProvider = getCcToolchainProvider(host);

assertThat(targetCcProvider.getSysroot()).isEqualTo("a/grte/top");
Expand Down Expand Up @@ -159,7 +159,7 @@ public void testSysrootWithHostConfig() throws Exception {
// The host BuildConfigurationValue shouldn't provide a sysroot option by default.
for (String cpu : new String[] {"piii", "k8"}) {
useConfiguration("--cpu=" + cpu, "--noincompatible_enable_cc_toolchain_resolution");
BuildConfigurationValue config = getHostConfiguration();
BuildConfigurationValue config = getExecConfiguration();
testCCFlagsContainsSysroot(config, "/usr/grte/v1", true);
}
// The host BuildConfigurationValue should work with label grte_top options.
Expand All @@ -169,7 +169,7 @@ public void testSysrootWithHostConfig() throws Exception {
"--cpu=" + cpu,
"--host_grte_top=//a/grte/top",
"--noincompatible_enable_cc_toolchain_resolution");
BuildConfigurationValue config = getHostConfiguration();
BuildConfigurationValue config = getExecConfiguration();
testCCFlagsContainsSysroot(config, "a/grte/top", true);

// "--grte_top" does *not* set the host grte_top,
Expand All @@ -178,7 +178,7 @@ public void testSysrootWithHostConfig() throws Exception {
"--cpu=" + cpu,
"--grte_top=//a/grte/top",
"--noincompatible_enable_cc_toolchain_resolution");
config = getHostConfiguration();
config = getExecConfiguration();
testCCFlagsContainsSysroot(config, "/usr/grte/v1", true);

// If a host_crosstool_top is set, we shouldn't see the grte_top option in the host config.
Expand All @@ -188,7 +188,7 @@ public void testSysrootWithHostConfig() throws Exception {
"--grte_top=//a/grte/top",
"--host_crosstool_top=" + analysisMock.ccSupport().getMockCrosstoolLabel(),
"--noincompatible_enable_cc_toolchain_resolution");
config = getHostConfiguration();
config = getExecConfiguration();
testCCFlagsContainsSysroot(config, "/usr/grte/v1", true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public void testAppleBuildVariablesMacosHost() throws Exception {
")");
scratch.file("x/a.cc");

ConfiguredTarget target = getHostConfiguredTarget("//x:bin");
ConfiguredTarget target = getExecConfiguredTarget("//x:bin");
Artifact lipoBin =
getBinArtifact(Label.parseCanonical("//x:bin").getName() + "_lipobin", target);
Action lipoAction = getGeneratingAction(lipoBin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void testHostCrosstoolTop() throws Exception {
.isEqualTo(
Label.parseAbsoluteUnchecked(TestConstants.TOOLS_REPOSITORY + "//tools/cpp:toolchain"));

BuildConfigurationValue hostConfig = createHost();
BuildConfigurationValue hostConfig = createExec();
assertThat(hostConfig.getFragment(CppConfiguration.class).getRuleProvidingCcToolchainProvider())
.isEqualTo(
Label.parseAbsoluteUnchecked(TestConstants.TOOLS_REPOSITORY + "//tools/cpp:toolchain"));
Expand Down

0 comments on commit f2cdf9e

Please sign in to comment.