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