mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add sysctl file fallbacks (#71623)
This commit is contained in:
parent
bf8313f8fc
commit
a8bed5e405
@ -301,8 +301,26 @@ class _MacOSUtils extends _PosixUtils {
|
|||||||
@override
|
@override
|
||||||
HostPlatform get hostPlatform {
|
HostPlatform get hostPlatform {
|
||||||
if (_hostPlatform == null) {
|
if (_hostPlatform == null) {
|
||||||
|
String sysctlPath;
|
||||||
|
if (which('sysctl') == null) {
|
||||||
|
// Fallback to known install locations.
|
||||||
|
for (final String path in <String>[
|
||||||
|
'/usr/sbin/sysctl',
|
||||||
|
'/sbin/sysctl',
|
||||||
|
]) {
|
||||||
|
if (_fileSystem.isFileSync(path)) {
|
||||||
|
sysctlPath = path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sysctlPath = 'sysctl';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sysctlPath == null) {
|
||||||
|
throwToolExit('sysctl not found. Try adding it to your PATH environment variable.');
|
||||||
|
}
|
||||||
final RunResult arm64Check =
|
final RunResult arm64Check =
|
||||||
_processUtils.runSync(<String>['sysctl', 'hw.optional.arm64']);
|
_processUtils.runSync(<String>[sysctlPath, 'hw.optional.arm64']);
|
||||||
// On arm64 stdout is "sysctl hw.optional.arm64: 1"
|
// On arm64 stdout is "sysctl hw.optional.arm64: 1"
|
||||||
// On x86 hw.optional.arm64 is unavailable and exits with 1.
|
// On x86 hw.optional.arm64 is unavailable and exits with 1.
|
||||||
if (arm64Check.exitCode == 0 && arm64Check.stdout.trim().endsWith('1')) {
|
if (arm64Check.exitCode == 0 && arm64Check.stdout.trim().endsWith('1')) {
|
||||||
|
@ -16,6 +16,13 @@ import 'package:flutter_tools/src/reporting/reporting.dart';
|
|||||||
import '../../src/common.dart';
|
import '../../src/common.dart';
|
||||||
import '../../src/context.dart';
|
import '../../src/context.dart';
|
||||||
|
|
||||||
|
const FakeCommand kWhichSysctlCommand = FakeCommand(
|
||||||
|
command: <String>[
|
||||||
|
'which',
|
||||||
|
'sysctl',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
const FakeCommand kARMCheckCommand = FakeCommand(
|
const FakeCommand kARMCheckCommand = FakeCommand(
|
||||||
command: <String>[
|
command: <String>[
|
||||||
'sysctl',
|
'sysctl',
|
||||||
@ -255,9 +262,11 @@ void main() {
|
|||||||
testWithoutContext('builds iOS with bitcode', () async {
|
testWithoutContext('builds iOS with bitcode', () async {
|
||||||
final String outputPath = fileSystem.path.join('build', 'foo');
|
final String outputPath = fileSystem.path.join('build', 'foo');
|
||||||
final String assembly = fileSystem.path.join(outputPath, 'snapshot_assembly.S');
|
final String assembly = fileSystem.path.join(outputPath, 'snapshot_assembly.S');
|
||||||
processManager.addCommand(FakeCommand(
|
processManager.addCommands(<FakeCommand>[
|
||||||
command: <String>[
|
FakeCommand(command: <String>[
|
||||||
artifacts.getArtifactPath(Artifact.genSnapshot, platform: TargetPlatform.ios, mode: BuildMode.profile) +'_armv7',
|
artifacts.getArtifactPath(Artifact.genSnapshot,
|
||||||
|
platform: TargetPlatform.ios, mode: BuildMode.profile) +
|
||||||
|
'_armv7',
|
||||||
'--deterministic',
|
'--deterministic',
|
||||||
'--snapshot_kind=app-aot-assembly',
|
'--snapshot_kind=app-aot-assembly',
|
||||||
'--assembly=$assembly',
|
'--assembly=$assembly',
|
||||||
@ -267,11 +276,10 @@ void main() {
|
|||||||
'--no-causal-async-stacks',
|
'--no-causal-async-stacks',
|
||||||
'--lazy-async-stacks',
|
'--lazy-async-stacks',
|
||||||
'main.dill',
|
'main.dill',
|
||||||
]
|
]),
|
||||||
));
|
kWhichSysctlCommand,
|
||||||
processManager.addCommand(kARMCheckCommand);
|
kARMCheckCommand,
|
||||||
processManager.addCommand(const FakeCommand(
|
const FakeCommand(command: <String>[
|
||||||
command: <String>[
|
|
||||||
'xcrun',
|
'xcrun',
|
||||||
'cc',
|
'cc',
|
||||||
'-arch',
|
'-arch',
|
||||||
@ -283,17 +291,15 @@ void main() {
|
|||||||
'build/foo/snapshot_assembly.S',
|
'build/foo/snapshot_assembly.S',
|
||||||
'-o',
|
'-o',
|
||||||
'build/foo/snapshot_assembly.o',
|
'build/foo/snapshot_assembly.o',
|
||||||
]
|
]),
|
||||||
));
|
const FakeCommand(command: <String>[
|
||||||
processManager.addCommand(const FakeCommand(
|
|
||||||
command: <String>[
|
|
||||||
'xcrun',
|
'xcrun',
|
||||||
'clang',
|
'clang',
|
||||||
'-arch',
|
'-arch',
|
||||||
'armv7',
|
'armv7',
|
||||||
...kBitcodeClang,
|
...kBitcodeClang,
|
||||||
]
|
]),
|
||||||
));
|
]);
|
||||||
|
|
||||||
final int genSnapshotExitCode = await snapshotter.build(
|
final int genSnapshotExitCode = await snapshotter.build(
|
||||||
platform: TargetPlatform.ios,
|
platform: TargetPlatform.ios,
|
||||||
@ -315,9 +321,11 @@ void main() {
|
|||||||
final String outputPath = fileSystem.path.join('build', 'foo');
|
final String outputPath = fileSystem.path.join('build', 'foo');
|
||||||
final String assembly = fileSystem.path.join(outputPath, 'snapshot_assembly.S');
|
final String assembly = fileSystem.path.join(outputPath, 'snapshot_assembly.S');
|
||||||
final String debugPath = fileSystem.path.join('foo', 'app.ios-armv7.symbols');
|
final String debugPath = fileSystem.path.join('foo', 'app.ios-armv7.symbols');
|
||||||
processManager.addCommand(FakeCommand(
|
processManager.addCommands(<FakeCommand>[
|
||||||
command: <String>[
|
FakeCommand(command: <String>[
|
||||||
artifacts.getArtifactPath(Artifact.genSnapshot, platform: TargetPlatform.ios, mode: BuildMode.profile) +'_armv7',
|
artifacts.getArtifactPath(Artifact.genSnapshot,
|
||||||
|
platform: TargetPlatform.ios, mode: BuildMode.profile) +
|
||||||
|
'_armv7',
|
||||||
'--deterministic',
|
'--deterministic',
|
||||||
'--snapshot_kind=app-aot-assembly',
|
'--snapshot_kind=app-aot-assembly',
|
||||||
'--assembly=$assembly',
|
'--assembly=$assembly',
|
||||||
@ -329,11 +337,10 @@ void main() {
|
|||||||
'--dwarf-stack-traces',
|
'--dwarf-stack-traces',
|
||||||
'--save-debugging-info=$debugPath',
|
'--save-debugging-info=$debugPath',
|
||||||
'main.dill',
|
'main.dill',
|
||||||
]
|
]),
|
||||||
));
|
kWhichSysctlCommand,
|
||||||
processManager.addCommand(kARMCheckCommand);
|
kARMCheckCommand,
|
||||||
processManager.addCommand(const FakeCommand(
|
const FakeCommand(command: <String>[
|
||||||
command: <String>[
|
|
||||||
'xcrun',
|
'xcrun',
|
||||||
'cc',
|
'cc',
|
||||||
'-arch',
|
'-arch',
|
||||||
@ -344,17 +351,15 @@ void main() {
|
|||||||
'build/foo/snapshot_assembly.S',
|
'build/foo/snapshot_assembly.S',
|
||||||
'-o',
|
'-o',
|
||||||
'build/foo/snapshot_assembly.o',
|
'build/foo/snapshot_assembly.o',
|
||||||
]
|
]),
|
||||||
));
|
const FakeCommand(command: <String>[
|
||||||
processManager.addCommand(const FakeCommand(
|
|
||||||
command: <String>[
|
|
||||||
'xcrun',
|
'xcrun',
|
||||||
'clang',
|
'clang',
|
||||||
'-arch',
|
'-arch',
|
||||||
'armv7',
|
'armv7',
|
||||||
...kDefaultClang,
|
...kDefaultClang,
|
||||||
]
|
]),
|
||||||
));
|
]);
|
||||||
|
|
||||||
final int genSnapshotExitCode = await snapshotter.build(
|
final int genSnapshotExitCode = await snapshotter.build(
|
||||||
platform: TargetPlatform.ios,
|
platform: TargetPlatform.ios,
|
||||||
@ -375,9 +380,11 @@ void main() {
|
|||||||
testWithoutContext('builds iOS armv7 snapshot with obfuscate', () async {
|
testWithoutContext('builds iOS armv7 snapshot with obfuscate', () async {
|
||||||
final String outputPath = fileSystem.path.join('build', 'foo');
|
final String outputPath = fileSystem.path.join('build', 'foo');
|
||||||
final String assembly = fileSystem.path.join(outputPath, 'snapshot_assembly.S');
|
final String assembly = fileSystem.path.join(outputPath, 'snapshot_assembly.S');
|
||||||
processManager.addCommand(FakeCommand(
|
processManager.addCommands(<FakeCommand>[
|
||||||
command: <String>[
|
FakeCommand(command: <String>[
|
||||||
artifacts.getArtifactPath(Artifact.genSnapshot, platform: TargetPlatform.ios, mode: BuildMode.profile) +'_armv7',
|
artifacts.getArtifactPath(Artifact.genSnapshot,
|
||||||
|
platform: TargetPlatform.ios, mode: BuildMode.profile) +
|
||||||
|
'_armv7',
|
||||||
'--deterministic',
|
'--deterministic',
|
||||||
'--snapshot_kind=app-aot-assembly',
|
'--snapshot_kind=app-aot-assembly',
|
||||||
'--assembly=$assembly',
|
'--assembly=$assembly',
|
||||||
@ -388,11 +395,10 @@ void main() {
|
|||||||
'--lazy-async-stacks',
|
'--lazy-async-stacks',
|
||||||
'--obfuscate',
|
'--obfuscate',
|
||||||
'main.dill',
|
'main.dill',
|
||||||
]
|
]),
|
||||||
));
|
kWhichSysctlCommand,
|
||||||
processManager.addCommand(kARMCheckCommand);
|
kARMCheckCommand,
|
||||||
processManager.addCommand(const FakeCommand(
|
const FakeCommand(command: <String>[
|
||||||
command: <String>[
|
|
||||||
'xcrun',
|
'xcrun',
|
||||||
'cc',
|
'cc',
|
||||||
'-arch',
|
'-arch',
|
||||||
@ -403,17 +409,15 @@ void main() {
|
|||||||
'build/foo/snapshot_assembly.S',
|
'build/foo/snapshot_assembly.S',
|
||||||
'-o',
|
'-o',
|
||||||
'build/foo/snapshot_assembly.o',
|
'build/foo/snapshot_assembly.o',
|
||||||
]
|
]),
|
||||||
));
|
const FakeCommand(command: <String>[
|
||||||
processManager.addCommand(const FakeCommand(
|
|
||||||
command: <String>[
|
|
||||||
'xcrun',
|
'xcrun',
|
||||||
'clang',
|
'clang',
|
||||||
'-arch',
|
'-arch',
|
||||||
'armv7',
|
'armv7',
|
||||||
...kDefaultClang,
|
...kDefaultClang,
|
||||||
]
|
]),
|
||||||
));
|
]);
|
||||||
|
|
||||||
final int genSnapshotExitCode = await snapshotter.build(
|
final int genSnapshotExitCode = await snapshotter.build(
|
||||||
platform: TargetPlatform.ios,
|
platform: TargetPlatform.ios,
|
||||||
@ -434,9 +438,11 @@ void main() {
|
|||||||
|
|
||||||
testWithoutContext('builds iOS armv7 snapshot', () async {
|
testWithoutContext('builds iOS armv7 snapshot', () async {
|
||||||
final String outputPath = fileSystem.path.join('build', 'foo');
|
final String outputPath = fileSystem.path.join('build', 'foo');
|
||||||
processManager.addCommand(FakeCommand(
|
processManager.addCommands(<FakeCommand>[
|
||||||
command: <String>[
|
FakeCommand(command: <String>[
|
||||||
artifacts.getArtifactPath(Artifact.genSnapshot, platform: TargetPlatform.ios, mode: BuildMode.release) +'_armv7',
|
artifacts.getArtifactPath(Artifact.genSnapshot,
|
||||||
|
platform: TargetPlatform.ios, mode: BuildMode.release) +
|
||||||
|
'_armv7',
|
||||||
'--deterministic',
|
'--deterministic',
|
||||||
'--snapshot_kind=app-aot-assembly',
|
'--snapshot_kind=app-aot-assembly',
|
||||||
'--assembly=${fileSystem.path.join(outputPath, 'snapshot_assembly.S')}',
|
'--assembly=${fileSystem.path.join(outputPath, 'snapshot_assembly.S')}',
|
||||||
@ -446,11 +452,10 @@ void main() {
|
|||||||
'--no-causal-async-stacks',
|
'--no-causal-async-stacks',
|
||||||
'--lazy-async-stacks',
|
'--lazy-async-stacks',
|
||||||
'main.dill',
|
'main.dill',
|
||||||
]
|
]),
|
||||||
));
|
kWhichSysctlCommand,
|
||||||
processManager.addCommand(kARMCheckCommand);
|
kARMCheckCommand,
|
||||||
processManager.addCommand(const FakeCommand(
|
const FakeCommand(command: <String>[
|
||||||
command: <String>[
|
|
||||||
'xcrun',
|
'xcrun',
|
||||||
'cc',
|
'cc',
|
||||||
'-arch',
|
'-arch',
|
||||||
@ -461,17 +466,15 @@ void main() {
|
|||||||
'build/foo/snapshot_assembly.S',
|
'build/foo/snapshot_assembly.S',
|
||||||
'-o',
|
'-o',
|
||||||
'build/foo/snapshot_assembly.o',
|
'build/foo/snapshot_assembly.o',
|
||||||
]
|
]),
|
||||||
));
|
const FakeCommand(command: <String>[
|
||||||
processManager.addCommand(const FakeCommand(
|
|
||||||
command: <String>[
|
|
||||||
'xcrun',
|
'xcrun',
|
||||||
'clang',
|
'clang',
|
||||||
'-arch',
|
'-arch',
|
||||||
'armv7',
|
'armv7',
|
||||||
...kDefaultClang,
|
...kDefaultClang,
|
||||||
]
|
]),
|
||||||
));
|
]);
|
||||||
|
|
||||||
final int genSnapshotExitCode = await snapshotter.build(
|
final int genSnapshotExitCode = await snapshotter.build(
|
||||||
platform: TargetPlatform.ios,
|
platform: TargetPlatform.ios,
|
||||||
@ -491,9 +494,11 @@ void main() {
|
|||||||
|
|
||||||
testWithoutContext('builds iOS arm64 snapshot', () async {
|
testWithoutContext('builds iOS arm64 snapshot', () async {
|
||||||
final String outputPath = fileSystem.path.join('build', 'foo');
|
final String outputPath = fileSystem.path.join('build', 'foo');
|
||||||
processManager.addCommand(FakeCommand(
|
processManager.addCommands(<FakeCommand>[
|
||||||
command: <String>[
|
FakeCommand(command: <String>[
|
||||||
artifacts.getArtifactPath(Artifact.genSnapshot, platform: TargetPlatform.ios, mode: BuildMode.release) +'_arm64',
|
artifacts.getArtifactPath(Artifact.genSnapshot,
|
||||||
|
platform: TargetPlatform.ios, mode: BuildMode.release) +
|
||||||
|
'_arm64',
|
||||||
'--deterministic',
|
'--deterministic',
|
||||||
'--snapshot_kind=app-aot-assembly',
|
'--snapshot_kind=app-aot-assembly',
|
||||||
'--assembly=${fileSystem.path.join(outputPath, 'snapshot_assembly.S')}',
|
'--assembly=${fileSystem.path.join(outputPath, 'snapshot_assembly.S')}',
|
||||||
@ -501,11 +506,10 @@ void main() {
|
|||||||
'--no-causal-async-stacks',
|
'--no-causal-async-stacks',
|
||||||
'--lazy-async-stacks',
|
'--lazy-async-stacks',
|
||||||
'main.dill',
|
'main.dill',
|
||||||
]
|
]),
|
||||||
));
|
kWhichSysctlCommand,
|
||||||
processManager.addCommand(kARMCheckCommand);
|
kARMCheckCommand,
|
||||||
processManager.addCommand(const FakeCommand(
|
const FakeCommand(command: <String>[
|
||||||
command: <String>[
|
|
||||||
'xcrun',
|
'xcrun',
|
||||||
'cc',
|
'cc',
|
||||||
'-arch',
|
'-arch',
|
||||||
@ -516,17 +520,15 @@ void main() {
|
|||||||
'build/foo/snapshot_assembly.S',
|
'build/foo/snapshot_assembly.S',
|
||||||
'-o',
|
'-o',
|
||||||
'build/foo/snapshot_assembly.o',
|
'build/foo/snapshot_assembly.o',
|
||||||
]
|
]),
|
||||||
));
|
const FakeCommand(command: <String>[
|
||||||
processManager.addCommand(const FakeCommand(
|
|
||||||
command: <String>[
|
|
||||||
'xcrun',
|
'xcrun',
|
||||||
'clang',
|
'clang',
|
||||||
'-arch',
|
'-arch',
|
||||||
'arm64',
|
'arm64',
|
||||||
...kDefaultClang,
|
...kDefaultClang,
|
||||||
]
|
]),
|
||||||
));
|
]);
|
||||||
|
|
||||||
final int genSnapshotExitCode = await snapshotter.build(
|
final int genSnapshotExitCode = await snapshotter.build(
|
||||||
platform: TargetPlatform.ios,
|
platform: TargetPlatform.ios,
|
||||||
|
@ -167,7 +167,14 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWithoutContext('macOS ARM', () async {
|
testWithoutContext('macOS ARM', () async {
|
||||||
fakeProcessManager.addCommand(
|
fakeProcessManager.addCommands(
|
||||||
|
<FakeCommand>[
|
||||||
|
const FakeCommand(
|
||||||
|
command: <String>[
|
||||||
|
'which',
|
||||||
|
'sysctl',
|
||||||
|
],
|
||||||
|
),
|
||||||
const FakeCommand(
|
const FakeCommand(
|
||||||
command: <String>[
|
command: <String>[
|
||||||
'sysctl',
|
'sysctl',
|
||||||
@ -175,6 +182,7 @@ void main() {
|
|||||||
],
|
],
|
||||||
stdout: 'hw.optional.arm64: 1',
|
stdout: 'hw.optional.arm64: 1',
|
||||||
),
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
final OperatingSystemUtils utils =
|
final OperatingSystemUtils utils =
|
||||||
@ -183,7 +191,14 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWithoutContext('macOS 11 x86', () async {
|
testWithoutContext('macOS 11 x86', () async {
|
||||||
fakeProcessManager.addCommand(
|
fakeProcessManager.addCommands(
|
||||||
|
<FakeCommand>[
|
||||||
|
const FakeCommand(
|
||||||
|
command: <String>[
|
||||||
|
'which',
|
||||||
|
'sysctl',
|
||||||
|
],
|
||||||
|
),
|
||||||
const FakeCommand(
|
const FakeCommand(
|
||||||
command: <String>[
|
command: <String>[
|
||||||
'sysctl',
|
'sysctl',
|
||||||
@ -191,6 +206,7 @@ void main() {
|
|||||||
],
|
],
|
||||||
stdout: 'hw.optional.arm64: 0',
|
stdout: 'hw.optional.arm64: 0',
|
||||||
),
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
final OperatingSystemUtils utils =
|
final OperatingSystemUtils utils =
|
||||||
@ -198,8 +214,33 @@ void main() {
|
|||||||
expect(utils.hostPlatform, HostPlatform.darwin_x64);
|
expect(utils.hostPlatform, HostPlatform.darwin_x64);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWithoutContext('sysctl not found', () async {
|
||||||
|
fakeProcessManager.addCommands(
|
||||||
|
<FakeCommand>[
|
||||||
|
const FakeCommand(
|
||||||
|
command: <String>[
|
||||||
|
'which',
|
||||||
|
'sysctl',
|
||||||
|
],
|
||||||
|
exitCode: 1,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
final OperatingSystemUtils utils =
|
||||||
|
createOSUtils(FakePlatform(operatingSystem: 'macos'));
|
||||||
|
expect(() => utils.hostPlatform, throwsToolExit(message: 'sysctl'));
|
||||||
|
});
|
||||||
|
|
||||||
testWithoutContext('macOS 10 x86', () async {
|
testWithoutContext('macOS 10 x86', () async {
|
||||||
fakeProcessManager.addCommand(
|
fakeProcessManager.addCommands(
|
||||||
|
<FakeCommand>[
|
||||||
|
const FakeCommand(
|
||||||
|
command: <String>[
|
||||||
|
'which',
|
||||||
|
'sysctl',
|
||||||
|
],
|
||||||
|
),
|
||||||
const FakeCommand(
|
const FakeCommand(
|
||||||
command: <String>[
|
command: <String>[
|
||||||
'sysctl',
|
'sysctl',
|
||||||
@ -207,6 +248,7 @@ void main() {
|
|||||||
],
|
],
|
||||||
exitCode: 1,
|
exitCode: 1,
|
||||||
),
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
final OperatingSystemUtils utils =
|
final OperatingSystemUtils utils =
|
||||||
@ -237,6 +279,12 @@ void main() {
|
|||||||
],
|
],
|
||||||
stdout: 'build',
|
stdout: 'build',
|
||||||
),
|
),
|
||||||
|
const FakeCommand(
|
||||||
|
command: <String>[
|
||||||
|
'which',
|
||||||
|
'sysctl',
|
||||||
|
],
|
||||||
|
),
|
||||||
const FakeCommand(
|
const FakeCommand(
|
||||||
command: <String>[
|
command: <String>[
|
||||||
'sysctl',
|
'sysctl',
|
||||||
@ -274,6 +322,12 @@ void main() {
|
|||||||
],
|
],
|
||||||
stdout: 'build',
|
stdout: 'build',
|
||||||
),
|
),
|
||||||
|
const FakeCommand(
|
||||||
|
command: <String>[
|
||||||
|
'which',
|
||||||
|
'sysctl',
|
||||||
|
],
|
||||||
|
),
|
||||||
const FakeCommand(
|
const FakeCommand(
|
||||||
command: <String>[
|
command: <String>[
|
||||||
'sysctl',
|
'sysctl',
|
||||||
|
@ -50,6 +50,8 @@ void main() {
|
|||||||
|
|
||||||
// Work around https://github.com/flutter/flutter/issues/56415.
|
// Work around https://github.com/flutter/flutter/issues/56415.
|
||||||
testWithoutContext('xcodebuild versionText returns null when xcodebuild is not installed', () {
|
testWithoutContext('xcodebuild versionText returns null when xcodebuild is not installed', () {
|
||||||
|
when(processManager.runSync(<String>['which', 'sysctl']))
|
||||||
|
.thenReturn(ProcessResult(0, 0, '', ''));
|
||||||
when(processManager.runSync(<String>['sysctl', 'hw.optional.arm64']))
|
when(processManager.runSync(<String>['sysctl', 'hw.optional.arm64']))
|
||||||
.thenReturn(ProcessResult(0, 1, '', ''));
|
.thenReturn(ProcessResult(0, 1, '', ''));
|
||||||
when(processManager.runSync(<String>['xcrun', 'xcodebuild', '-version']))
|
when(processManager.runSync(<String>['xcrun', 'xcodebuild', '-version']))
|
||||||
@ -66,6 +68,8 @@ void main() {
|
|||||||
);
|
);
|
||||||
platform.environment = const <String, String>{};
|
platform.environment = const <String, String>{};
|
||||||
|
|
||||||
|
when(processManager.runSync(<String>['which', 'sysctl']))
|
||||||
|
.thenReturn(ProcessResult(0, 0, '', ''));
|
||||||
when(processManager.runSync(<String>['sysctl', 'hw.optional.arm64']))
|
when(processManager.runSync(<String>['sysctl', 'hw.optional.arm64']))
|
||||||
.thenReturn(ProcessResult(0, 1, '', ''));
|
.thenReturn(ProcessResult(0, 1, '', ''));
|
||||||
|
|
||||||
@ -79,6 +83,13 @@ void main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const FakeCommand kWhichSysctlCommand = FakeCommand(
|
||||||
|
command: <String>[
|
||||||
|
'which',
|
||||||
|
'sysctl',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
const FakeCommand kARMCheckCommand = FakeCommand(
|
const FakeCommand kARMCheckCommand = FakeCommand(
|
||||||
command: <String>[
|
command: <String>[
|
||||||
'sysctl',
|
'sysctl',
|
||||||
@ -115,6 +126,7 @@ void main() {
|
|||||||
|
|
||||||
testWithoutContext('xcodebuild versionText returns null when xcodebuild is not fully installed', () {
|
testWithoutContext('xcodebuild versionText returns null when xcodebuild is not fully installed', () {
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
kARMCheckCommand,
|
kARMCheckCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||||
@ -131,6 +143,7 @@ void main() {
|
|||||||
|
|
||||||
testWithoutContext('xcodebuild versionText returns formatted version text', () {
|
testWithoutContext('xcodebuild versionText returns formatted version text', () {
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
kARMCheckCommand,
|
kARMCheckCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||||
@ -144,6 +157,7 @@ void main() {
|
|||||||
|
|
||||||
testWithoutContext('xcodebuild versionText handles Xcode version string with unexpected format', () {
|
testWithoutContext('xcodebuild versionText handles Xcode version string with unexpected format', () {
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
kARMCheckCommand,
|
kARMCheckCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||||
@ -157,6 +171,7 @@ void main() {
|
|||||||
|
|
||||||
testWithoutContext('xcodebuild version parts can be parsed', () {
|
testWithoutContext('xcodebuild version parts can be parsed', () {
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
kARMCheckCommand,
|
kARMCheckCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||||
@ -172,6 +187,7 @@ void main() {
|
|||||||
|
|
||||||
testWithoutContext('xcodebuild minor and patch version default to 0', () {
|
testWithoutContext('xcodebuild minor and patch version default to 0', () {
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
kARMCheckCommand,
|
kARMCheckCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||||
@ -187,6 +203,7 @@ void main() {
|
|||||||
|
|
||||||
testWithoutContext('xcodebuild version parts is null when version has unexpected format', () {
|
testWithoutContext('xcodebuild version parts is null when version has unexpected format', () {
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
kARMCheckCommand,
|
kARMCheckCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||||
@ -225,6 +242,7 @@ void main() {
|
|||||||
testWithoutContext(
|
testWithoutContext(
|
||||||
'xcodebuild isInstalled is false when Xcode is not fully installed', () {
|
'xcodebuild isInstalled is false when Xcode is not fully installed', () {
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
kARMCheckCommand,
|
kARMCheckCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||||
@ -241,6 +259,7 @@ void main() {
|
|||||||
|
|
||||||
testWithoutContext('xcodebuild isInstalled is false when version has unexpected format', () {
|
testWithoutContext('xcodebuild isInstalled is false when version has unexpected format', () {
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
kARMCheckCommand,
|
kARMCheckCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||||
@ -254,6 +273,7 @@ void main() {
|
|||||||
|
|
||||||
testWithoutContext('xcodebuild isInstalled is true when version has expected format', () {
|
testWithoutContext('xcodebuild isInstalled is true when version has expected format', () {
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
kARMCheckCommand,
|
kARMCheckCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||||
@ -267,6 +287,7 @@ void main() {
|
|||||||
|
|
||||||
testWithoutContext('xcrun runs natively on arm64', () {
|
testWithoutContext('xcrun runs natively on arm64', () {
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>[
|
command: <String>[
|
||||||
'sysctl',
|
'sysctl',
|
||||||
@ -288,6 +309,7 @@ void main() {
|
|||||||
platform.environment = const <String, String>{};
|
platform.environment = const <String, String>{};
|
||||||
|
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>[
|
command: <String>[
|
||||||
'sysctl',
|
'sysctl',
|
||||||
@ -317,6 +339,7 @@ void main() {
|
|||||||
platform.environment = const <String, String>{};
|
platform.environment = const <String, String>{};
|
||||||
|
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
kARMCheckCommand,
|
kARMCheckCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>[
|
command: <String>[
|
||||||
@ -340,6 +363,7 @@ void main() {
|
|||||||
'FLUTTER_XCODE_ARCHS': 'arm64'
|
'FLUTTER_XCODE_ARCHS': 'arm64'
|
||||||
};
|
};
|
||||||
fakeProcessManager.addCommands(<FakeCommand>[
|
fakeProcessManager.addCommands(<FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
kARMCheckCommand,
|
kARMCheckCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>[
|
command: <String>[
|
||||||
@ -366,6 +390,7 @@ void main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
kARMCheckCommand,
|
kARMCheckCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>[
|
command: <String>[
|
||||||
@ -390,6 +415,7 @@ void main() {
|
|||||||
testWithoutContext('xcodebuild -list getInfo returns something when xcodebuild -list succeeds', () async {
|
testWithoutContext('xcodebuild -list getInfo returns something when xcodebuild -list succeeds', () async {
|
||||||
const String workingDirectory = '/';
|
const String workingDirectory = '/';
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
kARMCheckCommand,
|
kARMCheckCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>['xcrun', 'xcodebuild', '-list'],
|
command: <String>['xcrun', 'xcodebuild', '-list'],
|
||||||
@ -414,6 +440,7 @@ void main() {
|
|||||||
const String stderr = 'Useful Xcode failure message about missing project.';
|
const String stderr = 'Useful Xcode failure message about missing project.';
|
||||||
|
|
||||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||||
|
kWhichSysctlCommand,
|
||||||
kARMCheckCommand,
|
kARMCheckCommand,
|
||||||
FakeCommand(
|
FakeCommand(
|
||||||
command: <String>['xcrun', 'xcodebuild', '-list'],
|
command: <String>['xcrun', 'xcodebuild', '-list'],
|
||||||
|
@ -460,6 +460,8 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
|
|||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync('Existing Podfile');
|
..writeAsStringSync('Existing Podfile');
|
||||||
|
|
||||||
|
when(mockProcessManager.runSync(<String>['which', 'sysctl']))
|
||||||
|
.thenReturn(ProcessResult(0, 0, '', ''));
|
||||||
when(mockProcessManager.runSync(<String>['sysctl', 'hw.optional.arm64']))
|
when(mockProcessManager.runSync(<String>['sysctl', 'hw.optional.arm64']))
|
||||||
.thenReturn(ProcessResult(0, 0, 'hw.optional.arm64: 1', ''));
|
.thenReturn(ProcessResult(0, 0, 'hw.optional.arm64: 1', ''));
|
||||||
|
|
||||||
@ -497,6 +499,8 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
|
|||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync('Existing Podfile');
|
..writeAsStringSync('Existing Podfile');
|
||||||
|
|
||||||
|
when(mockProcessManager.runSync(<String>['which', 'sysctl']))
|
||||||
|
.thenReturn(ProcessResult(0, 0, '', ''));
|
||||||
when(mockProcessManager.runSync(<String>['sysctl', 'hw.optional.arm64']))
|
when(mockProcessManager.runSync(<String>['sysctl', 'hw.optional.arm64']))
|
||||||
.thenReturn(ProcessResult(0, 1, '', ''));
|
.thenReturn(ProcessResult(0, 1, '', ''));
|
||||||
|
|
||||||
|
@ -65,6 +65,8 @@ void main() {
|
|||||||
testWithoutContext('eulaSigned is false when clang is not installed', () {
|
testWithoutContext('eulaSigned is false when clang is not installed', () {
|
||||||
when(mockXcodeProjectInterpreter.xcrunCommand()).thenReturn(<String>['xcrun']);
|
when(mockXcodeProjectInterpreter.xcrunCommand()).thenReturn(<String>['xcrun']);
|
||||||
|
|
||||||
|
when(processManager.runSync(<String>['which', 'sysctl']))
|
||||||
|
.thenReturn(ProcessResult(1, 0, '', ''));
|
||||||
when(processManager.runSync(<String>['sysctl', 'hw.optional.arm64']))
|
when(processManager.runSync(<String>['sysctl', 'hw.optional.arm64']))
|
||||||
.thenReturn(ProcessResult(123, 1, '', ''));
|
.thenReturn(ProcessResult(123, 1, '', ''));
|
||||||
when(processManager.runSync(<String>['xcrun', 'clang']))
|
when(processManager.runSync(<String>['xcrun', 'clang']))
|
||||||
|
Loading…
Reference in New Issue
Block a user