Skip to content

Commit

Permalink
Automatic code cleanup.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 606251536
Change-Id: Ib3d8293bc4897f4a311ae842d3f05e5269e18bfc
  • Loading branch information
cpovirk authored and copybara-github committed Feb 12, 2024
1 parent 67e18a2 commit 1f87fb4
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;

import com.google.common.truth.Truth8;
import java.time.Duration;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -74,9 +73,9 @@ public void testBuilder_withNoExecutionTime() {
.setStderrStream(CommandResult.EMPTY_OUTPUT)
.setTerminationStatus(new TerminationStatus(0, false))
.build();
Truth8.assertThat(commandResult.getWallExecutionTime()).isEmpty();
Truth8.assertThat(commandResult.getUserExecutionTime()).isEmpty();
Truth8.assertThat(commandResult.getSystemExecutionTime()).isEmpty();
assertThat(commandResult.getWallExecutionTime()).isEmpty();
assertThat(commandResult.getUserExecutionTime()).isEmpty();
assertThat(commandResult.getSystemExecutionTime()).isEmpty();
}

@Test
Expand All @@ -90,8 +89,8 @@ public void testBuilder_withExecutionTime() {
.setUserExecutionTime(Duration.ofMillis(1492))
.setSystemExecutionTime(Duration.ofMillis(1787))
.build();
Truth8.assertThat(commandResult.getWallExecutionTime()).hasValue(Duration.ofMillis(1929));
Truth8.assertThat(commandResult.getUserExecutionTime()).hasValue(Duration.ofMillis(1492));
Truth8.assertThat(commandResult.getSystemExecutionTime()).hasValue(Duration.ofMillis(1787));
assertThat(commandResult.getWallExecutionTime()).hasValue(Duration.ofMillis(1929));
assertThat(commandResult.getUserExecutionTime()).hasValue(Duration.ofMillis(1492));
assertThat(commandResult.getSystemExecutionTime()).hasValue(Duration.ofMillis(1787));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import static com.google.common.truth.Truth.assertThat;

import com.google.common.truth.Truth8;
import com.google.devtools.build.lib.testutil.TestUtils;
import com.google.devtools.build.lib.vfs.DigestHashFunction;
import com.google.devtools.build.lib.vfs.FileSystem;
Expand Down Expand Up @@ -60,7 +59,7 @@ public void testNoResourceUsage_whenNoResourceUsageProto() throws Exception {

Optional<ExecutionStatistics.ResourceUsage> resourceUsage =
ExecutionStatistics.getResourceUsage(protoFilename);
Truth8.assertThat(resourceUsage).isEmpty();
assertThat(resourceUsage).isEmpty();
}

@Test
Expand Down Expand Up @@ -112,7 +111,7 @@ public void testStatiticsProvided_fromProtoFilename() throws Exception {

Optional<ExecutionStatistics.ResourceUsage> maybeResourceUsage =
ExecutionStatistics.getResourceUsage(protoFilename);
Truth8.assertThat(maybeResourceUsage).isPresent();
assertThat(maybeResourceUsage).isPresent();
ExecutionStatistics.ResourceUsage resourceUsage = maybeResourceUsage.get();

assertThat(resourceUsage.getUserExecutionTime()).isEqualTo(riggedUserExecutionTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import static com.google.common.truth.Truth.assertThat;

import com.google.common.truth.Truth8;
import com.google.devtools.build.lib.vfs.Path;
import java.io.IOException;
import java.time.Duration;
Expand Down Expand Up @@ -56,7 +55,7 @@ public static void executeCommandAndCheckStatisticsAboutCpuTimeSpent(

Optional<ExecutionStatistics.ResourceUsage> resourceUsage =
ExecutionStatistics.getResourceUsage(statisticsFilePath);
Truth8.assertThat(resourceUsage).isPresent();
assertThat(resourceUsage).isPresent();

Duration userTime = resourceUsage.get().getUserExecutionTime();
assertThat(userTime).isAtLeast(userTimeLowerBound);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;

import com.google.common.truth.Truth8;
import java.time.Duration;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -64,9 +63,9 @@ public void testBuilder_withNoTimedOut() {
public void testBuilder_withNoExecutionTime() {
TerminationStatus terminationStatus =
TerminationStatus.builder().setWaitResponse(0).setTimedOut(false).build();
Truth8.assertThat(terminationStatus.getWallExecutionTime()).isEmpty();
Truth8.assertThat(terminationStatus.getUserExecutionTime()).isEmpty();
Truth8.assertThat(terminationStatus.getSystemExecutionTime()).isEmpty();
assertThat(terminationStatus.getWallExecutionTime()).isEmpty();
assertThat(terminationStatus.getUserExecutionTime()).isEmpty();
assertThat(terminationStatus.getSystemExecutionTime()).isEmpty();
}

@Test
Expand All @@ -79,11 +78,11 @@ public void testBuilder_withExecutionTime() {
.setUserExecutionTime(Duration.ofMillis(1492))
.setSystemExecutionTime(Duration.ofMillis(1787))
.build();
Truth8.assertThat(terminationStatus.getWallExecutionTime()).isPresent();
Truth8.assertThat(terminationStatus.getWallExecutionTime()).hasValue(Duration.ofMillis(1929));
Truth8.assertThat(terminationStatus.getUserExecutionTime()).isPresent();
Truth8.assertThat(terminationStatus.getUserExecutionTime()).hasValue(Duration.ofMillis(1492));
Truth8.assertThat(terminationStatus.getSystemExecutionTime()).isPresent();
Truth8.assertThat(terminationStatus.getSystemExecutionTime()).hasValue(Duration.ofMillis(1787));
assertThat(terminationStatus.getWallExecutionTime()).isPresent();
assertThat(terminationStatus.getWallExecutionTime()).hasValue(Duration.ofMillis(1929));
assertThat(terminationStatus.getUserExecutionTime()).isPresent();
assertThat(terminationStatus.getUserExecutionTime()).hasValue(Duration.ofMillis(1492));
assertThat(terminationStatus.getSystemExecutionTime()).isPresent();
assertThat(terminationStatus.getSystemExecutionTime()).hasValue(Duration.ofMillis(1787));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.google.common.truth.Truth8;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.actions.ActionExecutionContext;
import com.google.devtools.build.lib.actions.ActionExecutionContext.LostInputsCheck;
Expand Down Expand Up @@ -142,7 +141,7 @@ public void testUsingOnlyShadowedActionInputs() throws Exception {

assertThat(starlarkAction.getInputs().toList()).isEmpty();
assertThat(starlarkAction.discoversInputs()).isFalse();
Truth8.assertThat(starlarkAction.getUnusedInputsList()).isEmpty();
assertThat(starlarkAction.getUnusedInputsList()).isEmpty();
assertThat(starlarkAction.getAllowedDerivedInputs().toList()).isEmpty();

// If the starlark action does not have any inputs, then it will use the shadowed action inputs
Expand All @@ -159,7 +158,7 @@ public void testUsingOnlyShadowedActionInputs() throws Exception {
assertThat(starlarkAction.getInputs().toList())
.containsExactlyElementsIn(shadowedActionInputs.toList());
assertThat(starlarkAction.discoversInputs()).isFalse();
Truth8.assertThat(starlarkAction.getUnusedInputsList()).isEmpty();
assertThat(starlarkAction.getUnusedInputsList()).isEmpty();
assertThat(starlarkAction.getAllowedDerivedInputs().toList())
.containsExactlyElementsIn(shadowedActionInputs.toList());
}
Expand All @@ -182,7 +181,7 @@ public void testUsingOnlyShadowedActionWithDiscoveredInputs() throws Exception {
collectingAnalysisEnvironment.registerAction(starlarkAction);

assertThat(starlarkAction.getInputs().toList()).isEmpty();
Truth8.assertThat(starlarkAction.getUnusedInputsList()).isEmpty();
assertThat(starlarkAction.getUnusedInputsList()).isEmpty();
assertThat(starlarkAction.getAllowedDerivedInputs().toList()).isEmpty();
assertThat(starlarkAction.discoversInputs()).isTrue();
assertThat(starlarkAction.discoverInputs(executionContext).toList())
Expand All @@ -206,7 +205,7 @@ public void testUsingOnlyShadowedActionWithDiscoveredInputs() throws Exception {

assertThat(starlarkAction.getInputs().toList())
.containsExactlyElementsIn(shadowedActionInputs.toList());
Truth8.assertThat(starlarkAction.getUnusedInputsList()).isEmpty();
assertThat(starlarkAction.getUnusedInputsList()).isEmpty();
assertThat(starlarkAction.getAllowedDerivedInputs().toList())
.containsExactlyElementsIn(shadowedActionInputs.toList());
assertThat(starlarkAction.discoversInputs()).isTrue();
Expand Down Expand Up @@ -236,7 +235,7 @@ public void testUsingShadowedActionWithStarlarkActionInputs() throws Exception {

assertThat(starlarkAction.getInputs().toList())
.containsExactlyElementsIn(starlarkActionInputs.toList());
Truth8.assertThat(starlarkAction.getUnusedInputsList()).isEmpty();
assertThat(starlarkAction.getUnusedInputsList()).isEmpty();
assertThat(starlarkAction.discoversInputs()).isFalse();

// Test using Starlark actions's inputs with shadowed action's inputs
Expand All @@ -258,7 +257,7 @@ public void testUsingShadowedActionWithStarlarkActionInputs() throws Exception {
assertThat(starlarkAction.getInputs().toList())
.containsExactlyElementsIn(
Sets.union(shadowedActionInputs.toSet(), starlarkActionInputs.toSet()));
Truth8.assertThat(starlarkAction.getUnusedInputsList()).isEmpty();
assertThat(starlarkAction.getUnusedInputsList()).isEmpty();
assertThat(starlarkAction.getAllowedDerivedInputs().toList())
.containsExactlyElementsIn(
Sets.union(shadowedActionInputs.toSet(), starlarkActionInputs.toSet()));
Expand All @@ -281,7 +280,7 @@ public void testUsingShadowedActionWithStarlarkActionInputs() throws Exception {
assertThat(starlarkAction.getInputs().toList())
.containsExactlyElementsIn(
Sets.union(shadowedActionInputs.toSet(), starlarkActionInputs.toSet()));
Truth8.assertThat(starlarkAction.getUnusedInputsList()).isEmpty();
assertThat(starlarkAction.getUnusedInputsList()).isEmpty();
assertThat(starlarkAction.getAllowedDerivedInputs().toList())
.containsExactlyElementsIn(
Sets.union(shadowedActionInputs.toSet(), starlarkActionInputs.toSet()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.truth.Truth8;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.actions.ActionOwner;
import com.google.devtools.build.lib.actions.Artifact;
Expand Down Expand Up @@ -8571,7 +8570,7 @@ public void testAspectKeyCreatedOnlyOnceForSameBaseKeysInDiffOrder() throws Exce
assertThat(keysForAspectAOnT3).hasSize(1);

ImmutableList<AspectKey> baseKeys = keysForAspectAOnT3.get(0).getBaseKeys();
Truth8.assertThat(baseKeys.stream().map(k -> k.getAspectClass().getName()))
assertThat(baseKeys.stream().map(k -> k.getAspectClass().getName()))
.containsExactly("//test:defs.bzl%b", "//test:defs.bzl%c")
.inOrder();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.testing.EqualsTester;
import com.google.common.truth.Truth8;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
Expand Down Expand Up @@ -196,7 +195,7 @@ public void builtInAttributesAreNotStarlarkDefined() throws Exception {
Stream<Attribute> builtInAttributes =
getRuleClass("r").getAttributes().stream()
.filter(attr -> !(attr.getName().equals("a") || attr.getName().equals("b")));
Truth8.assertThat(builtInAttributes.map(Attribute::starlarkDefined)).doesNotContain(true);
assertThat(builtInAttributes.map(Attribute::starlarkDefined)).doesNotContain(true);
}

@Test
Expand Down Expand Up @@ -1126,9 +1125,9 @@ public void testRuleDoc() throws Exception {
StarlarkRuleFunction longDocumentedRule =
(StarlarkRuleFunction) ev.lookup("long_documented_rule");
StarlarkRuleFunction undocumentedRule = (StarlarkRuleFunction) ev.lookup("undocumented_rule");
Truth8.assertThat(documentedRule.getDocumentation()).hasValue("My doc string");
Truth8.assertThat(longDocumentedRule.getDocumentation()).hasValue("Long doc\n\nWith details");
Truth8.assertThat(undocumentedRule.getDocumentation()).isEmpty();
assertThat(documentedRule.getDocumentation()).hasValue("My doc string");
assertThat(longDocumentedRule.getDocumentation()).hasValue("Long doc\n\nWith details");
assertThat(undocumentedRule.getDocumentation()).isEmpty();
}

@Test
Expand Down Expand Up @@ -1953,9 +1952,8 @@ public void declaredProviderDocumentation() throws Exception {
(StarlarkProvider) ev.lookup("SchemafulWithoutDocsInfo");
StarlarkProvider schemafulWithDocsInfo = (StarlarkProvider) ev.lookup("SchemafulWithDocsInfo");

Truth8.assertThat(undocumentedInfo.getDocumentation()).isEmpty();
Truth8.assertThat(documentedInfo.getDocumentation())
.hasValue("My documented provider\n\nDetails");
assertThat(undocumentedInfo.getDocumentation()).isEmpty();
assertThat(documentedInfo.getDocumentation()).hasValue("My documented provider\n\nDetails");
assertThat(schemafulWithoutDocsInfo.getSchema())
.containsExactly("b", Optional.empty(), "a", Optional.empty());
assertThat(schemafulWithDocsInfo.getSchema())
Expand Down Expand Up @@ -2433,14 +2431,13 @@ public void aspectDoc() throws Exception {
"undocumented_aspect = aspect(_impl)");

StarlarkDefinedAspect documentedAspect = (StarlarkDefinedAspect) ev.lookup("documented_aspect");
Truth8.assertThat(documentedAspect.getDocumentation()).hasValue("My doc string");
assertThat(documentedAspect.getDocumentation()).hasValue("My doc string");
StarlarkDefinedAspect longDocumentedAspect =
(StarlarkDefinedAspect) ev.lookup("long_documented_aspect");
Truth8.assertThat(longDocumentedAspect.getDocumentation())
.hasValue("My doc string\n\nWith details");
assertThat(longDocumentedAspect.getDocumentation()).hasValue("My doc string\n\nWith details");
StarlarkDefinedAspect undocumentedAspect =
(StarlarkDefinedAspect) ev.lookup("undocumented_aspect");
Truth8.assertThat(undocumentedAspect.getDocumentation()).isEmpty();
assertThat(undocumentedAspect.getDocumentation()).isEmpty();
}

@Test
Expand Down Expand Up @@ -3671,16 +3668,16 @@ public void extendRule_basicUse() throws Exception {
assertNoEvents();
assertThat(rule.getRuleClassObject().isExecutableStarlark()).isFalse();
assertThat(rule.getRuleClassObject().getRuleClassType()).isEqualTo(RuleClassType.NORMAL);
Truth8.assertThat(
assertThat(
Sequence.cast(myInfo.getValue("srcs"), Artifact.class, "srcs").stream()
.map(Artifact::getFilename))
.containsExactly("a.parent");
Truth8.assertThat(
assertThat(
Sequence.cast(myInfo.getValue("deps"), ConfiguredTarget.class, "deps").stream()
.map(ConfiguredTarget::getLabel)
.map(Label::getName))
.containsExactly();
Truth8.assertThat(
assertThat(
Sequence.cast(myInfo.getValue("runtime_deps"), ConfiguredTarget.class, "runtime_deps")
.stream()
.map(ConfiguredTarget::getLabel)
Expand Down Expand Up @@ -3749,17 +3746,17 @@ public void extendRule_withInitializers() throws Exception {
assertNoEvents();
assertThat(rule.getRuleClassObject().isExecutableStarlark()).isFalse();
assertThat(rule.getRuleClassObject().getRuleClassType()).isEqualTo(RuleClassType.NORMAL);
Truth8.assertThat(
assertThat(
Sequence.cast(myInfo.getValue("srcs"), Artifact.class, "srcs").stream()
.map(Artifact::getFilename))
.containsExactly("a.parent");
Truth8.assertThat(
assertThat(
Sequence.cast(myInfo.getValue("deps"), ConfiguredTarget.class, "deps").stream()
.map(ConfiguredTarget::getLabel)
.map(Label::getName))
.containsExactly("dep", "child_dep", "parent_dep")
.inOrder();
Truth8.assertThat(
assertThat(
Sequence.cast(myInfo.getValue("runtime_deps"), ConfiguredTarget.class, "runtime_deps")
.stream()
.map(ConfiguredTarget::getLabel)
Expand Down Expand Up @@ -4001,13 +3998,13 @@ public void extendRule_attributeAdditionalAspects() throws Exception {

assertThat(rule.getRuleClassObject().isExecutableStarlark()).isFalse();
assertThat(rule.getRuleClassObject().getRuleClassType()).isEqualTo(RuleClassType.NORMAL);
Truth8.assertThat(
assertThat(
rule.getRuleClassObject().getAttributeByName("deps").getAspectClasses().stream()
.map(AspectClass::toString))
.containsExactly(
"//extend_rule_testing/parent:parent.bzl%parent_aspect",
"//extend_rule_testing:child.bzl%my_aspect");
Truth8.assertThat(
assertThat(
rule.getRuleClassObject().getAttributeByName("tool").getAspectClasses().stream()
.map(AspectClass::toString))
.containsExactly("//extend_rule_testing:child.bzl%my_aspect");
Expand Down Expand Up @@ -4098,12 +4095,12 @@ public void extendRule_attributeOverrideDefault() throws Exception {
StarlarkInfo parentInfo = (StarlarkInfo) myTarget.get(parentInfoKey);

assertNoEvents();
Truth8.assertThat(
assertThat(
Sequence.cast(parentInfo.getValue("deps"), ConfiguredTarget.class, "deps").stream()
.map(ConfiguredTarget::getLabel)
.map(Label::getName))
.containsExactly("dep");
Truth8.assertThat(
assertThat(
Sequence.cast(parentInfo.getValue("tools"), ConfiguredTarget.class, "tools").stream()
.map(ConfiguredTarget::getLabel)
.map(Label::getName))
Expand Down Expand Up @@ -4521,7 +4518,7 @@ public void extendRule_toolchains_merged() throws Exception {
Rule rule = getRuleContext(myTarget).getRule();

assertNoEvents();
Truth8.assertThat(
assertThat(
rule.getRuleClassObject().getToolchainTypes().stream()
.map(ToolchainTypeRequirement::toolchainType)
.map(Label::toString))
Expand Down Expand Up @@ -4554,7 +4551,7 @@ public void extendRule_advertisedProviders_merged() throws Exception {
Rule rule = getRuleContext(myTarget).getRule();

assertNoEvents();
Truth8.assertThat(
assertThat(
rule.getRuleClassObject().getAdvertisedProviders().getStarlarkProviders().stream()
.map(StarlarkProviderIdentifier::getKey)
.map(key -> ((StarlarkProvider.Key) key).getExportedName()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.truth.Truth8;
import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.ExecException;
Expand Down Expand Up @@ -676,7 +675,7 @@ public void testCreateStarlarkActionArgumentsWithUnusedInputsList() throws Excep
(StarlarkAction)
Iterables.getOnlyElement(
ruleContext.getRuleContext().getAnalysisEnvironment().getRegisteredActions());
Truth8.assertThat(action.getUnusedInputsList()).isPresent();
assertThat(action.getUnusedInputsList()).isPresent();
assertThat(action.getUnusedInputsList().get().getFilename()).isEqualTo("a.txt");
assertThat(action.discoversInputs()).isTrue();
assertThat(action.isShareable()).isFalse();
Expand Down Expand Up @@ -922,7 +921,7 @@ public void testCreateStarlarkActionArgumentsWithoutUnusedInputsList() throws Ex
(StarlarkAction)
Iterables.getOnlyElement(
ruleContext.getRuleContext().getAnalysisEnvironment().getRegisteredActions());
Truth8.assertThat(action.getUnusedInputsList()).isEmpty();
assertThat(action.getUnusedInputsList()).isEmpty();
assertThat(action.discoversInputs()).isFalse();
}

Expand Down
Loading

0 comments on commit 1f87fb4

Please sign in to comment.