@@ -7,6 +7,8 @@ import 'dart:convert';
7
7
8
8
import 'package:file/file.dart' ;
9
9
import 'package:flutter_tools/src/base/io.dart' ;
10
+ import 'package:flutter_tools/src/base/logger.dart' ;
11
+ import 'package:flutter_tools/src/base/os.dart' ;
10
12
11
13
import '../src/common.dart' ;
12
14
import 'test_utils.dart' ;
@@ -48,6 +50,40 @@ Future<void> main() async {
48
50
expect (stdout, contains ('Successfully received SIGTERM!' ));
49
51
},
50
52
skip: platform.isWindows); // [intended] Windows does not use the bash entrypoint
53
+
54
+ test ('verify the dart binary arch matches the host arch' , () async {
55
+ final HostPlatform dartArch = _identifyBinaryArch (dartBinary.path);
56
+ final OperatingSystemUtils os = OperatingSystemUtils (
57
+ processManager: processManager,
58
+ fileSystem: fileSystem,
59
+ platform: platform,
60
+ logger: BufferLogger .test (),
61
+ );
62
+ expect (dartArch, os.hostPlatform);
63
+ }, skip: ! platform.isMacOS); // [intended] Calls macOS-specific commands
64
+ }
65
+
66
+ // Call `file` on the path and parse the output.
67
+ // This is macOS-specific.
68
+ HostPlatform _identifyBinaryArch (String path) {
69
+ // Expect STDOUT like:
70
+ // bin/cache/dart-sdk/bin/dart: Mach-O 64-bit executable x86_64
71
+ final RegExp pattern = RegExp (r'Mach-O 64-bit executable (\w+)' );
72
+ final ProcessResult result = processManager.runSync (
73
+ < String > ['file' , dartBinary.path],
74
+ );
75
+ final RegExpMatch ? match = pattern.firstMatch (result.stdout as String );
76
+ if (match == null ) {
77
+ fail ('Unrecognized STDOUT from `file`: "${result .stdout }"' );
78
+ }
79
+ switch (match.group (1 )) {
80
+ case 'x86_64' :
81
+ return HostPlatform .darwin_x64;
82
+ case 'arm64' :
83
+ return HostPlatform .darwin_arm;
84
+ default :
85
+ fail ('Unexpected architecture ${match .group (1 )}' );
86
+ }
51
87
}
52
88
53
89
// A test Dart app that will run until it receives SIGTERM
@@ -69,3 +105,14 @@ File get dartBash {
69
105
.childFile ('dart' )
70
106
.absolute;
71
107
}
108
+
109
+ // The executable bash entrypoint for the Dart binary.
110
+ File get dartBinary {
111
+ return flutterRoot
112
+ .childDirectory ('bin' )
113
+ .childDirectory ('cache' )
114
+ .childDirectory ('dart-sdk' )
115
+ .childDirectory ('bin' )
116
+ .childFile ('dart' )
117
+ .absolute;
118
+ }
0 commit comments