Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
84c8abd0
Unverified
Commit
84c8abd0
authored
Jul 07, 2022
by
Christopher Fujino
Committed by
GitHub
Jul 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] catch StdinException while trying to re-set single char mode (#107256)
parent
26c64569
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+6
-1
run_test.dart
.../flutter_tools/test/commands.shard/hermetic/run_test.dart
+31
-1
No files found.
packages/flutter_tools/lib/src/commands/run.dart
View file @
84c8abd0
...
...
@@ -12,6 +12,7 @@ import 'package:vm_service/vm_service.dart';
import
'../android/android_device.dart'
;
import
'../base/common.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/utils.dart'
;
import
'../build_info.dart'
;
import
'../daemon.dart'
;
...
...
@@ -719,7 +720,11 @@ class RunCommand extends RunCommandBase {
}
finally
{
// However we exited from the runner, ensure the terminal has line mode
// and echo mode enabled before we return the user to the shell.
globals
.
terminal
.
singleCharMode
=
false
;
try
{
globals
.
terminal
.
singleCharMode
=
false
;
}
on
StdinException
{
// Do nothing, if the STDIN handle is no longer available, there is nothing actionable for us to do at this point
}
}
return
FlutterCommandResult
(
ExitStatus
.
success
,
...
...
packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
View file @
84c8abd0
...
...
@@ -682,6 +682,28 @@ void main() {
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
testUsingContext
(
'Flutter run catches StdinException while setting terminal singleCharMode to false'
,
()
async
{
fakeTerminal
.
hasStdin
=
false
;
final
FakeResidentRunner
residentRunner
=
FakeResidentRunner
();
final
TestRunCommandWithFakeResidentRunner
command
=
TestRunCommandWithFakeResidentRunner
();
command
.
fakeResidentRunner
=
residentRunner
;
try
{
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'run'
,
'--no-pub'
,
]);
}
catch
(
err
)
{
// ignore: avoid_catches_without_on_clauses
fail
(
'Expected no error, got
$err
'
);
}
expect
(
fakeTerminal
.
setSingleCharModeHistory
,
isEmpty
);
},
overrides:
<
Type
,
Generator
>{
AnsiTerminal:
()
=>
fakeTerminal
,
Cache:
()
=>
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()),
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
});
testUsingContext
(
'Flutter run catches service has disappear errors and throws a tool exit'
,
()
async
{
...
...
@@ -1050,6 +1072,9 @@ class CapturingAppDomain extends AppDomain {
}
class
FakeAnsiTerminal
extends
Fake
implements
AnsiTerminal
{
/// Setting to false will cause operations to Stdin to throw a [StdinException].
bool
hasStdin
=
true
;
@override
bool
usesTerminalUi
=
false
;
...
...
@@ -1057,7 +1082,12 @@ class FakeAnsiTerminal extends Fake implements AnsiTerminal {
List
<
bool
>
setSingleCharModeHistory
=
<
bool
>[];
@override
set
singleCharMode
(
bool
value
)
=>
setSingleCharModeHistory
.
add
(
value
);
set
singleCharMode
(
bool
value
)
{
if
(!
hasStdin
)
{
throw
const
StdinException
(
'Error setting terminal line mode'
,
OSError
(
'The handle is invalid'
,
6
));
}
setSingleCharModeHistory
.
add
(
value
);
}
@override
bool
get
singleCharMode
=>
setSingleCharModeHistory
.
last
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment