Unverified Commit 190698d0 authored by Yegor's avatar Yegor Committed by GitHub

run web tests in batches; enable foundation tests (#37268)

* shard tests

* make foundation tests pass
parent d8833376
...@@ -461,25 +461,19 @@ Future<void> _runTests() async { ...@@ -461,25 +461,19 @@ Future<void> _runTests() async {
} }
Future<void> _runWebTests() async { Future<void> _runWebTests() async {
// Run a small subset of web tests to smoke-test the Web test infrastructure. // TODO(yjbanov): re-enable when web test cirrus flakiness is resolved
await _runFlutterWebTest(path.join(flutterRoot, 'packages', 'flutter'), tests: <String>[ await _runFlutterWebTest(path.join(flutterRoot, 'packages', 'flutter'), tests: <String>[
'test/foundation/assertions_test.dart', 'test/foundation/',
// TODO(yjbanov): re-enable when flakiness is resolved
// 'test/physics/',
// 'test/rendering/',
// 'test/services/',
// 'test/painting/',
// 'test/scheduler/',
// 'test/semantics/',
// 'test/widgets/',
// 'test/material/',
]); ]);
// TODO(yjbanov): re-enable when web test cirrus flakiness is resolved
// await _runFlutterWebTest(path.join(flutterRoot, 'packages', 'flutter'), tests: <String>[
// 'test/foundation/',
// 'test/physics/',
// 'test/rendering/',
// 'test/services/',
// 'test/painting/',
// 'test/scheduler/',
// 'test/semantics/',
// TODO(yjbanov): re-enable when instabiliy around pumpAndSettle is
// // resolved.
// // 'test/widgets/',
// // 'test/material/',
// ]);
} }
Future<void> _runCoverage() async { Future<void> _runCoverage() async {
...@@ -764,13 +758,44 @@ class EvalResult { ...@@ -764,13 +758,44 @@ class EvalResult {
Future<void> _runFlutterWebTest(String workingDirectory, { Future<void> _runFlutterWebTest(String workingDirectory, {
List<String> tests, List<String> tests,
}) async {
final List<String> allTests = <String>[];
for (String testDirPath in tests) {
final Directory testDir = Directory(path.join(workingDirectory, testDirPath));
allTests.addAll(
testDir.listSync(recursive: true)
.whereType<File>()
.where((File file) => file.path.endsWith('_test.dart'))
.map((File file) => path.relative(file.path, from: workingDirectory))
);
}
print(allTests.join('\n'));
print('${allTests.length} tests total');
// Maximum number of tests to run in a single `flutter test`. We found that
// large batches can get flaky, possibly because we reuse a single instance
// of the browser, and after many tests the browser's state gets corrupted.
const int kBatchSize = 20;
List<String> batch = <String>[];
for (int i = 0; i < allTests.length; i += 1) {
final String testFilePath = allTests[i];
batch.add(testFilePath);
if (batch.length == kBatchSize || i == allTests.length - 1) {
await _runFlutterWebTestBatch(workingDirectory, batch: batch);
batch = <String>[];
}
}
}
Future<void> _runFlutterWebTestBatch(String workingDirectory, {
List<String> batch,
}) async { }) async {
final List<String> args = <String>[ final List<String> args = <String>[
'test', 'test',
'-v', '-v',
'--platform=chrome', '--platform=chrome',
...?flutterTestArgs, ...?flutterTestArgs,
...tests, ...batch,
]; ];
// TODO(jonahwilliams): fix relative path issues to make this unecessary. // TODO(jonahwilliams): fix relative path issues to make this unecessary.
...@@ -781,7 +806,7 @@ Future<void> _runFlutterWebTest(String workingDirectory, { ...@@ -781,7 +806,7 @@ Future<void> _runFlutterWebTest(String workingDirectory, {
flutter, flutter,
args, args,
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
expectFlaky: true, expectFlaky: false,
environment: <String, String>{ environment: <String, String>{
'FLUTTER_WEB': 'true', 'FLUTTER_WEB': 'true',
'FLUTTER_LOW_RESOURCE_MODE': 'true', 'FLUTTER_LOW_RESOURCE_MODE': 'true',
......
...@@ -753,13 +753,14 @@ void debugPrintStack({StackTrace stackTrace, String label, int maxFrames}) { ...@@ -753,13 +753,14 @@ void debugPrintStack({StackTrace stackTrace, String label, int maxFrames}) {
debugPrint(label); debugPrint(label);
stackTrace ??= StackTrace.current; stackTrace ??= StackTrace.current;
Iterable<String> lines = stackTrace.toString().trimRight().split('\n'); Iterable<String> lines = stackTrace.toString().trimRight().split('\n');
if ( kIsWeb if (kIsWeb && lines.isNotEmpty) {
&& lines.isNotEmpty
&& lines.first.contains('StackTrace.current')) {
// Remove extra call to StackTrace.current for web platform. // Remove extra call to StackTrace.current for web platform.
// TODO(ferhat): remove when https://github.com/flutter/flutter/issues/37635 // TODO(ferhat): remove when https://github.com/flutter/flutter/issues/37635
// is addressed. // is addressed.
lines = lines.skip(1); lines = lines.skipWhile((String line) {
return line.contains('StackTrace.current') ||
line.contains('dart:sdk_internal');
});
} }
if (maxFrames != null) if (maxFrames != null)
lines = lines.take(maxFrames); lines = lines.take(maxFrames);
......
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