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
071d4eb2
Unverified
Commit
071d4eb2
authored
Mar 17, 2020
by
Christopher Fujino
Committed by
GitHub
Mar 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
explicitly catch ArgumentError, and add tests (#52757)
parent
a4d30c16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
process.dart
packages/flutter_tools/lib/src/base/process.dart
+6
-0
process_test.dart
...s/flutter_tools/test/general.shard/base/process_test.dart
+28
-0
No files found.
packages/flutter_tools/lib/src/base/process.dart
View file @
071d4eb2
...
...
@@ -542,6 +542,9 @@ class _DefaultProcessUtils implements ProcessUtils {
}
on
Exception
catch
(
error
)
{
_logger
.
printTrace
(
'
$cli
failed with
$error
'
);
return
false
;
}
on
ArgumentError
catch
(
error
)
{
_logger
.
printTrace
(
'
$cli
failed with
$error
'
);
return
false
;
}
}
...
...
@@ -556,6 +559,9 @@ class _DefaultProcessUtils implements ProcessUtils {
}
on
Exception
catch
(
error
)
{
_logger
.
printTrace
(
'
$cli
failed with
$error
'
);
return
false
;
}
on
ArgumentError
catch
(
error
)
{
_logger
.
printTrace
(
'
$cli
failed with
$error
'
);
return
false
;
}
}
...
...
packages/flutter_tools/test/general.shard/base/process_test.dart
View file @
071d4eb2
...
...
@@ -360,6 +360,20 @@ void main() {
);
expect
(
processUtils
.
exitsHappySync
(<
String
>[
'boohoo'
]),
isFalse
);
});
testWithoutContext
(
'catches Exception and returns false'
,
()
{
when
(
mockProcessManager
.
runSync
(<
String
>[
'boohoo'
])).
thenThrow
(
const
ProcessException
(
'Process failed'
,
<
String
>[]),
);
expect
(
processUtils
.
exitsHappySync
(<
String
>[
'boohoo'
]),
isFalse
);
});
testWithoutContext
(
'catches ArgumentError and returns false'
,
()
{
when
(
mockProcessManager
.
runSync
(<
String
>[
'nonesuch'
])).
thenThrow
(
ArgumentError
(
'Invalid argument(s): Cannot find executable for nonesuch'
)
);
expect
(
processUtils
.
exitsHappySync
(<
String
>[
'nonesuch'
]),
isFalse
);
});
});
group
(
'exitsHappy'
,
()
{
...
...
@@ -387,6 +401,20 @@ void main() {
});
expect
(
await
processUtils
.
exitsHappy
(<
String
>[
'boohoo'
]),
isFalse
);
});
testWithoutContext
(
'catches Exception and returns false'
,
()
async
{
when
(
mockProcessManager
.
run
(<
String
>[
'boohoo'
])).
thenThrow
(
const
ProcessException
(
'Process failed'
,
<
String
>[]),
);
expect
(
await
processUtils
.
exitsHappy
(<
String
>[
'boohoo'
]),
isFalse
);
});
testWithoutContext
(
'catches ArgumentError and returns false'
,
()
async
{
when
(
mockProcessManager
.
run
(<
String
>[
'nonesuch'
])).
thenThrow
(
ArgumentError
(
'Invalid argument(s): Cannot find executable for nonesuch'
),
);
expect
(
await
processUtils
.
exitsHappy
(<
String
>[
'nonesuch'
]),
isFalse
);
});
});
}
...
...
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