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 https://github.com/flutter/flutter/issues/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].*
This commit is contained in:
David Martos 2024-02-01 22:22:51 +01:00 committed by GitHub
parent 07ca92a69e
commit d242d1368f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -19,8 +19,16 @@ import 'package:test/test.dart';
void main() {
final TokenLogger logger = tokenLogger;
// Required init with empty at least once to init late fields.
// Then we can use the `clear` method.
logger.init(allTokens: <String, dynamic>{}, versionMap: <String, List<String>>{});
setUp(() {
// Cleanup the global token logger before each test, to not be tied to a particular
// test order.
logger.clear();
});
test('Templates will append to the end of a file', () {
final Directory tempDir = Directory.systemTemp.createTempSync('gen_defaults');
try {