Add Locale.US to String.format
Not having Locale.US set caused some tests to fail because strings were
different (i.e. `5,00s` instead of `5.00s`).
Closes #5705.
PiperOrigin-RevId: 210543454
diff --git a/src/main/java/com/google/devtools/build/lib/actions/SpawnResult.java b/src/main/java/com/google/devtools/build/lib/actions/SpawnResult.java
index 65a8417..418bf07 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/SpawnResult.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/SpawnResult.java
@@ -330,9 +330,11 @@
}
if (status() == Status.TIMEOUT) {
if (getWallTime().isPresent()) {
- explanation += String.format(
- " (failed due to timeout after %.2f seconds.)",
- getWallTime().get().toMillis() / 1000.0);
+ explanation +=
+ String.format(
+ Locale.US,
+ " (failed due to timeout after %.2f seconds.)",
+ getWallTime().get().toMillis() / 1000.0);
} else {
explanation += " (failed due to timeout.)";
}
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/TestSummaryPrinter.java b/src/main/java/com/google/devtools/build/lib/runtime/TestSummaryPrinter.java
index b1371fe..10e78e7 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/TestSummaryPrinter.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/TestSummaryPrinter.java
@@ -27,6 +27,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
@@ -204,7 +205,7 @@
*/
static String timeInSec(long time, TimeUnit unit) {
double ms = TimeUnit.MILLISECONDS.convert(time, unit);
- return String.format("%.1fs", ms / 1000.0);
+ return String.format(Locale.US, "%.1fs", ms / 1000.0);
}
static String getAttemptSummary(TestSummary summary) {
@@ -228,7 +229,8 @@
} else if (summary.getNumCached() == summary.totalRuns()) {
return "(cached) ";
} else {
- return String.format("(%d/%d cached) ", summary.getNumCached(), summary.totalRuns());
+ return String.format(
+ Locale.US, "(%d/%d cached) ", summary.getNumCached(), summary.totalRuns());
}
}
@@ -258,6 +260,7 @@
// distribution of times on the next line.
String maxTime = timeInSec(max, TimeUnit.MILLISECONDS);
return String.format(
+ Locale.US,
" in %s\n Stats over %d runs: max = %s, min = %s, avg = %s, dev = %s",
maxTime,
summary.getTestTimes().size(),