Update local gold api (#90072)
This commit is contained in:
parent
7d368dcf0c
commit
8587b609a6
@ -210,7 +210,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('Creates traceID correctly', () {
|
||||
test('Creates traceID correctly', () async {
|
||||
String traceID;
|
||||
platform = FakePlatform(
|
||||
environment: <String, String>{
|
||||
@ -231,11 +231,19 @@ void main() {
|
||||
httpClient: fakeHttpClient,
|
||||
);
|
||||
|
||||
traceID = skiaClient.getTraceID('flutter.golden.1');
|
||||
|
||||
RunInvocation md5 = const RunInvocation(
|
||||
<String>[
|
||||
'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(
|
||||
<String>[
|
||||
'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(
|
||||
<String>[
|
||||
'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'),
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -285,10 +285,10 @@ class SkiaGoldClient {
|
||||
/// Gold at head.
|
||||
Future<String?> getExpectationForTest(String testName) async {
|
||||
late String? expectation;
|
||||
final String traceID = getTraceID(testName);
|
||||
final String traceID = await getTraceID(testName);
|
||||
await io.HttpOverrides.runWithHttpOverrides<Future<void>>(() 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<String> getTraceID(String testName) async {
|
||||
final Map<String, dynamic> keys = <String, dynamic>{
|
||||
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(<String>['md5', '-s', jsonTrace]);
|
||||
final String md5Sum = md5Result.stdout.toString().split(' ').last.trim();
|
||||
return md5Sum;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user