Skip to content

Commit 11a9cb7

Browse files
authored
Make tests more resilient to Skia gold failures and refactor flutter_goldens for extensive technical debt removal (flutter#139549)
* Remove all use of global variables. * Always pass in all dependencies, only create them in main or in tests. * Pass in the "print" primitive. * Make all network traffic retry (except when run locally, when it just auto-passes). * Enable tests to be run in random order.
1 parent 3da9bc1 commit 11a9cb7

File tree

13 files changed

+1645
-1477
lines changed

13 files changed

+1645
-1477
lines changed
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
[0-9]+:[0-9]+ [+]0: Local passes non-existent baseline for new test, null expectation *
2-
*No expectations provided by Skia Gold for test: library.flutter.new_golden_test.1.png. This may be a new test. If this is an unexpected result, check https://flutter-gold.skia.org.
3-
*Validate image output found at flutter/test/library/
4-
[0-9]+:[0-9]+ [+]1: Local passes non-existent baseline for new test, empty expectation *
5-
*No expectations provided by Skia Gold for test: library.flutter.new_golden_test.2.png. This may be a new test. If this is an unexpected result, check https://flutter-gold.skia.org.
6-
*Validate image output found at flutter/test/library/
71
[0-9]+:[0-9]+ [+]2: All tests passed! *

dev/automated_tests/flutter_test/flutter_gold_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const List<int> _kFailPngBytes = <int>[
2121
];
2222

2323
void main() {
24+
final List<String> log = <String>[];
2425
final MemoryFileSystem fs = MemoryFileSystem();
2526
final Directory basedir = fs.directory('flutter/test/library/')
2627
..createSync(recursive: true);
@@ -34,6 +35,7 @@ void main() {
3435
environment: <String, String>{'FLUTTER_ROOT': '/flutter'},
3536
operatingSystem: 'macos'
3637
),
38+
log: log.add,
3739
);
3840

3941
test('Local passes non-existent baseline for new test, null expectation', () async {
@@ -44,6 +46,12 @@ void main() {
4446
),
4547
isTrue,
4648
);
49+
expect(log, <String>[
50+
// ignore: no_adjacent_strings_in_list
51+
'No expectations provided by Skia Gold for test: library.flutter.new_golden_test.1.png. '
52+
'This may be a new test. If this is an unexpected result, check https://flutter-gold.skia.org.\n'
53+
'Validate image output found at flutter/test/library/'
54+
]);
4755
});
4856

4957
test('Local passes non-existent baseline for new test, empty expectation', () async {
@@ -54,6 +62,16 @@ void main() {
5462
),
5563
isTrue,
5664
);
65+
expect(log, <String>[
66+
// ignore: no_adjacent_strings_in_list
67+
'No expectations provided by Skia Gold for test: library.flutter.new_golden_test.1.png. '
68+
'This may be a new test. If this is an unexpected result, check https://flutter-gold.skia.org.\n'
69+
'Validate image output found at flutter/test/library/',
70+
// ignore: no_adjacent_strings_in_list
71+
'No expectations provided by Skia Gold for test: library.flutter.new_golden_test.2.png. '
72+
'This may be a new test. If this is an unexpected result, check https://flutter-gold.skia.org.\n'
73+
'Validate image output found at flutter/test/library/',
74+
]);
5775
});
5876
}
5977

packages/flutter/pubspec.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dev_dependencies:
2929
async: 2.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3030
boolean_selector: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3131
clock: 1.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
32+
crypto: 3.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3233
file: 7.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3334
matcher: 0.12.16 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3435
path: 1.9.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@@ -40,6 +41,7 @@ dev_dependencies:
4041
string_scanner: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4142
term_glyph: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4243
test_api: 0.6.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
44+
typed_data: 1.3.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4345
vm_service: 13.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4446

45-
# PUBSPEC CHECKSUM: 8088
47+
# PUBSPEC CHECKSUM: bbe9

packages/flutter/test_private/test/pubspec.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ dev_dependencies:
3838
sdk: flutter
3939
fake_async: 1.3.1
4040

41+
crypto: 3.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4142
file: 7.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4243
platform: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4344
process: 5.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
45+
typed_data: 1.3.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4446

45-
# PUBSPEC CHECKSUM: db59
47+
# PUBSPEC CHECKSUM: 0fba

packages/flutter_goldens/README

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
This package is an internal implementation detail for our testing
2+
infrastructure. It enables the framework to use the Skia Gold
3+
infrastructure for tracking golden image tests.
4+
5+
See also:
6+
7+
* https://skia.org/docs/dev/testing/skiagold/
8+
* https://flutter-gold.skia.org/
9+
* https://github.com/flutter/flutter/wiki/Writing-a-golden-file-test-for-package:flutter

packages/flutter_goldens/dart_test.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)