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

* shard tests

* make foundation tests pass
This commit is contained in:
Yegor 2019-08-23 13:23:48 -07:00 committed by GitHub
parent d883337669
commit 190698d0d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 24 deletions

View file

@ -461,25 +461,19 @@ Future<void> _runTests() async {
}
Future<void> _runWebTests() async {
// Run a small subset of web tests to smoke-test the Web test infrastructure.
await _runFlutterWebTest(path.join(flutterRoot, 'packages', 'flutter'), tests: <String>[
'test/foundation/assertions_test.dart',
]);
// 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/',
// ]);
await _runFlutterWebTest(path.join(flutterRoot, 'packages', 'flutter'), tests: <String>[
'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<void> _runCoverage() async {
@ -764,13 +758,44 @@ class EvalResult {
Future<void> _runFlutterWebTest(String workingDirectory, {
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 {
final List<String> args = <String>[
'test',
'-v',
'--platform=chrome',
...?flutterTestArgs,
...tests,
...batch,
];
// TODO(jonahwilliams): fix relative path issues to make this unecessary.
@ -781,7 +806,7 @@ Future<void> _runFlutterWebTest(String workingDirectory, {
flutter,
args,
workingDirectory: workingDirectory,
expectFlaky: true,
expectFlaky: false,
environment: <String, String>{
'FLUTTER_WEB': 'true',
'FLUTTER_LOW_RESOURCE_MODE': 'true',

View file

@ -753,13 +753,14 @@ void debugPrintStack({StackTrace stackTrace, String label, int maxFrames}) {
debugPrint(label);
stackTrace ??= StackTrace.current;
Iterable<String> 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);