Skip to content

Commit

Permalink
[web] enable CanvasKit tests using a local bundle fetched from CIPD (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
yjbanov authored Oct 21, 2021
1 parent e7c809e commit ad7727a
Show file tree
Hide file tree
Showing 15 changed files with 425 additions and 30 deletions.
168 changes: 168 additions & 0 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,174 @@ targets:
- bin/
- .ci.yaml

- name: Linux web_canvaskit_tests_0
bringup: true
recipe: flutter/flutter_drone
timeout: 60
properties:
dependencies: >-
[
{"dependency": "android_sdk"},
{"dependency": "chrome_and_driver"},
{"dependency": "goldctl"}
]
shard: web_canvaskit_tests
subshard: "0"
tags: >
["framework","hostonly","shard"]
scheduler: luci
runIf:
- dev/
- packages/
- bin/

- name: Linux web_canvaskit_tests_1
bringup: true
recipe: flutter/flutter_drone
timeout: 60
properties:
dependencies: >-
[
{"dependency": "android_sdk"},
{"dependency": "chrome_and_driver"},
{"dependency": "goldctl"}
]
shard: web_canvaskit_tests
subshard: "1"
tags: >
["framework","hostonly","shard"]
scheduler: luci
runIf:
- dev/
- packages/
- bin/

- name: Linux web_canvaskit_tests_2
bringup: true
recipe: flutter/flutter_drone
timeout: 60
properties:
dependencies: >-
[
{"dependency": "android_sdk"},
{"dependency": "chrome_and_driver"},
{"dependency": "goldctl"}
]
shard: web_canvaskit_tests
subshard: "2"
tags: >
["framework","hostonly","shard"]
scheduler: luci
runIf:
- dev/
- packages/
- bin/

- name: Linux web_canvaskit_tests_3
bringup: true
recipe: flutter/flutter_drone
timeout: 60
properties:
dependencies: >-
[
{"dependency": "android_sdk"},
{"dependency": "chrome_and_driver"},
{"dependency": "goldctl"}
]
shard: web_canvaskit_tests
subshard: "3"
tags: >
["framework","hostonly","shard"]
scheduler: luci
runIf:
- dev/
- packages/
- bin/

- name: Linux web_canvaskit_tests_4
bringup: true
recipe: flutter/flutter_drone
timeout: 60
properties:
dependencies: >-
[
{"dependency": "android_sdk"},
{"dependency": "chrome_and_driver"},
{"dependency": "goldctl"}
]
shard: web_canvaskit_tests
subshard: "4"
tags: >
["framework","hostonly","shard"]
scheduler: luci
runIf:
- dev/
- packages/
- bin/

- name: Linux web_canvaskit_tests_5
bringup: true
recipe: flutter/flutter_drone
timeout: 60
properties:
dependencies: >-
[
{"dependency": "android_sdk"},
{"dependency": "chrome_and_driver"},
{"dependency": "goldctl"}
]
shard: web_canvaskit_tests
subshard: "5"
tags: >
["framework","hostonly","shard"]
scheduler: luci
runIf:
- dev/
- packages/
- bin/

- name: Linux web_canvaskit_tests_6
bringup: true
recipe: flutter/flutter_drone
timeout: 60
properties:
dependencies: >-
[
{"dependency": "android_sdk"},
{"dependency": "chrome_and_driver"},
{"dependency": "goldctl"}
]
shard: web_canvaskit_tests
subshard: "6"
tags: >
["framework","hostonly","shard"]
scheduler: luci
runIf:
- dev/
- packages/
- bin/

- name: Linux web_canvaskit_tests_7_last
bringup: true
recipe: flutter/flutter_drone
timeout: 60
properties:
dependencies: >-
[
{"dependency": "android_sdk"},
{"dependency": "chrome_and_driver"},
{"dependency": "goldctl"}
]
shard: web_canvaskit_tests
subshard: "7_last"
tags: >
["framework","hostonly","shard"]
scheduler: luci
runIf:
- dev/
- packages/
- bin/

- name: Linux web_tool_tests
recipe: flutter/flutter_drone
timeout: 60
Expand Down
1 change: 1 addition & 0 deletions TESTOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
# web_integration_tests @yjbanov @flutter/web
# web_long_running_tests @yjbanov @flutter/web
# web_tests @yjbanov @flutter/web
# web_canvaskit_tests @yjbanov @flutter/web
# web_tool_tests @zanderso @flutter/tool
# fuchsia_precache @zanderso @flutter/tool
# skp_generator @Hixie
Expand Down
96 changes: 81 additions & 15 deletions dev/bots/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,66 @@ const String kSubshardKey = 'SUBSHARD';
int get webShardCount => Platform.environment.containsKey('WEB_SHARD_COUNT')
? int.parse(Platform.environment['WEB_SHARD_COUNT']!)
: 8;
/// Tests that we don't run on Web for compilation reasons.

/// Tests that we don't run on Web.
///
/// In general avoid adding new tests here. If a test cannot run on the web
/// because it fails at runtime, such as when a piece of functionality is not
/// implemented or not implementable on the web, prefer using `skip` in the
/// test code. Only add tests here that cannot be skipped using `skip`. For
/// example:
///
/// * Test code cannot be compiled because it uses Dart VM-specific
/// functionality. In this case `skip` doesn't help because the code cannot
/// reach the point where it can even run the skipping logic.
/// * Migrations. It is OK to put tests here that need to be temporarily
/// disabled in certain modes because of some migration or initial bringup.
///
/// The key in the map is the renderer type that the list applies to. The value
/// is the list of tests known to fail for that renderer.
//
// TODO(yjbanov): we're getting rid of this as part of https://github.com/flutter/flutter/projects/60
const List<String> kWebTestFileKnownFailures = <String>[
'test/services/message_codecs_vm_test.dart',
'test/examples/sector_layout_test.dart',
];
const Map<String, List<String>> kWebTestFileKnownFailures = <String, List<String>>{
'html': <String>[
// These tests are not compilable on the web due to dependencies on
// VM-specific functionality.
'test/services/message_codecs_vm_test.dart',
'test/examples/sector_layout_test.dart',
],
'canvaskit': <String>[
// These tests are not compilable on the web due to dependencies on
// VM-specific functionality.
'test/services/message_codecs_vm_test.dart',
'test/examples/sector_layout_test.dart',

// These tests are broken and need to be fixed.
// TODO(yjbanov): https://github.com/flutter/flutter/issues/71604
'test/painting/decoration_test.dart',
'test/material/text_selection_theme_test.dart',
'test/material/date_picker_test.dart',
'test/rendering/layers_test.dart',
'test/painting/text_style_test.dart',
'test/widgets/image_test.dart',
'test/cupertino/colors_test.dart',
'test/cupertino/slider_test.dart',
'test/material/text_field_test.dart',
'test/rendering/proxy_box_test.dart',
'test/widgets/app_overrides_test.dart',
'test/material/calendar_date_picker_test.dart',
'test/material/ink_paint_test.dart',
'test/rendering/editable_test.dart',
'test/cupertino/dialog_test.dart',
'test/widgets/shape_decoration_test.dart',
'test/material/time_picker_theme_test.dart',
'test/cupertino/picker_test.dart',
'test/material/chip_theme_test.dart',
'test/cupertino/nav_bar_test.dart',
'test/widgets/performance_overlay_test.dart',
'test/widgets/html_element_view_test.dart',
'test/cupertino/scaffold_test.dart',
'test/rendering/platform_view_test.dart',
],
};

const String kSmokeTestShardName = 'smoke_tests';
const List<String> _kAllBuildModes = <String>['debug', 'profile', 'release'];
Expand Down Expand Up @@ -143,8 +196,10 @@ Future<void> main(List<String> args) async {
// web_tool_tests is also used by HHH: https://dart.googlesource.com/recipes/+/refs/heads/master/recipes/dart/flutter_engine.py
'web_tool_tests': _runWebToolTests,
'tool_integration_tests': _runIntegrationToolTests,
// All the unit/widget tests run using `flutter test --platform=chrome`
'web_tests': _runWebUnitTests,
// All the unit/widget tests run using `flutter test --platform=chrome --web-renderer=html`
'web_tests': _runWebHtmlUnitTests,
// All the unit/widget tests run using `flutter test --platform=chrome --web-renderer=canvaskit`
'web_canvaskit_tests': _runWebCanvasKitUnitTests,
// All web integration tests
'web_long_running_tests': _runWebLongRunningTests,
'flutter_plugins': _runFlutterPluginsTests,
Expand Down Expand Up @@ -802,7 +857,15 @@ Future<void> _runFrameworkCoverage() async {
}
}

Future<void> _runWebUnitTests() async {
Future<void> _runWebHtmlUnitTests() {
return _runWebUnitTests('html');
}

Future<void> _runWebCanvasKitUnitTests() {
return _runWebUnitTests('canvaskit');
}

Future<void> _runWebUnitTests(String webRenderer) async {
final Map<String, ShardRunner> subshards = <String, ShardRunner>{};

final Directory flutterPackageDirectory = Directory(path.join(flutterRoot, 'packages', 'flutter'));
Expand All @@ -817,7 +880,7 @@ Future<void> _runWebUnitTests() async {
)
.whereType<File>()
.map<String>((File file) => path.relative(file.path, from: flutterPackageDirectory.path))
.where((String filePath) => !kWebTestFileKnownFailures.contains(path.split(filePath).join('/')))
.where((String filePath) => !kWebTestFileKnownFailures[webRenderer]!.contains(path.split(filePath).join('/')))
.toList()
// Finally we shuffle the list because we want the average cost per file to be uniformly
// distributed. If the list is not sorted then different shards and batches may have
Expand All @@ -832,6 +895,7 @@ Future<void> _runWebUnitTests() async {
// This for loop computes all but the last shard.
for (int index = 0; index < webShardCount - 1; index += 1) {
subshards['$index'] = () => _runFlutterWebTest(
webRenderer,
flutterPackageDirectory.path,
allTests.sublist(
index * testsPerShard,
Expand All @@ -846,19 +910,22 @@ Future<void> _runWebUnitTests() async {
// between `.cirrus.yml` and `test.dart`.
subshards['${webShardCount - 1}_last'] = () async {
await _runFlutterWebTest(
webRenderer,
flutterPackageDirectory.path,
allTests.sublist(
(webShardCount - 1) * testsPerShard,
allTests.length,
),
);
await _runFlutterWebTest(
webRenderer,
path.join(flutterRoot, 'packages', 'flutter_web_plugins'),
<String>['test'],
);
await _runFlutterWebTest(
path.join(flutterRoot, 'packages', 'flutter_driver'),
<String>[path.join('test', 'src', 'web_tests', 'web_extension_test.dart')],
webRenderer,
path.join(flutterRoot, 'packages', 'flutter_driver'),
<String>[path.join('test', 'src', 'web_tests', 'web_extension_test.dart')],
);
};

Expand Down Expand Up @@ -1421,7 +1488,7 @@ Future<void> _runWebDebugTest(String target, {
}
}

Future<void> _runFlutterWebTest(String workingDirectory, List<String> tests) async {
Future<void> _runFlutterWebTest(String webRenderer, String workingDirectory, List<String> tests) async {
await runCommand(
flutter,
<String>[
Expand All @@ -1430,9 +1497,8 @@ Future<void> _runFlutterWebTest(String workingDirectory, List<String> tests) asy
'--concurrency=1', // do not parallelize on Cirrus, to reduce flakiness
'-v',
'--platform=chrome',
// TODO(ferhatb): Run web tests with both rendering backends.
'--web-renderer=html', // use html backend for web tests.
'--sound-null-safety', // web tests do not autodetect yet.
'--web-renderer=$webRenderer',
'--sound-null-safety',
...flutterTestArgs,
...tests,
],
Expand Down
9 changes: 8 additions & 1 deletion packages/flutter_goldens_client/lib/skia_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:process/process.dart';
const String _kFlutterRootKey = 'FLUTTER_ROOT';
const String _kGoldctlKey = 'GOLDCTL';
const String _kTestBrowserKey = 'FLUTTER_TEST_BROWSER';
const String _kWebRendererKey = 'FLUTTER_WEB_RENDERER';

/// A client for uploading image tests and making baseline requests to the
/// Flutter Gold Dashboard.
Expand Down Expand Up @@ -368,6 +369,9 @@ class SkiaGoldClient {
if (platform.environment[_kTestBrowserKey] != null) {
keys['Browser'] = platform.environment[_kTestBrowserKey];
keys['Platform'] = '${keys['Platform']}-browser';
if (platform.environment[_kWebRendererKey] == 'canvaskit') {
keys['WebRenderer'] = 'canvaskit';
}
}
return json.encode(keys);
}
Expand Down Expand Up @@ -413,7 +417,10 @@ class SkiaGoldClient {
/// the image keys.
String getTraceID(String testName) {
final Map<String, dynamic> keys = <String, dynamic>{
if (platform.environment[_kTestBrowserKey] != null) 'Browser' : platform.environment[_kTestBrowserKey],
if (platform.environment[_kTestBrowserKey] != null)
'Browser' : platform.environment[_kTestBrowserKey],
if (platform.environment[_kTestBrowserKey] != null && platform.environment[_kWebRendererKey] == 'canvaskit')
'WebRenderer' : 'canvaskit',
'CI' : 'luci',
'Platform' : platform.operatingSystem,
'name' : testName,
Expand Down
Loading

0 comments on commit ad7727a

Please sign in to comment.