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
97127730
Unverified
Commit
97127730
authored
Jun 28, 2019
by
Zachary Anderson
Committed by
GitHub
Jun 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Fill in Fuchsia version string (#34516)
parent
8418daae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
1 deletion
+77
-1
fuchsia_device.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+14
-1
fuchsia_device_test.dart
packages/flutter_tools/test/fuchsia/fuchsia_device_test.dart
+63
-0
No files found.
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
View file @
97127730
...
...
@@ -358,7 +358,20 @@ class FuchsiaDevice extends Device {
Future
<
TargetPlatform
>
get
targetPlatform
async
=>
TargetPlatform
.
fuchsia
;
@override
Future
<
String
>
get
sdkNameAndVersion
async
=>
'Fuchsia'
;
Future
<
String
>
get
sdkNameAndVersion
async
{
const
String
versionPath
=
'/pkgfs/packages/build-info/0/data/version'
;
final
RunResult
catResult
=
await
shell
(
'cat
$versionPath
'
);
if
(
catResult
.
exitCode
!=
0
)
{
printTrace
(
'Failed to cat
$versionPath
:
${catResult.stderr}
'
);
return
'Fuchsia'
;
}
final
String
version
=
catResult
.
stdout
.
trim
();
if
(
version
.
isEmpty
)
{
printTrace
(
'
$versionPath
was empty'
);
return
'Fuchsia'
;
}
return
'Fuchsia
$version
'
;
}
@override
DeviceLogReader
getLogReader
({
ApplicationPackage
app
})
=>
...
...
packages/flutter_tools/test/fuchsia/fuchsia_device_test.dart
View file @
97127730
...
...
@@ -571,6 +571,69 @@ void main() {
});
});
group
(
'sdkNameAndVersion: '
,
()
{
MockFile
sshConfig
;
MockProcessManager
mockSuccessProcessManager
;
MockProcessResult
mockSuccessProcessResult
;
MockProcessManager
mockFailureProcessManager
;
MockProcessResult
mockFailureProcessResult
;
MockProcessManager
emptyStdoutProcessManager
;
MockProcessResult
emptyStdoutProcessResult
;
setUp
(()
{
sshConfig
=
MockFile
();
when
(
sshConfig
.
absolute
).
thenReturn
(
sshConfig
);
mockSuccessProcessManager
=
MockProcessManager
();
mockSuccessProcessResult
=
MockProcessResult
();
when
(
mockSuccessProcessManager
.
run
(
any
)).
thenAnswer
(
(
Invocation
invocation
)
=>
Future
<
ProcessResult
>.
value
(
mockSuccessProcessResult
));
when
(
mockSuccessProcessResult
.
exitCode
).
thenReturn
(
0
);
when
<
String
>(
mockSuccessProcessResult
.
stdout
).
thenReturn
(
'version'
);
when
<
String
>(
mockSuccessProcessResult
.
stderr
).
thenReturn
(
''
);
mockFailureProcessManager
=
MockProcessManager
();
mockFailureProcessResult
=
MockProcessResult
();
when
(
mockFailureProcessManager
.
run
(
any
)).
thenAnswer
(
(
Invocation
invocation
)
=>
Future
<
ProcessResult
>.
value
(
mockFailureProcessResult
));
when
(
mockFailureProcessResult
.
exitCode
).
thenReturn
(
1
);
when
<
String
>(
mockFailureProcessResult
.
stdout
).
thenReturn
(
''
);
when
<
String
>(
mockFailureProcessResult
.
stderr
).
thenReturn
(
''
);
emptyStdoutProcessManager
=
MockProcessManager
();
emptyStdoutProcessResult
=
MockProcessResult
();
when
(
emptyStdoutProcessManager
.
run
(
any
)).
thenAnswer
((
Invocation
invocation
)
=>
Future
<
ProcessResult
>.
value
(
emptyStdoutProcessResult
));
when
(
emptyStdoutProcessResult
.
exitCode
).
thenReturn
(
0
);
when
<
String
>(
emptyStdoutProcessResult
.
stdout
).
thenReturn
(
''
);
when
<
String
>(
emptyStdoutProcessResult
.
stderr
).
thenReturn
(
''
);
});
testUsingContext
(
'returns what we get from the device on success'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia version'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockSuccessProcessManager
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
});
testUsingContext
(
'returns "Fuchsia" when device command fails'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockFailureProcessManager
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
});
testUsingContext
(
'returns "Fuchsia" when device gives an empty result'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
emptyStdoutProcessManager
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
});
});
}
class
FuchsiaModulePackage
extends
ApplicationPackage
{
...
...
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