Fix setup race in asset bundle tests (#140832)
Fixes https://github.com/flutter/flutter/issues/140665 by replacing use of `setUpAll` and `teardownAll` with `setUp` and `teardown` respectively. My theory has to how this issue happened (and how this PR fixes it) is that `setUpAll` is not guaranteed to run after any `setUp` in any parent test groups. However, `setUp` is guaranteed to run after any set-up callbacks in parent groups. From the [documentation](https://api.flutter.dev/flutter/flutter_test/setUp.html): > If this is called within a test group, it applies only to tests in that group. The body will be run after any set-up callbacks in parent groups or at the top level. Meanwhile, [`setUpAll`](https://api.flutter.dev/flutter/flutter_test/setUpAll.html) has a weaker documented guarantee that applies only to other `setUpAll` calls: > If this is called within a test group, The body will run before all tests in that group. It will be run after any [setUpAll](https://api.flutter.dev/flutter/flutter_test/setUpAll.html) callbacks in parent groups or at the top level. It won't be run if none of the tests in the group are run.
This commit is contained in:
@@ -2,13 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// TODO(andrewkolos): Remove this tag once this test's state leaks/test
|
||||
// dependencies have been fixed.
|
||||
// https://github.com/flutter/flutter/issues/140665
|
||||
// Fails with "flutter test --test-randomize-ordering-seed=20231227"
|
||||
@Tags(<String>['no-shuffle'])
|
||||
library;
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
@@ -356,14 +349,14 @@ flutter:
|
||||
return bundle;
|
||||
}
|
||||
|
||||
late final String? previousCacheFlutterRootValue;
|
||||
late String? previousCacheFlutterRootValue;
|
||||
|
||||
setUpAll(() {
|
||||
setUp(() {
|
||||
previousCacheFlutterRootValue = Cache.flutterRoot;
|
||||
Cache.flutterRoot = Cache.defaultFlutterRoot(platform: platform, fileSystem: testFileSystem, userMessages: UserMessages());
|
||||
});
|
||||
|
||||
tearDownAll(() => Cache.flutterRoot = previousCacheFlutterRootValue);
|
||||
tearDown(() => Cache.flutterRoot = previousCacheFlutterRootValue);
|
||||
|
||||
testWithoutContext('correctly bundles assets given a simple asset manifest with flavors', () async {
|
||||
testFileSystem.file('.packages').createSync();
|
||||
|
||||
Reference in New Issue
Block a user