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
2d2cd1f5
Unverified
Commit
2d2cd1f5
authored
Dec 29, 2021
by
Christopher Fujino
Committed by
GitHub
Dec 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Refactor checkVersionFreshness (#95056)
parent
7addb913
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
185 additions
and
120 deletions
+185
-120
globals.dart
packages/flutter_tools/lib/src/globals.dart
+3
-0
version.dart
packages/flutter_tools/lib/src/version.dart
+154
-92
version_test.dart
packages/flutter_tools/test/general.shard/version_test.dart
+28
-28
No files found.
packages/flutter_tools/lib/src/globals.dart
View file @
2d2cd1f5
...
...
@@ -278,3 +278,6 @@ FlutterProjectFactory get projectFactory {
CustomDevicesConfig
get
customDevicesConfig
=>
context
.
get
<
CustomDevicesConfig
>()!;
PreRunValidator
get
preRunValidator
=>
context
.
get
<
PreRunValidator
>()
??
const
NoOpPreRunValidator
();
// TODO(fujino): Migrate to 'main' https://github.com/flutter/flutter/issues/95041
const
String
kDefaultFrameworkChannel
=
'master'
;
packages/flutter_tools/lib/src/version.dart
View file @
2d2cd1f5
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/version_test.dart
View file @
2d2cd1f5
...
...
@@ -20,8 +20,8 @@ import '../src/context.dart';
import
'../src/fake_process_manager.dart'
;
final
SystemClock
_testClock
=
SystemClock
.
fixed
(
DateTime
(
2015
));
final
DateTime
_stampUpToDate
=
_testClock
.
ago
(
checkAgeConsideredUpToDate
~/
2
);
final
DateTime
_stampOutOfDate
=
_testClock
.
ago
(
checkAgeConsideredUpToDate
*
2
);
final
DateTime
_stampUpToDate
=
_testClock
.
ago
(
VersionFreshnessValidator
.
checkAgeConsideredUpToDate
~/
2
);
final
DateTime
_stampOutOfDate
=
_testClock
.
ago
(
VersionFreshnessValidator
.
checkAgeConsideredUpToDate
*
2
);
void
main
(
)
{
FakeCache
cache
;
...
...
@@ -42,17 +42,17 @@ void main() {
for
(
final
String
channel
in
kOfficialChannels
)
{
DateTime
getChannelUpToDateVersion
()
{
return
_testClock
.
ago
(
versionAgeConsideredUpToDate
(
channel
)
~/
2
);
return
_testClock
.
ago
(
VersionFreshnessValidator
.
versionAgeConsideredUpToDate
(
channel
)
~/
2
);
}
DateTime
getChannelOutOfDateVersion
()
{
return
_testClock
.
ago
(
versionAgeConsideredUpToDate
(
channel
)
*
2
);
return
_testClock
.
ago
(
VersionFreshnessValidator
.
versionAgeConsideredUpToDate
(
channel
)
*
2
);
}
group
(
'
$FlutterVersion
for
$channel
'
,
()
{
setUpAll
(()
{
Cache
.
disableLocking
();
timeToPauseToLetUserReadTheMessage
=
Duration
.
zero
;
VersionFreshnessValidator
.
timeToPauseToLetUserReadTheMessage
=
Duration
.
zero
;
});
testUsingContext
(
'prints nothing when Flutter installation looks fresh'
,
()
async
{
...
...
@@ -151,14 +151,14 @@ void main() {
);
cache
.
versionStamp
=
json
.
encode
(
stamp
);
await
checkVersionFreshness
(
flutterVersion
,
await
VersionFreshnessValidator
(
version:
flutterVersion
,
cache:
cache
,
clock:
_testClock
,
logger:
logger
,
localFrameworkCommitDate:
getChannelOutOfDateVersion
(),
latestFlutterCommitDate:
getChannelOutOfDateVersion
(),
);
)
.
run
()
;
_expectVersionMessage
(
''
,
logger
);
});
...
...
@@ -172,14 +172,14 @@ void main() {
);
cache
.
versionStamp
=
json
.
encode
(
stamp
);
await
checkVersionFreshness
(
flutterVersion
,
await
VersionFreshnessValidator
(
version:
flutterVersion
,
cache:
cache
,
clock:
_testClock
,
logger:
logger
,
localFrameworkCommitDate:
getChannelOutOfDateVersion
(),
latestFlutterCommitDate:
getChannelUpToDateVersion
(),
);
)
.
run
()
;
_expectVersionMessage
(
newVersionAvailableMessage
(),
logger
);
expect
(
cache
.
setVersionStamp
,
true
);
...
...
@@ -195,14 +195,14 @@ void main() {
);
cache
.
versionStamp
=
json
.
encode
(
stamp
);
await
checkVersionFreshness
(
flutterVersion
,
await
VersionFreshnessValidator
(
version:
flutterVersion
,
cache:
cache
,
clock:
_testClock
,
logger:
logger
,
localFrameworkCommitDate:
getChannelOutOfDateVersion
(),
latestFlutterCommitDate:
getChannelUpToDateVersion
(),
);
)
.
run
()
;
_expectVersionMessage
(
''
,
logger
);
});
...
...
@@ -212,14 +212,14 @@ void main() {
final
BufferLogger
logger
=
BufferLogger
.
test
();
cache
.
versionStamp
=
'{}'
;
await
checkVersionFreshness
(
flutterVersion
,
await
VersionFreshnessValidator
(
version:
flutterVersion
,
cache:
cache
,
clock:
_testClock
,
logger:
logger
,
localFrameworkCommitDate:
getChannelOutOfDateVersion
(),
latestFlutterCommitDate:
getChannelUpToDateVersion
(),
);
)
.
run
()
;
_expectVersionMessage
(
newVersionAvailableMessage
(),
logger
);
expect
(
cache
.
setVersionStamp
,
true
);
...
...
@@ -234,14 +234,14 @@ void main() {
);
cache
.
versionStamp
=
json
.
encode
(
stamp
);
await
checkVersionFreshness
(
flutterVersion
,
await
VersionFreshnessValidator
(
version:
flutterVersion
,
cache:
cache
,
clock:
_testClock
,
logger:
logger
,
localFrameworkCommitDate:
getChannelOutOfDateVersion
(),
latestFlutterCommitDate:
getChannelUpToDateVersion
(),
);
)
.
run
()
;
_expectVersionMessage
(
newVersionAvailableMessage
(),
logger
);
});
...
...
@@ -251,14 +251,14 @@ void main() {
final
BufferLogger
logger
=
BufferLogger
.
test
();
cache
.
versionStamp
=
'{}'
;
await
checkVersionFreshness
(
flutterVersion
,
await
VersionFreshnessValidator
(
version:
flutterVersion
,
cache:
cache
,
clock:
_testClock
,
logger:
logger
,
localFrameworkCommitDate:
getChannelUpToDateVersion
(),
latestFlutterCommitDate:
null
,
// F
ailed to get remote version
);
// latestFlutterCommitDate defaults to null because we f
ailed to get remote version
)
.
run
()
;
_expectVersionMessage
(
''
,
logger
);
});
...
...
@@ -272,14 +272,14 @@ void main() {
);
cache
.
versionStamp
=
json
.
encode
(
stamp
);
await
checkVersionFreshness
(
flutterVersion
,
await
VersionFreshnessValidator
(
version:
flutterVersion
,
cache:
cache
,
clock:
_testClock
,
logger:
logger
,
localFrameworkCommitDate:
getChannelOutOfDateVersion
(),
latestFlutterCommitDate:
null
,
// F
ailed to get remote version
);
// latestFlutterCommitDate defaults to null because we f
ailed to get remote version
)
.
run
()
;
_expectVersionMessage
(
versionOutOfDateMessage
(
_testClock
.
now
().
difference
(
getChannelOutOfDateVersion
())),
logger
);
});
...
...
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