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
7d1fbcae
Unverified
Commit
7d1fbcae
authored
Mar 20, 2020
by
Christopher Fujino
Committed by
GitHub
Mar 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor exits happy (#52916)
parent
27383415
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
30 deletions
+56
-30
process.dart
packages/flutter_tools/lib/src/base/process.dart
+10
-6
mac.dart
packages/flutter_tools/lib/src/ios/mac.dart
+1
-12
process_test.dart
...s/flutter_tools/test/general.shard/base/process_test.dart
+34
-12
code_signing_test.dart
...utter_tools/test/general.shard/ios/code_signing_test.dart
+2
-0
cocoapods_test.dart
...lutter_tools/test/general.shard/macos/cocoapods_test.dart
+9
-0
No files found.
packages/flutter_tools/lib/src/base/process.dart
View file @
7d1fbcae
...
...
@@ -537,14 +537,16 @@ class _DefaultProcessUtils implements ProcessUtils {
Map
<
String
,
String
>
environment
,
})
{
_traceCommand
(
cli
);
if
(!
_processManager
.
canRun
(
cli
.
first
))
{
_logger
.
printTrace
(
'
$cli
either does not exist or is not executable.'
);
return
false
;
}
try
{
return
_processManager
.
runSync
(
cli
,
environment:
environment
).
exitCode
==
0
;
}
on
Exception
catch
(
error
)
{
_logger
.
printTrace
(
'
$cli
failed with
$error
'
);
return
false
;
}
on
ArgumentError
catch
(
error
)
{
_logger
.
printTrace
(
'
$cli
failed with
$error
'
);
return
false
;
}
}
...
...
@@ -554,14 +556,16 @@ class _DefaultProcessUtils implements ProcessUtils {
Map
<
String
,
String
>
environment
,
})
async
{
_traceCommand
(
cli
);
if
(!
_processManager
.
canRun
(
cli
.
first
))
{
_logger
.
printTrace
(
'
$cli
either does not exist or is not executable.'
);
return
false
;
}
try
{
return
(
await
_processManager
.
run
(
cli
,
environment:
environment
)).
exitCode
==
0
;
}
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/lib/src/ios/mac.dart
View file @
7d1fbcae
...
...
@@ -35,18 +35,7 @@ class IMobileDevice {
final
String
_idevicesyslogPath
;
final
String
_idevicescreenshotPath
;
bool
get
isInstalled
{
_isInstalled
??=
processUtils
.
exitsHappySync
(
<
String
>[
_idevicescreenshotPath
,
'-h'
,
],
environment:
Map
<
String
,
String
>.
fromEntries
(
<
MapEntry
<
String
,
String
>>[
globals
.
cache
.
dyLdLibEntry
]
),
);
return
_isInstalled
;
}
bool
get
isInstalled
=>
_isInstalled
??=
globals
.
processManager
.
canRun
(
_idevicescreenshotPath
);
bool
_isInstalled
;
/// Starts `idevicesyslog` and returns the running process.
...
...
packages/flutter_tools/test/general.shard/base/process_test.dart
View file @
7d1fbcae
...
...
@@ -336,7 +336,7 @@ void main() {
});
group
(
'exitsHappySync'
,
()
{
ProcessManager
mockProcessManager
;
Mock
ProcessManager
mockProcessManager
;
ProcessUtils
processUtils
;
setUp
(()
{
...
...
@@ -368,16 +368,27 @@ void main() {
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'
)
);
testWithoutContext
(
'does not throw Exception and returns false if binary cannot run'
,
()
{
mockProcessManager
.
canRunSucceeds
=
false
;
expect
(
processUtils
.
exitsHappySync
(<
String
>[
'nonesuch'
]),
isFalse
);
verifyNever
(
mockProcessManager
.
runSync
(
any
,
environment:
anyNamed
(
'environment'
)),
);
});
testWithoutContext
(
'does not catch ArgumentError'
,
()
async
{
when
(
mockProcessManager
.
runSync
(<
String
>[
'invalid'
])).
thenThrow
(
ArgumentError
(
'Bad input'
),
);
expect
(
()
=>
processUtils
.
exitsHappySync
(<
String
>[
'invalid'
]),
throwsArgumentError
,
);
});
});
group
(
'exitsHappy'
,
()
{
ProcessManager
mockProcessManager
;
Mock
ProcessManager
mockProcessManager
;
ProcessUtils
processUtils
;
setUp
(()
{
...
...
@@ -388,14 +399,14 @@ void main() {
);
});
testWithoutContext
(
'
succeeds on success'
,
()
async
{
testWithoutContext
(
'succeeds on success'
,
()
async
{
when
(
mockProcessManager
.
run
(<
String
>[
'whoohoo'
])).
thenAnswer
((
_
)
{
return
Future
<
ProcessResult
>.
value
(
ProcessResult
(
0
,
0
,
''
,
''
));
});
expect
(
await
processUtils
.
exitsHappy
(<
String
>[
'whoohoo'
]),
isTrue
);
});
testWithoutContext
(
'
fails on failure'
,
()
async
{
testWithoutContext
(
'fails on failure'
,
()
async
{
when
(
mockProcessManager
.
run
(<
String
>[
'boohoo'
])).
thenAnswer
((
_
)
{
return
Future
<
ProcessResult
>.
value
(
ProcessResult
(
0
,
1
,
''
,
''
));
});
...
...
@@ -409,11 +420,22 @@ void main() {
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'
),
);
testWithoutContext
(
'does not throw Exception and returns false if binary cannot run'
,
()
async
{
mockProcessManager
.
canRunSucceeds
=
false
;
expect
(
await
processUtils
.
exitsHappy
(<
String
>[
'nonesuch'
]),
isFalse
);
verifyNever
(
mockProcessManager
.
runSync
(
any
,
environment:
anyNamed
(
'environment'
)),
);
});
testWithoutContext
(
'does not catch ArgumentError'
,
()
async
{
when
(
mockProcessManager
.
run
(<
String
>[
'invalid'
])).
thenThrow
(
ArgumentError
(
'Bad input'
),
);
expect
(
()
async
=>
await
processUtils
.
exitsHappy
(<
String
>[
'invalid'
]),
throwsArgumentError
,
);
});
});
...
...
packages/flutter_tools/test/general.shard/ios/code_signing_test.dart
View file @
7d1fbcae
...
...
@@ -30,6 +30,8 @@ void main() {
setUp
(()
async
{
mockProcessManager
=
MockProcessManager
();
// Assume all binaries exist and are executable
when
(
mockProcessManager
.
canRun
(
any
)).
thenReturn
(
true
);
mockConfig
=
MockConfig
();
mockIosProject
=
MockIosProject
();
when
(
mockIosProject
.
buildSettings
).
thenAnswer
((
_
)
{
...
...
packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
View file @
7d1fbcae
...
...
@@ -134,6 +134,11 @@ void main() {
}
group
(
'Evaluate installation'
,
()
{
setUp
(()
{
// Assume all binaries can run
when
(
mockProcessManager
.
canRun
(
any
)).
thenReturn
(
true
);
});
testUsingContext
(
'detects not installed, if pod exec does not exist'
,
()
async
{
pretendPodIsNotInstalled
();
expect
(
await
cocoaPodsUnderTest
.
evaluateCocoaPodsInstallation
,
CocoaPodsStatus
.
notInstalled
);
...
...
@@ -328,6 +333,8 @@ void main() {
group
(
'Process pods'
,
()
{
setUp
(()
{
podsIsInHomeDir
();
// Assume all binaries can run
when
(
mockProcessManager
.
canRun
(
any
)).
thenReturn
(
true
);
});
testUsingContext
(
'throwsToolExit if CocoaPods is not installed'
,
()
async
{
...
...
@@ -674,6 +681,8 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
String
cocoapodsRepoDir
;
Map
<
String
,
String
>
environment
;
setUp
(()
{
// Assume binaries exist and can run
when
(
mockProcessManager
.
canRun
(
any
)).
thenReturn
(
true
);
cocoapodsRepoDir
=
podsIsInCustomDir
();
environment
=
<
String
,
String
>{
'FLUTTER_FRAMEWORK_DIR'
:
'engine/path'
,
...
...
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