Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
abbc0bed
Unverified
Commit
abbc0bed
authored
Aug 04, 2022
by
Kate Lovett
Committed by
GitHub
Aug 04, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more logs to diagnose Gold flake (#108930)
parent
e27a19e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
138 additions
and
16 deletions
+138
-16
flutter_goldens_test.dart
packages/flutter_goldens/test/flutter_goldens_test.dart
+88
-0
skia_client.dart
packages/flutter_goldens_client/lib/skia_client.dart
+50
-16
No files found.
packages/flutter_goldens/test/flutter_goldens_test.dart
View file @
abbc0bed
...
...
@@ -489,6 +489,94 @@ void main() {
);
});
test
(
'throws for error state from imgtestAdd'
,
()
{
final
File
goldenFile
=
fs
.
file
(
'/workDirectory/temp/golden_file_test.png'
)
..
createSync
(
recursive:
true
);
platform
=
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
_kFlutterRoot
,
'GOLDCTL'
:
'goldctl'
,
},
operatingSystem:
'macos'
);
skiaClient
=
SkiaGoldClient
(
workDirectory
,
fs:
fs
,
process:
process
,
platform:
platform
,
httpClient:
fakeHttpClient
,
);
const
RunInvocation
goldctlInvocation
=
RunInvocation
(
<
String
>[
'goldctl'
,
'imgtest'
,
'add'
,
'--work-dir'
,
'/workDirectory/temp'
,
'--test-name'
,
'golden_file_test'
,
'--png-file'
,
'/workDirectory/temp/golden_file_test.png'
,
'--passfail'
,
],
null
,
);
process
.
processResults
[
goldctlInvocation
]
=
ProcessResult
(
123
,
1
,
'Expected failure'
,
'Expected failure'
);
process
.
fallbackProcessResult
=
ProcessResult
(
123
,
1
,
'Fallback failure'
,
'Fallback failure'
);
expect
(
skiaClient
.
imgtestAdd
(
'golden_file_test'
,
goldenFile
),
throwsA
(
isA
<
SkiaException
>().
having
((
SkiaException
error
)
=>
error
.
message
,
'message'
,
contains
(
'result-state.json'
),
),
),
);
});
test
(
'throws for error state from tryjobAdd'
,
()
{
final
File
goldenFile
=
fs
.
file
(
'/workDirectory/temp/golden_file_test.png'
)
..
createSync
(
recursive:
true
);
platform
=
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
_kFlutterRoot
,
'GOLDCTL'
:
'goldctl'
,
},
operatingSystem:
'macos'
);
skiaClient
=
SkiaGoldClient
(
workDirectory
,
fs:
fs
,
process:
process
,
platform:
platform
,
httpClient:
fakeHttpClient
,
);
const
RunInvocation
goldctlInvocation
=
RunInvocation
(
<
String
>[
'goldctl'
,
'imgtest'
,
'add'
,
'--work-dir'
,
'/workDirectory/temp'
,
'--test-name'
,
'golden_file_test'
,
'--png-file'
,
'/workDirectory/temp/golden_file_test.png'
,
'--passfail'
,
],
null
,
);
process
.
processResults
[
goldctlInvocation
]
=
ProcessResult
(
123
,
1
,
'Expected failure'
,
'Expected failure'
);
process
.
fallbackProcessResult
=
ProcessResult
(
123
,
1
,
'Fallback failure'
,
'Fallback failure'
);
expect
(
skiaClient
.
tryjobAdd
(
'golden_file_test'
,
goldenFile
),
throwsA
(
isA
<
SkiaException
>().
having
((
SkiaException
error
)
=>
error
.
message
,
'message'
,
contains
(
'result-state.json'
),
),
),
);
});
group
(
'Request Handling'
,
()
{
const
String
expectation
=
'55109a4bed52acc780530f7a9aeff6c0'
;
...
...
packages/flutter_goldens_client/lib/skia_client.dart
View file @
abbc0bed
...
...
@@ -21,6 +21,21 @@ const String _kGoldctlKey = 'GOLDCTL';
const
String
_kTestBrowserKey
=
'FLUTTER_TEST_BROWSER'
;
const
String
_kWebRendererKey
=
'FLUTTER_WEB_RENDERER'
;
/// Exception thrown when an error is returned from the [SkiaClient].
class
SkiaException
implements
Exception
{
/// Creates a new `SkiaException` with a required error [message].
const
SkiaException
(
this
.
message
);
/// A message describing the error.
final
String
message
;
/// Returns a description of the Skia exception.
///
/// The description always contains the [message].
@override
String
toString
()
=>
'SkiaException:
$message
'
;
}
/// A client for uploading image tests and making baseline requests to the
/// Flutter Gold Dashboard.
class
SkiaGoldClient
{
...
...
@@ -103,10 +118,10 @@ class SkiaGoldClient {
..
writeln
(
'Luci environments authenticate using the file provided '
'by LUCI_CONTEXT. There may be an error with this file or Gold '
'authentication.'
)
..
writeln
(
'Debug information for Gold
:
'
)
..
writeln
(
'Debug information for Gold
--------------------------------
'
)
..
writeln
(
'stdout:
${result.stdout}
'
)
..
writeln
(
'stderr:
${result.stderr}
'
);
throw
Exception
(
buf
.
toString
());
throw
Skia
Exception
(
buf
.
toString
());
}
}
...
...
@@ -155,7 +170,7 @@ class SkiaGoldClient {
..
writeln
(
'Please confirm the settings of your golden file test.'
)
..
writeln
(
'Arguments provided:'
);
imgtestInitCommand
.
forEach
(
buf
.
writeln
);
throw
Exception
(
buf
.
toString
());
throw
Skia
Exception
(
buf
.
toString
());
}
final
io
.
ProcessResult
result
=
await
process
.
run
(
imgtestInitCommand
);
...
...
@@ -167,10 +182,10 @@ class SkiaGoldClient {
..
writeln
(
'An error occurred when initializing golden file test with '
)
..
writeln
(
'goldctl.'
)
..
writeln
()
..
writeln
(
'Debug information for Gold
:
'
)
..
writeln
(
'Debug information for Gold
--------------------------------
'
)
..
writeln
(
'stdout:
${result.stdout}
'
)
..
writeln
(
'stderr:
${result.stderr}
'
);
throw
Exception
(
buf
.
toString
());
throw
Skia
Exception
(
buf
.
toString
());
}
_initialized
=
true
;
}
...
...
@@ -202,6 +217,14 @@ class SkiaGoldClient {
if
(
result
.
exitCode
!=
0
)
{
// If an unapproved image has made it to post-submit, throw to close the
// tree.
String
?
resultContents
;
final
File
resultFile
=
workDirectory
.
childFile
(
fs
.
path
.
join
(
'result-state.json'
,
));
if
(
await
resultFile
.
exists
())
{
resultContents
=
await
resultFile
.
readAsString
();
}
final
StringBuffer
buf
=
StringBuffer
()
..
writeln
(
'Skia Gold received an unapproved image in post-submit '
)
..
writeln
(
'testing. Golden file images in flutter/flutter are triaged '
)
...
...
@@ -212,10 +235,12 @@ class SkiaGoldClient {
..
writeln
(
'information, visit the wiki: '
)
..
writeln
(
'https://github.com/flutter/flutter/wiki/Writing-a-golden-file-test-for-package:flutter'
)
..
writeln
()
..
writeln
(
'Debug information for Gold
:
'
)
..
writeln
(
'Debug information for Gold
--------------------------------
'
)
..
writeln
(
'stdout:
${result.stdout}
'
)
..
writeln
(
'stderr:
${result.stderr}
'
);
throw
Exception
(
buf
.
toString
());
..
writeln
(
'stderr:
${result.stderr}
'
)
..
writeln
()
..
writeln
(
'result-state.json:
${resultContents ?? 'No result file found.'}
'
);
throw
SkiaException
(
buf
.
toString
());
}
return
true
;
...
...
@@ -269,7 +294,7 @@ class SkiaGoldClient {
..
writeln
(
'Please confirm the settings of your golden file test.'
)
..
writeln
(
'Arguments provided:'
);
imgtestInitCommand
.
forEach
(
buf
.
writeln
);
throw
Exception
(
buf
.
toString
());
throw
Skia
Exception
(
buf
.
toString
());
}
final
io
.
ProcessResult
result
=
await
process
.
run
(
imgtestInitCommand
);
...
...
@@ -281,10 +306,10 @@ class SkiaGoldClient {
..
writeln
(
'An error occurred when initializing golden file tryjob with '
)
..
writeln
(
'goldctl.'
)
..
writeln
()
..
writeln
(
'Debug information for Gold
:
'
)
..
writeln
(
'Debug information for Gold
--------------------------------
'
)
..
writeln
(
'stdout:
${result.stdout}
'
)
..
writeln
(
'stderr:
${result.stderr}
'
);
throw
Exception
(
buf
.
toString
());
throw
Skia
Exception
(
buf
.
toString
());
}
_tryjobInitialized
=
true
;
}
...
...
@@ -315,16 +340,25 @@ class SkiaGoldClient {
final
String
/*!*/
resultStdout
=
result
.
stdout
.
toString
();
if
(
result
.
exitCode
!=
0
&&
!(
resultStdout
.
contains
(
'Untriaged'
)
||
resultStdout
.
contains
(
'negative image'
)))
{
String
?
resultContents
;
final
File
resultFile
=
workDirectory
.
childFile
(
fs
.
path
.
join
(
'result-state.json'
,
));
if
(
await
resultFile
.
exists
())
{
resultContents
=
await
resultFile
.
readAsString
();
}
final
StringBuffer
buf
=
StringBuffer
()
..
writeln
(
'Unexpected Gold tryjobAdd failure.'
)
..
writeln
(
'Tryjob execution for golden file test
$testName
failed for'
)
..
writeln
(
'a reason unrelated to pixel comparison.'
)
..
writeln
()
..
writeln
(
'Debug information for Gold
:
'
)
..
writeln
(
'Debug information for Gold
--------------------------------
'
)
..
writeln
(
'stdout:
${result.stdout}
'
)
..
writeln
(
'stderr:
${result.stderr}
'
)
..
writeln
();
throw
Exception
(
buf
.
toString
());
..
writeln
()
..
writeln
()
..
writeln
(
'result-state.json:
${resultContents ?? 'No result file found.'}
'
);
throw
SkiaException
(
buf
.
toString
());
}
}
...
...
@@ -432,14 +466,14 @@ class SkiaGoldClient {
/// Returns the current commit hash of the Flutter repository.
Future
<
String
>
_getCurrentCommit
()
async
{
if
(!
_flutterRoot
.
existsSync
())
{
throw
Exception
(
'Flutter root could not be found:
$_flutterRoot
\n
'
);
throw
Skia
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
,
);
if
(
revParse
.
exitCode
!=
0
)
{
throw
Exception
(
'Current commit of Flutter can not be found.'
);
throw
const
Skia
Exception
(
'Current commit of Flutter can not be found.'
);
}
return
(
revParse
.
stdout
as
String
/*!*/
).
trim
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment