Skip to content

Commit 8bea632

Browse files
[flutter_tools] add shuffle to hermetic run_tests (#105462)
1 parent 0cdb3bf commit 8bea632

File tree

2 files changed

+42
-12
lines changed

2 files changed

+42
-12
lines changed

packages/flutter_tools/test/commands.shard/hermetic/run_test.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44

55
// @dart = 2.8
66

7-
// TODO(gspencergoog): Remove this tag once this test's state leaks/test
8-
// dependencies have been fixed.
9-
// https://github.com/flutter/flutter/issues/85160
10-
// Fails with "flutter test --test-randomize-ordering-seed=1000"
11-
@Tags(<String>['no-shuffle'])
12-
137
import 'dart:async';
148

159
import 'package:file/file.dart';
@@ -405,7 +399,6 @@ void main() {
405399
Usage: () => usage,
406400
});
407401

408-
409402
testUsingContext('passes device target platform to usage', () async {
410403
final RunCommand command = RunCommand();
411404
final FakeDevice mockDevice = FakeDevice(sdkNameAndVersion: 'iOS 13')
@@ -431,7 +424,7 @@ void main() {
431424
expect(usage.commands, contains(
432425
TestUsageCommand('run', parameters: CustomDimensions.fromMap(<String, String>{
433426
'cd3': 'false', 'cd4': 'ios', 'cd22': 'iOS 13',
434-
'cd23': 'debug', 'cd18': 'false', 'cd15': 'swift', 'cd31': 'false',
427+
'cd23': 'debug', 'cd18': 'false', 'cd15': 'swift', 'cd31': 'true',
435428
'cd56': 'false',
436429
})
437430
)));
@@ -441,6 +434,7 @@ void main() {
441434
DeviceManager: () => mockDeviceManager,
442435
FileSystem: () => fs,
443436
ProcessManager: () => FakeProcessManager.any(),
437+
Stdio: () => FakeStdio(),
444438
Usage: () => usage,
445439
});
446440

packages/flutter_tools/test/src/fakes.dart

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ class MemoryStdout extends MemoryIOSink implements io.Stdout {
222222

223223
/// A Stdio that collects stdout and supports simulated stdin.
224224
class FakeStdio extends Stdio {
225-
final MemoryStdout _stdout = MemoryStdout();
225+
final MemoryStdout _stdout = MemoryStdout()..terminalColumns = 80;
226226
final MemoryIOSink _stderr = MemoryIOSink();
227-
final StreamController<List<int>> _stdin = StreamController<List<int>>();
227+
final FakeStdin _stdin = FakeStdin();
228228

229229
@override
230230
MemoryStdout get stdout => _stdout;
@@ -233,16 +233,52 @@ class FakeStdio extends Stdio {
233233
MemoryIOSink get stderr => _stderr;
234234

235235
@override
236-
Stream<List<int>> get stdin => _stdin.stream;
236+
Stream<List<int>> get stdin => _stdin;
237237

238238
void simulateStdin(String line) {
239-
_stdin.add(utf8.encode('$line\n'));
239+
_stdin.controller.add(utf8.encode('$line\n'));
240240
}
241241

242+
@override
243+
bool hasTerminal = true;
244+
242245
List<String> get writtenToStdout => _stdout.writes.map<String>(_stdout.encoding.decode).toList();
243246
List<String> get writtenToStderr => _stderr.writes.map<String>(_stderr.encoding.decode).toList();
244247
}
245248

249+
class FakeStdin extends Fake implements Stdin {
250+
final StreamController<List<int>> controller = StreamController<List<int>>();
251+
252+
@override
253+
bool echoMode = true;
254+
255+
@override
256+
bool echoNewlineMode = true;
257+
258+
@override
259+
bool lineMode = true;
260+
261+
@override
262+
Stream<S> transform<S>(StreamTransformer<List<int>, S> transformer) {
263+
return controller.stream.transform(transformer);
264+
}
265+
266+
@override
267+
StreamSubscription<List<int>> listen(
268+
void Function(List<int> event)? onData, {
269+
Function? onError,
270+
void Function()? onDone,
271+
bool? cancelOnError,
272+
}) {
273+
return controller.stream.listen(
274+
onData,
275+
onError: onError,
276+
onDone: onDone,
277+
cancelOnError: cancelOnError,
278+
);
279+
}
280+
}
281+
246282
class FakePlistParser implements PlistParser {
247283
FakePlistParser([Map<String, Object>? underlyingValues]):
248284
_underlyingValues = underlyingValues ?? <String, Object>{};

0 commit comments

Comments
 (0)