Change the default architecture in test.py from x64 to host.

This brings test.py into agreement with build.py, and makes development on arm64 hosts nicer.

Change-Id: Ic544b4eee0e27d9f395328297ed6108d4e4689f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257800
Reviewed-by: Jonas Termansen <sortie@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2022-12-15 20:41:33 +00:00 committed by Commit Queue
parent 8e1162cb72
commit 933d2cf4e7
2 changed files with 41 additions and 2 deletions

View file

@ -622,6 +622,45 @@ class Architecture extends NamedEnum {
}
const Architecture._(String name) : super(name);
static final Architecture host = _computeHost();
static Architecture _computeHost() {
String? arch;
if (Platform.isWindows) {
arch = Platform.environment["PROCESSOR_ARCHITECTURE"];
} else {
arch = (Process.runSync("uname", ["-m"]).stdout as String).trim();
}
switch (arch) {
case "i386":
case "i686":
case "ia32":
case "x86":
case "X86":
return ia32;
case "x64":
case "x86-64":
case "x86_64":
case "amd64":
case "AMD64":
return x64;
case "armv7l":
case "ARM":
return arm;
case "aarch64":
case "arm64":
case "arm64e":
case "ARM64":
return arm64;
case "riscv32":
return riscv32;
case "riscv64":
return riscv64;
}
throw "Unknown host architecture: $arch";
}
}
class Compiler extends NamedEnum {

View file

@ -107,7 +107,7 @@ none: No runtime, compile only.''')
..addMultiOption('arch',
abbr: 'a',
allowed: ['all', ...Architecture.names],
defaultsTo: [Architecture.x64.name],
defaultsTo: [Architecture.host.name],
hide: true,
help: '''The architecture to run tests for.
@ -935,7 +935,7 @@ void findConfigurations(Map<String, dynamic> options) {
var architectureOption = options['arch'] as List<String>;
var architectures = [
if (architectureOption.isEmpty)
Architecture.x64
Architecture.host
else if (!architectureOption.contains('all'))
...architectureOption.map(Architecture.find)
];