fix cast error in codesign sub-command (#86890)
This commit is contained in:
parent
03de61664e
commit
93b358f912
@ -316,9 +316,15 @@ class CodesignCommand extends Command<void> {
|
|||||||
'Test failed because unexpected binaries found in the cache.');
|
'Test failed because unexpected binaries found in the cache.');
|
||||||
}
|
}
|
||||||
|
|
||||||
stdio.printStatus(
|
final String? desiredRevision = argResults![kRevision] as String?;
|
||||||
'Verified that binaries for commit ${argResults![kRevision] as String} are codesigned and have '
|
if (desiredRevision == null) {
|
||||||
'expected entitlements.');
|
stdio.printStatus(
|
||||||
|
'Verified that binaries are codesigned and have expected entitlements.');
|
||||||
|
} else {
|
||||||
|
stdio.printStatus(
|
||||||
|
'Verified that binaries for commit $desiredRevision are codesigned and have '
|
||||||
|
'expected entitlements.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String>? _allBinaryPaths;
|
List<String>? _allBinaryPaths;
|
||||||
|
@ -81,6 +81,90 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('does not fail if --revision flag not provided', () async {
|
||||||
|
final List<FakeCommand> codesignCheckCommands = <FakeCommand>[];
|
||||||
|
for (final String bin in binariesWithEntitlements) {
|
||||||
|
codesignCheckCommands.add(
|
||||||
|
FakeCommand(
|
||||||
|
command: <String>['codesign', '-vvv', bin],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
codesignCheckCommands.add(
|
||||||
|
FakeCommand(
|
||||||
|
command: <String>['codesign', '--display', '--entitlements', ':-', bin],
|
||||||
|
stdout: expectedEntitlements.join('\n'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
for (final String bin in binariesWithoutEntitlements) {
|
||||||
|
codesignCheckCommands.add(
|
||||||
|
FakeCommand(
|
||||||
|
command: <String>['codesign', '-vvv', bin],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
createRunner(commands: <FakeCommand>[
|
||||||
|
const FakeCommand(command: <String>[
|
||||||
|
'git',
|
||||||
|
'clone',
|
||||||
|
'--origin',
|
||||||
|
'upstream',
|
||||||
|
'--',
|
||||||
|
'file://$flutterRoot/',
|
||||||
|
'${checkoutsParentDirectory}flutter_conductor_checkouts/framework',
|
||||||
|
]),
|
||||||
|
const FakeCommand(command: <String>[
|
||||||
|
'git',
|
||||||
|
'rev-parse',
|
||||||
|
'HEAD',
|
||||||
|
], stdout: revision),
|
||||||
|
const FakeCommand(command: <String>[
|
||||||
|
'git',
|
||||||
|
'rev-parse',
|
||||||
|
'HEAD',
|
||||||
|
], stdout: revision),
|
||||||
|
const FakeCommand(command: <String>[
|
||||||
|
'git',
|
||||||
|
'checkout',
|
||||||
|
revision,
|
||||||
|
]),
|
||||||
|
const FakeCommand(command: <String>[
|
||||||
|
flutterBin,
|
||||||
|
'help',
|
||||||
|
]),
|
||||||
|
const FakeCommand(command: <String>[
|
||||||
|
flutterBin,
|
||||||
|
'help',
|
||||||
|
]),
|
||||||
|
const FakeCommand(command: <String>[
|
||||||
|
flutterBin,
|
||||||
|
'precache',
|
||||||
|
'--android',
|
||||||
|
'--ios',
|
||||||
|
'--macos',
|
||||||
|
]),
|
||||||
|
FakeCommand(
|
||||||
|
command: const <String>[
|
||||||
|
'find',
|
||||||
|
'${checkoutsParentDirectory}flutter_conductor_checkouts/framework/bin/cache',
|
||||||
|
'-type',
|
||||||
|
'f',
|
||||||
|
],
|
||||||
|
stdout: allBinaries.join('\n'),
|
||||||
|
),
|
||||||
|
for (String bin in allBinaries)
|
||||||
|
FakeCommand(
|
||||||
|
command: <String>['file', '--mime-type', '-b', bin],
|
||||||
|
stdout: 'application/x-mach-binary',
|
||||||
|
),
|
||||||
|
...codesignCheckCommands,
|
||||||
|
]);
|
||||||
|
await runner.run(<String>['codesign', '--$kVerify']);
|
||||||
|
expect(processManager.hasRemainingExpectations, false);
|
||||||
|
expect(stdio.stdout, contains('Verified that binaries are codesigned and have expected entitlements'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
test('succeeds if every binary is codesigned and has correct entitlements', () async {
|
test('succeeds if every binary is codesigned and has correct entitlements', () async {
|
||||||
final List<FakeCommand> codesignCheckCommands = <FakeCommand>[];
|
final List<FakeCommand> codesignCheckCommands = <FakeCommand>[];
|
||||||
for (final String bin in binariesWithEntitlements) {
|
for (final String bin in binariesWithEntitlements) {
|
||||||
@ -156,6 +240,7 @@ void main() {
|
|||||||
]);
|
]);
|
||||||
await runner.run(<String>['codesign', '--$kVerify', '--$kRevision', revision]);
|
await runner.run(<String>['codesign', '--$kVerify', '--$kRevision', revision]);
|
||||||
expect(processManager.hasRemainingExpectations, false);
|
expect(processManager.hasRemainingExpectations, false);
|
||||||
|
expect(stdio.stdout, contains('Verified that binaries for commit $revision are codesigned and have expected entitlements'));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('fails if a single binary is not codesigned', () async {
|
test('fails if a single binary is not codesigned', () async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user