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
46a5c550
Unverified
Commit
46a5c550
authored
Apr 29, 2020
by
Jenn Magder
Committed by
GitHub
Apr 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add iOS simulator log parse test (#55808)
parent
7ec50ddd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
52 deletions
+76
-52
simulators_test.dart
...flutter_tools/test/general.shard/ios/simulators_test.dart
+76
-52
No files found.
packages/flutter_tools/test/general.shard/ios/simulators_test.dart
View file @
46a5c550
...
...
@@ -517,13 +517,13 @@ void main() {
});
group
(
'log reader'
,
()
{
MockProcessManager
mock
ProcessManager
;
FakeProcessManager
fake
ProcessManager
;
MockIosProject
mockIosProject
;
MockSimControl
mockSimControl
;
MockXcode
mockXcode
;
setUp
(()
{
mockProcessManager
=
MockProcessManager
(
);
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[]
);
mockIosProject
=
MockIosProject
();
mockSimControl
=
MockSimControl
();
mockXcode
=
MockXcode
();
...
...
@@ -535,25 +535,49 @@ void main() {
osx
.
environment
[
'IOS_SIMULATOR_LOG_FILE_PATH'
]
=
syslog
.
path
;
});
testUsingContext
(
'simulator can parse Xcode 8/iOS 10-style logs'
,
()
async
{
fakeProcessManager
..
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'tail'
,
'-n'
,
'0'
,
'-F'
,
'system.log'
],
stdout:
'Dec 20 17:04:32 md32-11-vm1 Runner[88374]: flutter: Observatory listening on http://127.0.0.1:64213/1Uoeu523990=/'
,
))
..
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'tail'
,
'-n'
,
'0'
,
'-F'
,
'/private/var/log/system.log'
]
));
final
IOSSimulator
device
=
IOSSimulator
(
'123456'
,
simulatorCategory:
'iOS 10.0'
,
simControl:
mockSimControl
,
xcode:
mockXcode
,
);
final
DeviceLogReader
logReader
=
device
.
getLogReader
(
app:
await
BuildableIOSApp
.
fromProject
(
mockIosProject
),
);
final
List
<
String
>
lines
=
await
logReader
.
logLines
.
toList
();
expect
(
lines
,
<
String
>[
'flutter: Observatory listening on http://127.0.0.1:64213/1Uoeu523990=/'
,
]);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
fakeProcessManager
,
FileSystem:
()
=>
fileSystem
,
Platform:
()
=>
osx
,
});
testUsingContext
(
'simulator can output `)`'
,
()
async
{
when
(
mockProcessManager
.
start
(
any
,
environment:
null
,
workingDirectory:
null
))
.
thenAnswer
((
Invocation
invocation
)
{
final
Process
mockProcess
=
MockProcess
();
when
(
mockProcess
.
stdout
)
.
thenAnswer
((
Invocation
invocation
)
{
return
Stream
<
List
<
int
>>.
fromIterable
(<
List
<
int
>>[
'''
fakeProcessManager
..
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'tail'
,
'-n'
,
'0'
,
'-F'
,
'system.log'
],
stdout:
'''
2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) Observatory listening on http://127.0.0.1:57701/
2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) ))))))))))
2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) #0 Object.noSuchMethod (dart:core-patch/dart:core/object_patch.dart:46)'''
.
codeUnits
]);
});
when
(
mockProcess
.
stderr
)
.
thenAnswer
((
Invocation
invocation
)
=>
const
Stream
<
List
<
int
>>.
empty
());
// Delay return of exitCode until after stdout stream data, since it terminates the logger.
when
(
mockProcess
.
exitCode
)
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
int
>.
delayed
(
Duration
.
zero
,
()
=>
0
));
return
Future
<
Process
>.
value
(
mockProcess
);
});
))
..
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'tail'
,
'-n'
,
'0'
,
'-F'
,
'/private/var/log/system.log'
]
));
final
IOSSimulator
device
=
IOSSimulator
(
'123456'
,
...
...
@@ -571,20 +595,18 @@ void main() {
'))))))))))'
,
'#0 Object.noSuchMethod (dart:core-patch/dart:core/object_patch.dart:46)'
,
]);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mock
ProcessManager
,
ProcessManager:
()
=>
fake
ProcessManager
,
FileSystem:
()
=>
fileSystem
,
Platform:
()
=>
osx
,
});
testUsingContext
(
'log reader handles multiline messages'
,
()
async
{
when
(
mockProcessManager
.
start
(
any
,
environment:
null
,
workingDirectory:
null
))
.
thenAnswer
((
Invocation
invocation
)
{
final
Process
mockProcess
=
MockProcess
();
when
(
mockProcess
.
stdout
)
.
thenAnswer
((
Invocation
invocation
)
{
// Messages from 2017 should pass through, 2020 message should not
return
Stream
<
List
<
int
>>.
fromIterable
(<
List
<
int
>>[
'''
testUsingContext
(
'multiline messages'
,
()
async
{
fakeProcessManager
..
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'tail'
,
'-n'
,
'0'
,
'-F'
,
'system.log'
],
stdout:
'''
2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) Single line message
2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) Multi line message
continues...
...
...
@@ -599,15 +621,10 @@ void main() {
and goes...
2017-09-13 15:36:57.228948-0700 localhost Runner[37195]: (Flutter) Single line message, not the part of the above
'''
.
codeUnits
]);
});
when
(
mockProcess
.
stderr
)
.
thenAnswer
((
Invocation
invocation
)
=>
const
Stream
<
List
<
int
>>.
empty
());
// Delay return of exitCode until after stdout stream data, since it terminates the logger.
when
(
mockProcess
.
exitCode
)
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
int
>.
delayed
(
Duration
.
zero
,
()
=>
0
));
return
Future
<
Process
>.
value
(
mockProcess
);
});
))
..
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'tail'
,
'-n'
,
'0'
,
'-F'
,
'/private/var/log/system.log'
]
));
final
IOSSimulator
device
=
IOSSimulator
(
'123456'
,
...
...
@@ -630,8 +647,9 @@ void main() {
' and goes...'
,
'Single line message, not the part of the above'
]);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mock
ProcessManager
,
ProcessManager:
()
=>
fake
ProcessManager
,
FileSystem:
()
=>
fileSystem
,
Platform:
()
=>
osx
,
});
...
...
@@ -639,12 +657,25 @@ void main() {
group
(
'unified logging'
,
()
{
testUsingContext
(
'log reader handles escaped multiline messages'
,
()
async
{
when
(
mockProcessManager
.
start
(
any
,
environment:
null
,
workingDirectory:
null
))
.
thenAnswer
((
Invocation
invocation
)
{
final
Process
mockProcess
=
MockProcess
();
when
(
mockProcess
.
stdout
)
.
thenAnswer
((
Invocation
invocation
)
{
return
Stream
<
List
<
int
>>.
fromIterable
(<
List
<
int
>>[
'''
const
String
logPredicate
=
'eventType = logEvent AND processImagePath ENDSWITH "Runner" '
'AND (senderImagePath ENDSWITH "/Flutter" OR senderImagePath ENDSWITH "/libswiftCore.dylib" '
'OR processImageUUID == senderImageUUID) AND NOT(eventMessage CONTAINS ": could not find icon '
'for representation -> com.apple.") AND NOT(eventMessage BEGINSWITH "assertion failed: ") '
'AND NOT(eventMessage CONTAINS " libxpc.dylib ")'
;
fakeProcessManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/usr/bin/xcrun'
,
'simctl'
,
'spawn'
,
'123456'
,
'log'
,
'stream'
,
'--style'
,
'json'
,
'--predicate'
,
logPredicate
,
],
stdout:
'''
},{
"traceID" : 37579774151491588,
"eventMessage" : "Single line message",
...
...
@@ -658,15 +689,7 @@ void main() {
"eventType" : "logEvent"
},{
'''
.
codeUnits
]);
});
when
(
mockProcess
.
stderr
)
.
thenAnswer
((
Invocation
invocation
)
=>
const
Stream
<
List
<
int
>>.
empty
());
// Delay return of exitCode until after stdout stream data, since it terminates the logger.
when
(
mockProcess
.
exitCode
)
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
int
>.
delayed
(
Duration
.
zero
,
()
=>
0
));
return
Future
<
Process
>.
value
(
mockProcess
);
});
));
final
IOSSimulator
device
=
IOSSimulator
(
'123456'
,
...
...
@@ -683,8 +706,9 @@ void main() {
'Single line message'
,
'Multi line message
\n
continues...
\n
continues...'
,
'Single line message, not the part of the above'
]);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mock
ProcessManager
,
ProcessManager:
()
=>
fake
ProcessManager
,
FileSystem:
()
=>
fileSystem
,
});
});
...
...
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