Commit 89d72a12 authored by Kate Lovett's avatar Kate Lovett Committed by Flutter GitHub Bot

Throwing when goldctl cannot authorize/initialize (#45925)

parent fba96809
......@@ -53,9 +53,10 @@ void main() {
group('SkiaGoldClient', () {
SkiaGoldClient skiaClient;
Directory workDirectory;
setUp(() {
final Directory workDirectory = fs.directory('/workDirectory')
workDirectory = fs.directory('/workDirectory')
..createSync(recursive: true);
skiaClient = SkiaGoldClient(
workDirectory,
......@@ -66,20 +67,91 @@ void main() {
);
});
group('auth', () {
test('performs minimal work if already authorized', () async {
fs.file('/workDirectory/temp/auth_opt.json')
..createSync(recursive: true);
when(process.run(any))
.thenAnswer((_) => Future<ProcessResult>
.value(ProcessResult(123, 0, '', '')));
await skiaClient.auth();
verifyNever(process.run(
captureAny,
workingDirectory: captureAnyNamed('workingDirectory'),
));
});
test('auth performs minimal work if already authorized', () async {
fs.file('/workDirectory/temp/auth_opt.json')
..createSync(recursive: true);
when(process.run(any))
.thenAnswer((_) => Future<ProcessResult>
.value(ProcessResult(123, 0, '', '')));
await skiaClient.auth();
verifyNever(process.run(
captureAny,
workingDirectory: captureAnyNamed('workingDirectory'),
));
});
test('throws for error state from auth', () async {
platform = FakePlatform(
environment: <String, String>{
'FLUTTER_ROOT': _kFlutterRoot,
'GOLD_SERVICE_ACCOUNT' : 'Service Account',
'GOLDCTL' : 'goldctl',
},
operatingSystem: 'macos'
);
skiaClient = SkiaGoldClient(
workDirectory,
fs: fs,
process: process,
platform: platform,
httpClient: mockHttpClient,
);
when(process.run(any))
.thenAnswer((_) => Future<ProcessResult>
.value(ProcessResult(123, 1, 'fail', 'fail')));
final Future<void> test = skiaClient.auth();
expect(
test,
throwsException,
);
});
test(' throws for error state from init', () {
platform = FakePlatform(
environment: <String, String>{
'FLUTTER_ROOT': _kFlutterRoot,
'GOLDCTL' : 'goldctl',
},
operatingSystem: 'macos'
);
skiaClient = SkiaGoldClient(
workDirectory,
fs: fs,
process: process,
platform: platform,
httpClient: mockHttpClient,
);
when(process.run(
<String>['git', 'rev-parse', 'HEAD'],
workingDirectory: '/flutter',
)).thenAnswer((_) => Future<ProcessResult>
.value(ProcessResult(12345678, 0, '12345678', '')));
when(process.run(
<String>[
'goldctl',
'imgtest', 'init',
'--instance', 'flutter',
'--work-dir', '/workDirectory/temp',
'--commit', '12345678',
'--keys-file', '/workDirectory/keys.json',
'--failure-file', '/workDirectory/failures.json',
'--passfail',
],
)).thenAnswer((_) => Future<ProcessResult>
.value(ProcessResult(123, 1, 'fail', 'fail')));
final Future<void> test = skiaClient.imgtestInit();
expect(
test,
throwsException,
);
});
group('Request Handling', () {
......
......@@ -128,8 +128,11 @@ class SkiaGoldClient {
);
if (result.exitCode != 0) {
print('goldctl auth stdout: ${result.stdout}');
print('goldctl auth stderr: ${result.stderr}');
final StringBuffer buf = StringBuffer()
..writeln('Skia Gold auth failed.')
..writeln('stdout: ${result.stdout}')
..writeln('stderr: ${result.stderr}');
throw NonZeroExitCode(1, buf.toString());
}
}
......@@ -170,8 +173,11 @@ class SkiaGoldClient {
);
if (result.exitCode != 0) {
print('goldctl imgtest init stdout: ${result.stdout}');
print('goldctl imgtest init stderr: ${result.stderr}');
final StringBuffer buf = StringBuffer()
..writeln('Skia Gold imgtest init failed.')
..writeln('stdout: ${result.stdout}')
..writeln('stderr: ${result.stderr}');
throw NonZeroExitCode(1, buf.toString());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment