Skip to content

Commit d242d13

Browse files
Fix gen_defaults test randomness (#142743)
This PR improves the gen_defaults tests to not be tied to a particular order of execution. Since there is a global class that holds the state of the used/not used tokens, we need to clear this logger before each test. Fixes flutter/flutter#142716 cc @zanderso @QuncCccccc *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
1 parent 07ca92a commit d242d13

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

dev/tools/gen_defaults/test/gen_defaults_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,16 @@ import 'package:test/test.dart';
1919

2020
void main() {
2121
final TokenLogger logger = tokenLogger;
22+
// Required init with empty at least once to init late fields.
23+
// Then we can use the `clear` method.
2224
logger.init(allTokens: <String, dynamic>{}, versionMap: <String, List<String>>{});
2325

26+
setUp(() {
27+
// Cleanup the global token logger before each test, to not be tied to a particular
28+
// test order.
29+
logger.clear();
30+
});
31+
2432
test('Templates will append to the end of a file', () {
2533
final Directory tempDir = Directory.systemTemp.createTempSync('gen_defaults');
2634
try {

0 commit comments

Comments
 (0)