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;
|
String traceID;
|
||||||
platform = FakePlatform(
|
platform = FakePlatform(
|
||||||
environment: <String, String>{
|
environment: <String, String>{
|
||||||
@ -231,11 +231,19 @@ void main() {
|
|||||||
httpClient: fakeHttpClient,
|
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(
|
expect(
|
||||||
traceID,
|
traceID,
|
||||||
equals(',CI=luci,Platform=linux,name=flutter.golden.1,source_type=flutter,'),
|
equals('12345678'),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Browser
|
// Browser
|
||||||
@ -258,12 +266,19 @@ void main() {
|
|||||||
platform: platform,
|
platform: platform,
|
||||||
httpClient: fakeHttpClient,
|
httpClient: fakeHttpClient,
|
||||||
);
|
);
|
||||||
|
md5 = const RunInvocation(
|
||||||
traceID = skiaClient.getTraceID('flutter.golden.1');
|
<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(
|
expect(
|
||||||
traceID,
|
traceID,
|
||||||
equals(',Browser=chrome,CI=luci,Platform=linux,name=flutter.golden.1,source_type=flutter,'),
|
equals('12345678'),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Locally - should defer to luci traceID
|
// Locally - should defer to luci traceID
|
||||||
@ -281,12 +296,19 @@ void main() {
|
|||||||
platform: platform,
|
platform: platform,
|
||||||
httpClient: fakeHttpClient,
|
httpClient: fakeHttpClient,
|
||||||
);
|
);
|
||||||
|
md5 = const RunInvocation(
|
||||||
traceID = skiaClient.getTraceID('flutter.golden.1');
|
<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(
|
expect(
|
||||||
traceID,
|
traceID,
|
||||||
equals(',CI=luci,Platform=macos,name=flutter.golden.1,source_type=flutter,'),
|
equals('12345678'),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -285,10 +285,10 @@ class SkiaGoldClient {
|
|||||||
/// Gold at head.
|
/// Gold at head.
|
||||||
Future<String?> getExpectationForTest(String testName) async {
|
Future<String?> getExpectationForTest(String testName) async {
|
||||||
late String? expectation;
|
late String? expectation;
|
||||||
final String traceID = getTraceID(testName);
|
final String traceID = await getTraceID(testName);
|
||||||
await io.HttpOverrides.runWithHttpOverrides<Future<void>>(() async {
|
await io.HttpOverrides.runWithHttpOverrides<Future<void>>(() async {
|
||||||
final Uri requestForExpectations = Uri.parse(
|
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;
|
late String rawResponse;
|
||||||
try {
|
try {
|
||||||
@ -410,20 +410,20 @@ class SkiaGoldClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a trace id based on the current testing environment to lookup
|
/// Returns a trace id based on the current testing environment to lookup
|
||||||
/// the latest positive digest on Flutter Gold.
|
/// the latest positive digest on Flutter Gold with a hex-encoded md5 hash of
|
||||||
///
|
/// the image keys.
|
||||||
/// Trace IDs are case sensitive and should be in alphabetical order for the
|
Future<String> getTraceID(String testName) async {
|
||||||
/// keys, followed by the rest of the paramset, also in alphabetical order.
|
final Map<String, dynamic> keys = <String, dynamic>{
|
||||||
/// There should also be leading and trailing commas.
|
if (platform.environment[_kTestBrowserKey] != null) 'Browser' : platform.environment[_kTestBrowserKey],
|
||||||
///
|
'CI' : 'luci',
|
||||||
/// Example TraceID for Flutter Gold:
|
'Platform' : platform.operatingSystem,
|
||||||
/// ',CI=cirrus,Platform=linux,name=cupertino.activityIndicator.inprogress.1.0,source_type=flutter,'
|
'name' : testName,
|
||||||
String getTraceID(String testName) {
|
'source_type' : 'flutter',
|
||||||
return '${platform.environment[_kTestBrowserKey] == null ? ',' : ',Browser=${platform.environment[_kTestBrowserKey]},'}'
|
};
|
||||||
'CI=luci,'
|
final String jsonTrace = json.encode(keys);
|
||||||
'Platform=${platform.operatingSystem},'
|
final io.ProcessResult md5Result = await process.run(<String>['md5', '-s', jsonTrace]);
|
||||||
'name=$testName,'
|
final String md5Sum = md5Result.stdout.toString().split(' ').last.trim();
|
||||||
'source_type=flutter,';
|
return md5Sum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user