-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flutter_tools] add shuffle to hermetic run_tests #105462
Merged
fluttergithubbot
merged 5 commits into
flutter:master
from
christopherfujino:improve-run-test
Jun 9, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,9 +222,9 @@ class MemoryStdout extends MemoryIOSink implements io.Stdout { | |
|
||
/// A Stdio that collects stdout and supports simulated stdin. | ||
class FakeStdio extends Stdio { | ||
final MemoryStdout _stdout = MemoryStdout(); | ||
final MemoryStdout _stdout = MemoryStdout()..terminalColumns = 80; | ||
final MemoryIOSink _stderr = MemoryIOSink(); | ||
final StreamController<List<int>> _stdin = StreamController<List<int>>(); | ||
final FakeStdin _stdin = FakeStdin(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously this was failing the cast in https://github.com/christopherfujino/flutter/blob/improve-run-test/packages/flutter_tools/lib/src/base/terminal.dart#L286. |
||
|
||
@override | ||
MemoryStdout get stdout => _stdout; | ||
|
@@ -233,16 +233,52 @@ class FakeStdio extends Stdio { | |
MemoryIOSink get stderr => _stderr; | ||
|
||
@override | ||
Stream<List<int>> get stdin => _stdin.stream; | ||
Stream<List<int>> get stdin => _stdin; | ||
|
||
void simulateStdin(String line) { | ||
_stdin.add(utf8.encode('$line\n')); | ||
_stdin.controller.add(utf8.encode('$line\n')); | ||
} | ||
|
||
@override | ||
bool hasTerminal = true; | ||
|
||
List<String> get writtenToStdout => _stdout.writes.map<String>(_stdout.encoding.decode).toList(); | ||
List<String> get writtenToStderr => _stderr.writes.map<String>(_stderr.encoding.decode).toList(); | ||
} | ||
|
||
class FakeStdin extends Fake implements Stdin { | ||
final StreamController<List<int>> controller = StreamController<List<int>>(); | ||
|
||
@override | ||
bool echoMode = true; | ||
|
||
@override | ||
bool echoNewlineMode = true; | ||
|
||
@override | ||
bool lineMode = true; | ||
|
||
@override | ||
Stream<S> transform<S>(StreamTransformer<List<int>, S> transformer) { | ||
return controller.stream.transform(transformer); | ||
} | ||
|
||
@override | ||
StreamSubscription<List<int>> listen( | ||
void Function(List<int> event)? onData, { | ||
Function? onError, | ||
void Function()? onDone, | ||
bool? cancelOnError, | ||
}) { | ||
return controller.stream.listen( | ||
onData, | ||
onError: onError, | ||
onDone: onDone, | ||
cancelOnError: cancelOnError, | ||
); | ||
} | ||
} | ||
|
||
class FakePlistParser implements PlistParser { | ||
FakePlistParser([Map<String, Object>? underlyingValues]): | ||
_underlyingValues = underlyingValues ?? <String, Object>{}; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cd31 is commandHasTerminal (https://github.com/christopherfujino/flutter/blob/improve-run-test/packages/flutter_tools/lib/src/reporting/custom_dimensions.dart#L102). The global environment was leaking into this test previously; thus, this test was passing on CI, since the Dart VM did not have a terminal attached, yet failing locally since it did. By overriding the context with a
FakeStdio
that defaults tohasTerminal = true
, this dimension should be true both locally and on CI.