Randomize tests, exclude tests that fail with randomization. (#86793)
* Randomize tests, exclude tests that fail with randomization. * Disable some more tool tests
This commit is contained in:
@@ -113,7 +113,8 @@ Future<Command> startCommand(String executable, List<String> arguments, {
|
||||
environment: environment,
|
||||
);
|
||||
|
||||
Future<List<List<int>>>? savedStdout, savedStderr;
|
||||
Future<List<List<int>>> savedStdout = Future<List<List<int>>>.value(<List<int>>[]);
|
||||
Future<List<List<int>>> savedStderr = Future<List<List<int>>>.value(<List<int>>[]);
|
||||
final Stream<List<int>> stdoutSource = process.stdout
|
||||
.transform<String>(const Utf8Decoder())
|
||||
.transform(const LineSplitter())
|
||||
@@ -128,8 +129,14 @@ Future<Command> startCommand(String executable, List<String> arguments, {
|
||||
.transform(const Utf8Encoder());
|
||||
switch (outputMode) {
|
||||
case OutputMode.print:
|
||||
stdoutSource.listen(io.stdout.add);
|
||||
process.stderr.listen(io.stdout.add);
|
||||
stdoutSource.listen((List<int> output) {
|
||||
io.stdout.add(output);
|
||||
savedStdout.then((List<List<int>> list) => list.add(output));
|
||||
});
|
||||
process.stderr.listen((List<int> output) {
|
||||
io.stdout.add(output);
|
||||
savedStdout.then((List<List<int>> list) => list.add(output));
|
||||
});
|
||||
break;
|
||||
case OutputMode.capture:
|
||||
savedStdout = stdoutSource.toList();
|
||||
|
||||
@@ -85,6 +85,22 @@ const List<String> kWebTestFileKnownFailures = <String>[
|
||||
const String kSmokeTestShardName = 'smoke_tests';
|
||||
const List<String> _kAllBuildModes = <String>['debug', 'profile', 'release'];
|
||||
|
||||
// The seed used to shuffle tests. If not passed with
|
||||
// --test-randomize-ordering-seed=<seed> on the command line, it will be set the
|
||||
// first time it is accessed. Pass zero to turn off shuffling.
|
||||
String? _shuffleSeed;
|
||||
String get shuffleSeed {
|
||||
if (_shuffleSeed == null) {
|
||||
// Change the seed at 7am, UTC.
|
||||
final DateTime seedTime = DateTime.now().toUtc().subtract(const Duration(hours: 7));
|
||||
// Generates YYYYMMDD as the seed, so that testing continues to fail for a
|
||||
// day after the seed changes, and on other days the seed can be used to
|
||||
// replicate failures.
|
||||
_shuffleSeed = '${seedTime.year * 10000 + seedTime.month * 100 + seedTime.day}';
|
||||
}
|
||||
return _shuffleSeed!;
|
||||
}
|
||||
|
||||
/// When you call this, you can pass additional arguments to pass custom
|
||||
/// arguments to flutter test. For example, you might want to call this
|
||||
/// script with the parameter --local-engine=host_debug_unopt to
|
||||
@@ -99,12 +115,20 @@ Future<void> main(List<String> args) async {
|
||||
print('$clock STARTING ANALYSIS');
|
||||
try {
|
||||
flutterTestArgs.addAll(args);
|
||||
final Set<String> removeArgs = <String>{};
|
||||
for (final String arg in args) {
|
||||
if (arg.startsWith('--local-engine='))
|
||||
if (arg.startsWith('--local-engine=')) {
|
||||
localEngineEnv['FLUTTER_LOCAL_ENGINE'] = arg.substring('--local-engine='.length);
|
||||
if (arg.startsWith('--local-engine-src-path='))
|
||||
}
|
||||
if (arg.startsWith('--local-engine-src-path=')) {
|
||||
localEngineEnv['FLUTTER_LOCAL_ENGINE_SRC_PATH'] = arg.substring('--local-engine-src-path='.length);
|
||||
}
|
||||
if (arg.startsWith('--test-randomize-ordering-seed=')) {
|
||||
_shuffleSeed = arg.substring('--test-randomize-ordering-seed='.length);
|
||||
removeArgs.add(arg);
|
||||
}
|
||||
}
|
||||
flutterTestArgs.removeWhere((String arg) => removeArgs.contains(arg));
|
||||
if (Platform.environment.containsKey(CIRRUS_TASK_NAME))
|
||||
print('Running task: ${Platform.environment[CIRRUS_TASK_NAME]}');
|
||||
print('═' * 80);
|
||||
@@ -1437,6 +1461,7 @@ Future<void> _pubRunTest(String workingDirectory, {
|
||||
Duration? perTestTimeout,
|
||||
bool includeLocalEngineEnv = false,
|
||||
bool ensurePrecompiledTool = true,
|
||||
bool shuffleTests = true,
|
||||
}) async {
|
||||
int? cpus;
|
||||
final String? cpuVariable = Platform.environment['CPU']; // CPU is set in cirrus.yml
|
||||
@@ -1459,6 +1484,7 @@ Future<void> _pubRunTest(String workingDirectory, {
|
||||
final List<String> args = <String>[
|
||||
'run',
|
||||
'test',
|
||||
if (shuffleTests) '--test-randomize-ordering-seed=$shuffleSeed',
|
||||
if (useFlutterTestFormatter)
|
||||
'-rjson'
|
||||
else
|
||||
@@ -1532,11 +1558,13 @@ Future<void> _runFlutterTest(String workingDirectory, {
|
||||
List<String> options = const <String>[],
|
||||
Map<String, String>? environment,
|
||||
List<String> tests = const <String>[],
|
||||
bool shuffleTests = true,
|
||||
}) async {
|
||||
assert(!printOutput || outputChecker == null, 'Output either can be printed or checked but not both');
|
||||
|
||||
final List<String> args = <String>[
|
||||
'test',
|
||||
if (shuffleTests) '--test-randomize-ordering-seed=$shuffleSeed',
|
||||
...options,
|
||||
...flutterTestArgs,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user