[flutter_conductor] fix conductor codesign --upstream flag (#101782)

This commit is contained in:
Christopher Fujino 2022-04-13 10:39:05 -07:00 committed by GitHub
parent a20cd33d67
commit 462427d53c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 94 additions and 0 deletions

View File

@ -75,6 +75,10 @@ class CodesignCommand extends Command<void> {
FrameworkRepository get framework {
return _framework ??= FrameworkRepository(
checkouts,
upstreamRemote: Remote(
name: RemoteName.upstream,
url: argResults![kUpstream] as String,
),
);
}

View File

@ -167,6 +167,96 @@ void main() {
expect(stdio.stdout, contains('Verified that binaries are codesigned and have expected entitlements'));
});
test('framework cloned from repo provided by --$kUpstream', () async {
const String upstreamRepo = 'https://githost.org/org/project';
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',
'--',
upstreamRepo,
'${checkoutsParentDirectory}flutter_conductor_checkouts/framework',
]),
const FakeCommand(command: <String>[
'git',
'checkout',
FrameworkRepository.defaultBranch,
]),
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',
'--$kRevision',
revision,
'--$kUpstream',
upstreamRepo,
]);
expect(processManager, hasNoRemainingExpectations);
expect(stdio.stdout, contains('Verified that binaries for commit $revision are codesigned and have expected entitlements'));
});
test('succeeds if every binary is codesigned and has correct entitlements', () async {
final List<FakeCommand> codesignCheckCommands = <FakeCommand>[];