diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 1f0816f852f..d3ced31bb05 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -461,25 +461,19 @@ Future _runTests() async { } Future _runWebTests() async { - // Run a small subset of web tests to smoke-test the Web test infrastructure. - await _runFlutterWebTest(path.join(flutterRoot, 'packages', 'flutter'), tests: [ - 'test/foundation/assertions_test.dart', - ]); - // TODO(yjbanov): re-enable when web test cirrus flakiness is resolved - // await _runFlutterWebTest(path.join(flutterRoot, 'packages', 'flutter'), tests: [ - // '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/', - // ]); + await _runFlutterWebTest(path.join(flutterRoot, 'packages', 'flutter'), tests: [ + '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/', + ]); } Future _runCoverage() async { @@ -764,13 +758,44 @@ class EvalResult { Future _runFlutterWebTest(String workingDirectory, { List tests, +}) async { + final List allTests = []; + for (String testDirPath in tests) { + final Directory testDir = Directory(path.join(workingDirectory, testDirPath)); + allTests.addAll( + testDir.listSync(recursive: true) + .whereType() + .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 batch = []; + 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 = []; + } + } +} + +Future _runFlutterWebTestBatch(String workingDirectory, { + List batch, }) async { final List args = [ 'test', '-v', '--platform=chrome', ...?flutterTestArgs, - ...tests, + ...batch, ]; // TODO(jonahwilliams): fix relative path issues to make this unecessary. @@ -781,7 +806,7 @@ Future _runFlutterWebTest(String workingDirectory, { flutter, args, workingDirectory: workingDirectory, - expectFlaky: true, + expectFlaky: false, environment: { 'FLUTTER_WEB': 'true', 'FLUTTER_LOW_RESOURCE_MODE': 'true', diff --git a/packages/flutter/lib/src/foundation/assertions.dart b/packages/flutter/lib/src/foundation/assertions.dart index 6697b15fe89..76edc678cd2 100644 --- a/packages/flutter/lib/src/foundation/assertions.dart +++ b/packages/flutter/lib/src/foundation/assertions.dart @@ -753,13 +753,14 @@ void debugPrintStack({StackTrace stackTrace, String label, int maxFrames}) { debugPrint(label); stackTrace ??= StackTrace.current; Iterable lines = stackTrace.toString().trimRight().split('\n'); - if ( kIsWeb - && lines.isNotEmpty - && lines.first.contains('StackTrace.current')) { + if (kIsWeb && lines.isNotEmpty) { // Remove extra call to StackTrace.current for web platform. // TODO(ferhat): remove when https://github.com/flutter/flutter/issues/37635 // is addressed. - lines = lines.skip(1); + lines = lines.skipWhile((String line) { + return line.contains('StackTrace.current') || + line.contains('dart:sdk_internal'); + }); } if (maxFrames != null) lines = lines.take(maxFrames);