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
50fb7296
Unverified
Commit
50fb7296
authored
Nov 07, 2018
by
jslavitz
Committed by
GitHub
Nov 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Includes frameworkVersion in JSON version output (#23891)
* Include framework version in JSON output and adds test
parent
73428160
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
3 deletions
+46
-3
version.dart
packages/flutter_tools/lib/src/version.dart
+1
-0
flutter_command_runner_test.dart
...lutter_tools/test/runner/flutter_command_runner_test.dart
+45
-3
No files found.
packages/flutter_tools/lib/src/version.dart
View file @
50fb7296
...
...
@@ -108,6 +108,7 @@ class FlutterVersion {
}
Map
<
String
,
Object
>
toJson
()
=>
<
String
,
Object
>{
'frameworkVersion'
:
frameworkVersion
??
'unknown'
,
'channel'
:
channel
,
'repositoryUrl'
:
repositoryUrl
??
'unknown source'
,
'frameworkRevision'
:
frameworkRevision
,
...
...
packages/flutter_tools/test/runner/flutter_command_runner_test.dart
View file @
50fb7296
...
...
@@ -13,6 +13,7 @@ import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
import
'package:flutter_tools/src/version.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:platform/platform.dart'
;
import
'package:process/process.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
...
...
@@ -28,6 +29,7 @@ void main() {
MemoryFileSystem
fs
;
Platform
platform
;
FlutterCommandRunner
runner
;
ProcessManager
processManager
;
setUpAll
(()
{
Cache
.
disableLocking
();
...
...
@@ -39,11 +41,15 @@ void main() {
fs
.
directory
(
_kProjectRoot
).
createSync
(
recursive:
true
);
fs
.
currentDirectory
=
_kProjectRoot
;
platform
=
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
_kFlutterRoot
,
});
platform
=
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
_kFlutterRoot
,
},
version:
'1 2 3 4 5'
,
);
runner
=
createTestCommandRunner
(
DummyFlutterCommand
());
processManager
=
MockProcessManager
();
});
group
(
'run'
,
()
{
...
...
@@ -73,6 +79,36 @@ void main() {
},
initializeFlutterRoot:
false
);
});
group
(
'version'
,
()
{
testUsingContext
(
'checks that Flutter toJson output reports the flutter framework version'
,
()
async
{
final
ProcessResult
result
=
ProcessResult
(
0
,
0
,
'random'
,
'0'
);
when
(
processManager
.
runSync
(
'git log -n 1 --pretty=format:%H'
.
split
(
' '
),
workingDirectory:
Cache
.
flutterRoot
)).
thenReturn
(
result
);
when
(
processManager
.
runSync
(
'git rev-parse --abbrev-ref --symbolic @{u}'
.
split
(
' '
),
workingDirectory:
Cache
.
flutterRoot
)).
thenReturn
(
result
);
when
(
processManager
.
runSync
(
'git rev-parse --abbrev-ref HEAD'
.
split
(
' '
),
workingDirectory:
Cache
.
flutterRoot
)).
thenReturn
(
result
);
when
(
processManager
.
runSync
(
'git ls-remote --get-url master'
.
split
(
' '
),
workingDirectory:
Cache
.
flutterRoot
)).
thenReturn
(
result
);
when
(
processManager
.
runSync
(
'git log -n 1 --pretty=format:%ar'
.
split
(
' '
),
workingDirectory:
Cache
.
flutterRoot
)).
thenReturn
(
result
);
when
(
processManager
.
runSync
(
'git describe --match v*.*.* --first-parent --long --tags'
.
split
(
' '
),
workingDirectory:
Cache
.
flutterRoot
)).
thenReturn
(
result
);
when
(
processManager
.
runSync
(
'git log -n 1 --pretty=format:%ad --date=iso'
.
split
(
' '
),
workingDirectory:
Cache
.
flutterRoot
)).
thenReturn
(
result
);
final
FakeFlutterVersion
version
=
FakeFlutterVersion
();
// Because the hash depends on the time, we just use the 0.0.0-unknown here.
expect
(
version
.
toJson
()[
'frameworkVersion'
],
'0.10.3'
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
Platform:
()
=>
platform
,
ProcessManager:
()
=>
processManager
,
},
initializeFlutterRoot:
false
);
});
group
(
'getRepoPackages'
,
()
{
setUp
(()
{
fs
.
directory
(
fs
.
path
.
join
(
_kFlutterRoot
,
'examples'
))
...
...
@@ -144,6 +180,12 @@ void main() {
});
});
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
FakeFlutterVersion
extends
FlutterVersion
{
@override
String
get
frameworkVersion
=>
'0.10.3'
;
}
class
FakeCommand
extends
FlutterCommand
{
OutputPreferences
preferences
;
...
...
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