Replace the always omitted CPU environment variable with numberOfProcessors. (#161392)

I am not sure if this is a 1:1 comparison, so please advise.

Towards https://github.com/flutter/flutter/issues/161387.
This commit is contained in:
Matan Lurey 2025-01-09 18:41:05 -08:00 committed by GitHub
parent 4efb64b53a
commit 9bed9d7f95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -426,20 +426,10 @@ Future<void> runDartTest(
List<String>? tags,
bool runSkipped = false,
}) async {
int? cpus;
final String? cpuVariable = Platform.environment['CPU']; // CPU is set in cirrus.yml
if (cpuVariable != null) {
cpus = int.tryParse(cpuVariable, radix: 10);
if (cpus == null) {
foundError(<String>[
'${red}The CPU environment variable, if set, must be set to the integer number of available cores.$reset',
'Actual value: "$cpuVariable"',
]);
return;
}
} else {
cpus = 2; // Don't default to 1, otherwise we won't catch race conditions.
}
// TODO(matanlurey): Consider Platform.numberOfProcessors instead.
// See https://github.com/flutter/flutter/issues/161399.
int cpus = 2;
// Integration tests that depend on external processes like chrome
// can get stuck if there are multiple instances running at once.
if (forceSingleCore) {