diff --git a/packages/flutter_goldens/test/flutter_goldens_test.dart b/packages/flutter_goldens/test/flutter_goldens_test.dart index 74468da9b0..b680c0f475 100644 --- a/packages/flutter_goldens/test/flutter_goldens_test.dart +++ b/packages/flutter_goldens/test/flutter_goldens_test.dart @@ -210,7 +210,7 @@ void main() { ); }); - test('Creates traceID correctly', () { + test('Creates traceID correctly', () async { String traceID; platform = FakePlatform( environment: { @@ -231,11 +231,19 @@ void main() { httpClient: fakeHttpClient, ); - traceID = skiaClient.getTraceID('flutter.golden.1'); - + RunInvocation md5 = const RunInvocation( + [ + 'md5', + '-s', + '{"CI":"luci","Platform":"linux","name":"flutter.golden.1","source_type":"flutter"}', + ], + null, + ); + process.processResults[md5] = ProcessResult(12345678, 0, '12345678', ''); + traceID = await skiaClient.getTraceID('flutter.golden.1'); expect( traceID, - equals(',CI=luci,Platform=linux,name=flutter.golden.1,source_type=flutter,'), + equals('12345678'), ); // Browser @@ -258,12 +266,19 @@ void main() { platform: platform, httpClient: fakeHttpClient, ); - - traceID = skiaClient.getTraceID('flutter.golden.1'); - + md5 = const RunInvocation( + [ + 'md5', + '-s', + '{"Browser":"chrome","CI":"luci","Platform":"linux","name":"flutter.golden.1","source_type":"flutter"}', + ], + null, + ); + process.processResults[md5] = ProcessResult(12345678, 0, '12345678', ''); + traceID = await skiaClient.getTraceID('flutter.golden.1'); expect( traceID, - equals(',Browser=chrome,CI=luci,Platform=linux,name=flutter.golden.1,source_type=flutter,'), + equals('12345678'), ); // Locally - should defer to luci traceID @@ -281,12 +296,19 @@ void main() { platform: platform, httpClient: fakeHttpClient, ); - - traceID = skiaClient.getTraceID('flutter.golden.1'); - + md5 = const RunInvocation( + [ + 'md5', + '-s', + '{"CI":"luci","Platform":"macos","name":"flutter.golden.1","source_type":"flutter"}', + ], + null, + ); + process.processResults[md5] = ProcessResult(12345678, 0, '12345678', ''); + traceID = await skiaClient.getTraceID('flutter.golden.1'); expect( traceID, - equals(',CI=luci,Platform=macos,name=flutter.golden.1,source_type=flutter,'), + equals('12345678'), ); }); diff --git a/packages/flutter_goldens_client/lib/skia_client.dart b/packages/flutter_goldens_client/lib/skia_client.dart index 66bdc7133b..7193c630b0 100644 --- a/packages/flutter_goldens_client/lib/skia_client.dart +++ b/packages/flutter_goldens_client/lib/skia_client.dart @@ -285,10 +285,10 @@ class SkiaGoldClient { /// Gold at head. Future getExpectationForTest(String testName) async { late String? expectation; - final String traceID = getTraceID(testName); + final String traceID = await getTraceID(testName); await io.HttpOverrides.runWithHttpOverrides>(() async { final Uri requestForExpectations = Uri.parse( - 'https://flutter-gold.skia.org/json/v1/latestpositivedigest/$traceID' + 'https://flutter-gold.skia.org/json/v2/latestpositivedigest/$traceID' ); late String rawResponse; try { @@ -410,20 +410,20 @@ class SkiaGoldClient { } /// Returns a trace id based on the current testing environment to lookup - /// the latest positive digest on Flutter Gold. - /// - /// Trace IDs are case sensitive and should be in alphabetical order for the - /// keys, followed by the rest of the paramset, also in alphabetical order. - /// There should also be leading and trailing commas. - /// - /// Example TraceID for Flutter Gold: - /// ',CI=cirrus,Platform=linux,name=cupertino.activityIndicator.inprogress.1.0,source_type=flutter,' - String getTraceID(String testName) { - return '${platform.environment[_kTestBrowserKey] == null ? ',' : ',Browser=${platform.environment[_kTestBrowserKey]},'}' - 'CI=luci,' - 'Platform=${platform.operatingSystem},' - 'name=$testName,' - 'source_type=flutter,'; + /// the latest positive digest on Flutter Gold with a hex-encoded md5 hash of + /// the image keys. + Future getTraceID(String testName) async { + final Map keys = { + if (platform.environment[_kTestBrowserKey] != null) 'Browser' : platform.environment[_kTestBrowserKey], + 'CI' : 'luci', + 'Platform' : platform.operatingSystem, + 'name' : testName, + 'source_type' : 'flutter', + }; + final String jsonTrace = json.encode(keys); + final io.ProcessResult md5Result = await process.run(['md5', '-s', jsonTrace]); + final String md5Sum = md5Result.stdout.toString().split(' ').last.trim(); + return md5Sum; } }