Add FlutterVersion.engineCommitDate, helps signal engine artifact SHA issues (#163652)
Closes #163644. Before this change: ```sh flutter-dev --version Flutter 3.30.0-1.0.pre.215 • channel [user-branch] • https://github.com/matanlurey/flutter Framework • revision cead517e4e (79 seconds ago) • 2025-02-19 13:00:11 -0800 Engine • revision39b4951f8fTools • Dart 3.8.0 (build 3.8.0-92.0.dev) • DevTools 2.43.0 ``` After this change: ```sh flutter-dev --version Flutter 3.30.0-1.0.pre.215 • channel [user-branch] • https://github.com/matanlurey/flutter Framework • revision cead517e4e (79 seconds ago) • 2025-02-19 13:00:11 -0800 Engine • revision39b4951f8f(79 seconds ago) • 2025-02-18 13:42:53 -0800 Tools • Dart 3.8.0 (build 3.8.0-92.0.dev) • DevTools 2.43.0 ``` /cc @jtmcdole as this could be helpful for sleuthing artifact mismatch.
This commit is contained in:
@@ -168,6 +168,33 @@ void main() {
|
||||
],
|
||||
stdout: getChannelUpToDateVersion().toString(),
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'-c',
|
||||
'log.showSignature=false',
|
||||
'log',
|
||||
'-n',
|
||||
'1',
|
||||
'--pretty=format:%ar',
|
||||
'abcdefg',
|
||||
],
|
||||
stdout: '2 seconds ago',
|
||||
),
|
||||
FakeCommand(
|
||||
command: const <String>[
|
||||
'git',
|
||||
'-c',
|
||||
'log.showSignature=false',
|
||||
'log',
|
||||
'abcdefg',
|
||||
'-n',
|
||||
'1',
|
||||
'--pretty=format:%ad',
|
||||
'--date=iso',
|
||||
],
|
||||
stdout: getChannelUpToDateVersion().toString(),
|
||||
),
|
||||
]);
|
||||
|
||||
final FlutterVersion flutterVersion = FlutterVersion(
|
||||
@@ -185,7 +212,7 @@ void main() {
|
||||
flutterVersion.toString(),
|
||||
'Flutter • channel $channel • $flutterUpstreamUrl\n'
|
||||
'Framework • revision 1234abcd (1 second ago) • ${getChannelUpToDateVersion()}\n'
|
||||
'Engine • revision abcdefg\n'
|
||||
'Engine • revision abcdefg (2 seconds ago) • ${getChannelUpToDateVersion()}\n'
|
||||
'Tools • Dart 2.12.0 • DevTools 2.8.0',
|
||||
);
|
||||
expect(flutterVersion.frameworkAge, '1 second ago');
|
||||
@@ -689,6 +716,23 @@ void main() {
|
||||
.ago(VersionFreshnessValidator.versionAgeConsideredUpToDate('stable') ~/ 2)
|
||||
.toString(),
|
||||
),
|
||||
FakeCommand(
|
||||
command: const <String>[
|
||||
'git',
|
||||
'-c',
|
||||
'log.showSignature=false',
|
||||
'log',
|
||||
'abcdefg',
|
||||
'-n',
|
||||
'1',
|
||||
'--pretty=format:%ad',
|
||||
'--date=iso',
|
||||
],
|
||||
stdout:
|
||||
_testClock
|
||||
.ago(VersionFreshnessValidator.versionAgeConsideredUpToDate('stable') ~/ 2)
|
||||
.toString(),
|
||||
),
|
||||
]);
|
||||
|
||||
final MemoryFileSystem fs = MemoryFileSystem.test();
|
||||
@@ -713,6 +757,7 @@ void main() {
|
||||
"frameworkRevision": "1234abcd",
|
||||
"frameworkCommitDate": "2014-10-02 00:00:00.000Z",
|
||||
"engineRevision": "abcdefg",
|
||||
"engineCommitDate": "2014-10-02 00:00:00.000Z",
|
||||
"dartSdkVersion": "2.12.0",
|
||||
"devToolsVersion": "2.8.0",
|
||||
"flutterVersion": "0.0.0-unknown"
|
||||
@@ -793,6 +838,67 @@ void main() {
|
||||
overrides: <Type, Generator>{ProcessManager: () => processManager, Cache: () => cache},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'_FlutterVersionFromFile ignores engineCommitDate if historically omitted',
|
||||
() async {
|
||||
final MemoryFileSystem fs = MemoryFileSystem.test();
|
||||
final Directory flutterRoot = fs.directory('/path/to/flutter');
|
||||
final Directory cacheDir = flutterRoot.childDirectory('bin').childDirectory('cache')
|
||||
..createSync(recursive: true);
|
||||
|
||||
const Map<String, Object> versionJson = <String, Object>{
|
||||
'channel': 'stable',
|
||||
'frameworkVersion': '1.2.3',
|
||||
'repositoryUrl': 'https://github.com/flutter/flutter.git',
|
||||
'frameworkRevision': '1234abcd',
|
||||
'frameworkCommitDate': '2023-04-28 12:34:56 -0400',
|
||||
'engineRevision': 'deadbeef',
|
||||
'dartSdkVersion': 'deadbeef2',
|
||||
'devToolsVersion': '0000000',
|
||||
'flutterVersion': 'foo',
|
||||
};
|
||||
cacheDir.childFile('flutter.version.json').writeAsStringSync(jsonEncode(versionJson));
|
||||
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'-c',
|
||||
'log.showSignature=false',
|
||||
'log',
|
||||
'-n',
|
||||
'1',
|
||||
'--pretty=format:%ar',
|
||||
],
|
||||
stdout: '1 second ago',
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
'git',
|
||||
'-c',
|
||||
'log.showSignature=false',
|
||||
'log',
|
||||
'-n',
|
||||
'1',
|
||||
'--pretty=format:%ar',
|
||||
'deadbeef',
|
||||
],
|
||||
stdout: '1 second ago',
|
||||
),
|
||||
]);
|
||||
|
||||
final FlutterVersion flutterVersion = FlutterVersion(
|
||||
clock: _testClock,
|
||||
fs: fs,
|
||||
flutterRoot: flutterRoot.path,
|
||||
);
|
||||
expect(flutterVersion.engineCommitDate, isNull);
|
||||
expect(flutterVersion.toJson(), isNot(contains('engineCommitDate')));
|
||||
expect(flutterVersion.toString(), contains('Engine • revision deadbeef (1 second ago)\n'));
|
||||
},
|
||||
overrides: <Type, Generator>{ProcessManager: () => processManager, Cache: () => cache},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'FlutterVersion() falls back to git if .version.json is malformed',
|
||||
() async {
|
||||
@@ -846,6 +952,23 @@ void main() {
|
||||
.ago(VersionFreshnessValidator.versionAgeConsideredUpToDate('stable') ~/ 2)
|
||||
.toString(),
|
||||
),
|
||||
FakeCommand(
|
||||
command: const <String>[
|
||||
'git',
|
||||
'-c',
|
||||
'log.showSignature=false',
|
||||
'log',
|
||||
'abcdefg',
|
||||
'-n',
|
||||
'1',
|
||||
'--pretty=format:%ad',
|
||||
'--date=iso',
|
||||
],
|
||||
stdout:
|
||||
_testClock
|
||||
.ago(VersionFreshnessValidator.versionAgeConsideredUpToDate('stable') ~/ 2)
|
||||
.toString(),
|
||||
),
|
||||
]);
|
||||
|
||||
// version file exists in a malformed state
|
||||
|
||||
@@ -366,6 +366,8 @@ class FakeFlutterVersion implements FlutterVersion {
|
||||
this.devToolsVersion = '2.8.0',
|
||||
this.engineRevision = 'abcdefghijklmnopqrstuvwxyz',
|
||||
this.engineRevisionShort = 'abcde',
|
||||
this.engineAge = '0 hours ago',
|
||||
this.engineCommitDate = '12/01/01',
|
||||
this.repositoryUrl = 'https://github.com/flutter/flutter.git',
|
||||
this.frameworkVersion = '0.0.0',
|
||||
this.frameworkRevision = '11111111111111111111',
|
||||
@@ -417,6 +419,12 @@ class FakeFlutterVersion implements FlutterVersion {
|
||||
@override
|
||||
final String engineRevisionShort;
|
||||
|
||||
@override
|
||||
final String? engineCommitDate;
|
||||
|
||||
@override
|
||||
final String engineAge;
|
||||
|
||||
@override
|
||||
final String? repositoryUrl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user