Unverified Commit f7d2bcdf authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

nnbd annotation in flutter_goldens_client (#59069)

parent 6067571f
...@@ -93,13 +93,13 @@ class SkiaGoldClient { ...@@ -93,13 +93,13 @@ class SkiaGoldClient {
/// The path to the local [Directory] where the goldctl tool is hosted. /// The path to the local [Directory] where the goldctl tool is hosted.
/// ///
/// Uses the [platform] environment in this implementation. /// Uses the [platform] environment in this implementation.
String get _goldctl => platform.environment[_kGoldctlKey]; String/*!*/ get _goldctl => platform.environment[_kGoldctlKey];
/// The path to the local [Directory] where the service account key is /// The path to the local [Directory] where the service account key is
/// hosted. /// hosted.
/// ///
/// Uses the [platform] environment in this implementation. /// Uses the [platform] environment in this implementation.
String get _serviceAccount => platform.environment[_kServiceAccountKey]; String/*!*/ get _serviceAccount => platform.environment[_kServiceAccountKey];
/// Prepares the local work space for golden file testing and calls the /// Prepares the local work space for golden file testing and calls the
/// goldctl `auth` command. /// goldctl `auth` command.
...@@ -116,9 +116,9 @@ class SkiaGoldClient { ...@@ -116,9 +116,9 @@ class SkiaGoldClient {
return; return;
List<String> authArguments; List<String> authArguments;
String failureContext; /*late*/ String failureContext;
switch (ci) { switch (ci/*!*/) {
case ContinuousIntegrationEnvironment.luci: case ContinuousIntegrationEnvironment.luci:
authArguments = <String>[ authArguments = <String>[
'auth', 'auth',
...@@ -378,7 +378,7 @@ class SkiaGoldClient { ...@@ -378,7 +378,7 @@ class SkiaGoldClient {
imgtestArguments, imgtestArguments,
); );
final String resultStdout = result.stdout.toString(); final String/*!*/ resultStdout = result.stdout.toString();
if (result.exitCode != 0 && if (result.exitCode != 0 &&
!(resultStdout.contains('Untriaged') || resultStdout.contains('negative image'))) { !(resultStdout.contains('Untriaged') || resultStdout.contains('negative image'))) {
final StringBuffer buf = StringBuffer() final StringBuffer buf = StringBuffer()
...@@ -508,8 +508,8 @@ class SkiaGoldClient { ...@@ -508,8 +508,8 @@ class SkiaGoldClient {
rawResponse = await utf8.decodeStream(response); rawResponse = await utf8.decodeStream(response);
final List<dynamic> ignores = json.decode(rawResponse) as List<dynamic>; final List<dynamic> ignores = json.decode(rawResponse) as List<dynamic>;
for(final dynamic ignore in ignores) { for(final dynamic ignore in ignores) {
final List<String> ignoredQueries = (ignore['query'] as String).split('&'); final List<String> ignoredQueries = (ignore['query'] as String/*!*/).split('&');
final String ignoredPullRequest = (ignore['note'] as String).split('/').last; final String ignoredPullRequest = (ignore['note'] as String/*!*/).split('/').last;
final DateTime expiration = DateTime.parse(ignore['expires'] as String); final DateTime expiration = DateTime.parse(ignore['expires'] as String);
// The currently failing test is in the process of modification. // The currently failing test is in the process of modification.
if (ignoredQueries.contains('name=$testName')) { if (ignoredQueries.contains('name=$testName')) {
...@@ -589,15 +589,16 @@ class SkiaGoldClient { ...@@ -589,15 +589,16 @@ class SkiaGoldClient {
/// Returns the current commit hash of the Flutter repository. /// Returns the current commit hash of the Flutter repository.
Future<String> _getCurrentCommit() async { Future<String> _getCurrentCommit() async {
if (!_flutterRoot.existsSync()) { if (!_flutterRoot.existsSync()) {
final StringBuffer buf = StringBuffer() throw Exception('Flutter root could not be found: $_flutterRoot\n');
..writeln('Flutter root could not be found: $_flutterRoot');
throw Exception(buf.toString());
} else { } else {
final io.ProcessResult revParse = await process.run( final io.ProcessResult revParse = await process.run(
<String>['git', 'rev-parse', 'HEAD'], <String>['git', 'rev-parse', 'HEAD'],
workingDirectory: _flutterRoot.path, workingDirectory: _flutterRoot.path,
); );
return revParse.exitCode == 0 ? (revParse.stdout as String).trim() : null; if (revParse.exitCode != 0) {
throw Exception('Current commit of Flutter can not be found.');
}
return (revParse.stdout as String/*!*/).trim();
} }
} }
...@@ -626,15 +627,15 @@ class SkiaGoldClient { ...@@ -626,15 +627,15 @@ class SkiaGoldClient {
/// Returns a boolean value to prevent the client from re-authorizing itself /// Returns a boolean value to prevent the client from re-authorizing itself
/// for multiple tests. /// for multiple tests.
Future<bool> clientIsAuthorized() async { Future<bool> clientIsAuthorized() async {
final File authFile = workDirectory?.childFile(fs.path.join( final File authFile = workDirectory.childFile(fs.path.join(
'temp', 'temp',
'auth_opt.json', 'auth_opt.json',
)); ))/*!*/;
if(await authFile.exists()) { if(await authFile.exists()) {
final String contents = await authFile.readAsString(); final String contents = await authFile.readAsString();
final Map<String, dynamic> decoded = json.decode(contents) as Map<String, dynamic>; final Map<String, dynamic> decoded = json.decode(contents) as Map<String, dynamic>;
return !(decoded['GSUtil'] as bool); return !(decoded['GSUtil'] as bool/*!*/);
} }
return false; return false;
} }
...@@ -642,11 +643,11 @@ class SkiaGoldClient { ...@@ -642,11 +643,11 @@ class SkiaGoldClient {
/// Returns a list of arguments for initializing a tryjob based on the testing /// Returns a list of arguments for initializing a tryjob based on the testing
/// environment. /// environment.
List<String> getCIArguments() { List<String> getCIArguments() {
String pullRequest; /*late*/ String/*!*/ pullRequest;
String jobId; /*late*/ String/*!*/ jobId;
String cis; /*late*/ String cis;
switch (ci) { switch (ci/*!*/) {
case ContinuousIntegrationEnvironment.luci: case ContinuousIntegrationEnvironment.luci:
jobId = platform.environment['LOGDOG_STREAM_PREFIX'].split('/').last; jobId = platform.environment['LOGDOG_STREAM_PREFIX'].split('/').last;
final List<String> refs = platform.environment['GOLD_TRYJOB'].split('/'); final List<String> refs = platform.environment['GOLD_TRYJOB'].split('/');
...@@ -682,9 +683,6 @@ class SkiaGoldDigest { ...@@ -682,9 +683,6 @@ class SkiaGoldDigest {
/// Create a digest from requested JSON. /// Create a digest from requested JSON.
factory SkiaGoldDigest.fromJson(Map<String, dynamic> json) { factory SkiaGoldDigest.fromJson(Map<String, dynamic> json) {
if (json == null)
return null;
return SkiaGoldDigest( return SkiaGoldDigest(
imageHash: json['digest'] as String, imageHash: json['digest'] as String,
paramSet: Map<String, dynamic>.from(json['paramset'] as Map<String, dynamic> ?? paramSet: Map<String, dynamic>.from(json['paramset'] as Map<String, dynamic> ??
...@@ -698,21 +696,21 @@ class SkiaGoldDigest { ...@@ -698,21 +696,21 @@ class SkiaGoldDigest {
} }
/// Unique identifier for the image associated with the digest. /// Unique identifier for the image associated with the digest.
final String imageHash; final String/*!*/ imageHash;
/// Parameter set for the given test, e.g. Platform : Windows. /// Parameter set for the given test, e.g. Platform : Windows.
final Map<String, dynamic> paramSet; final Map<String, dynamic>/*!*/ paramSet;
/// Test name associated with the digest, e.g. positive or un-triaged. /// Test name associated with the digest, e.g. positive or un-triaged.
final String testName; final String/*!*/ testName;
/// Status of the given digest, e.g. positive or un-triaged. /// Status of the given digest, e.g. positive or un-triaged.
final String status; final String/*!*/ status;
/// Validates a given digest against the current testing conditions. /// Validates a given digest against the current testing conditions.
bool isValid(Platform platform, String name, String expectation) { bool isValid(Platform platform, String name, String expectation) {
return imageHash == expectation return imageHash == expectation
&& (paramSet['Platform'] as List<dynamic>).contains(platform.operatingSystem) && (paramSet['Platform'] as List<dynamic>/*!*/).contains(platform.operatingSystem)
&& (platform.environment[_kTestBrowserKey] == null && (platform.environment[_kTestBrowserKey] == null
|| paramSet['Browser'] == platform.environment[_kTestBrowserKey]) || paramSet['Browser'] == platform.environment[_kTestBrowserKey])
&& testName == name && testName == name
......
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