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
c81f4c71
Unverified
Commit
c81f4c71
authored
Oct 09, 2018
by
Greg Spencer
Committed by
GitHub
Oct 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Have runAsyncChecked throw a ProcessException instead of a String. (#22710)
parent
052779d4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
6 deletions
+48
-6
process.dart
packages/flutter_tools/lib/src/base/process.dart
+4
-2
simulators.dart
packages/flutter_tools/lib/src/ios/simulators.dart
+26
-4
process_test.dart
packages/flutter_tools/test/base/process_test.dart
+18
-0
No files found.
packages/flutter_tools/lib/src/base/process.dart
View file @
c81f4c71
...
...
@@ -247,8 +247,10 @@ Future<RunResult> runCheckedAsync(List<String> cmd, {
allowReentrantFlutter:
allowReentrantFlutter
,
environment:
environment
,
);
if
(
result
.
exitCode
!=
0
)
throw
'Exit code
${result.exitCode}
from:
${cmd.join(' ')}
:
\n
$result
'
;
if
(
result
.
exitCode
!=
0
)
{
throw
ProcessException
(
cmd
[
0
],
cmd
.
sublist
(
1
),
'Process "
${cmd[0]}
" exited abnormally:
\n
$result
'
,
result
.
exitCode
);
}
return
result
;
}
...
...
packages/flutter_tools/lib/src/ios/simulators.dart
View file @
c81f4c71
...
...
@@ -120,22 +120,44 @@ class SimControl {
}
Future
<
RunResult
>
install
(
String
deviceId
,
String
appPath
)
{
return
runCheckedAsync
(<
String
>[
_xcrunPath
,
'simctl'
,
'install'
,
deviceId
,
appPath
]);
Future
<
RunResult
>
result
;
try
{
result
=
runCheckedAsync
(<
String
>[
_xcrunPath
,
'simctl'
,
'install'
,
deviceId
,
appPath
]);
}
on
ProcessException
catch
(
exception
)
{
throwToolExit
(
'Unable to install
$appPath
on
$deviceId
:
\n
$exception
'
);
}
return
result
;
}
Future
<
RunResult
>
uninstall
(
String
deviceId
,
String
appId
)
{
return
runCheckedAsync
(<
String
>[
_xcrunPath
,
'simctl'
,
'uninstall'
,
deviceId
,
appId
]);
Future
<
RunResult
>
result
;
try
{
result
=
runCheckedAsync
(<
String
>[
_xcrunPath
,
'simctl'
,
'uninstall'
,
deviceId
,
appId
]);
}
on
ProcessException
catch
(
exception
)
{
throwToolExit
(
'Unable to uninstall
$appId
from
$deviceId
:
\n
$exception
'
);
}
return
result
;
}
Future
<
RunResult
>
launch
(
String
deviceId
,
String
appIdentifier
,
[
List
<
String
>
launchArgs
])
{
final
List
<
String
>
args
=
<
String
>[
_xcrunPath
,
'simctl'
,
'launch'
,
deviceId
,
appIdentifier
];
if
(
launchArgs
!=
null
)
args
.
addAll
(
launchArgs
);
return
runCheckedAsync
(
args
);
Future
<
RunResult
>
result
;
try
{
result
=
runCheckedAsync
(
args
);
}
on
ProcessException
catch
(
exception
)
{
throwToolExit
(
'Unable to launch
$appIdentifier
on
$deviceId
:
\n
$exception
'
);
}
return
result
;
}
Future
<
void
>
takeScreenshot
(
String
deviceId
,
String
outputPath
)
async
{
try
{
await
runCheckedAsync
(<
String
>[
_xcrunPath
,
'simctl'
,
'io'
,
deviceId
,
'screenshot'
,
outputPath
]);
}
on
ProcessException
catch
(
exception
)
{
throwToolExit
(
'Unable to take screenshot of
$deviceId
:
\n
$exception
'
);
}
}
}
...
...
packages/flutter_tools/test/base/process_test.dart
View file @
c81f4c71
...
...
@@ -2,12 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/process.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
void
main
(
)
{
group
(
'process exceptions'
,
()
{
ProcessManager
mockProcessManager
;
setUp
(()
{
mockProcessManager
=
MockProcessManager
();
});
testUsingContext
(
'runCheckedAsync exceptions should be ProcessException objects'
,
()
async
{
when
(
mockProcessManager
.
run
(<
String
>[
'false'
]))
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
ProcessResult
>.
value
(
ProcessResult
(
0
,
1
,
''
,
''
)));
expect
(()
async
=>
await
runCheckedAsync
(<
String
>[
'false'
]),
throwsA
(
isInstanceOf
<
ProcessException
>()));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
});
});
group
(
'shutdownHooks'
,
()
{
testUsingContext
(
'runInExpectedOrder'
,
()
async
{
int
i
=
1
;
...
...
@@ -41,3 +57,5 @@ void main() {
});
});
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
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