[flutter_tools] fix bug where last build id parent folder is missing (#66156)
This commit is contained in:
@@ -668,6 +668,7 @@ class FlutterBuildSystem extends BuildSystem {
|
||||
final String currentBuildId = fileSystem.path.basename(environment.buildDir.path);
|
||||
final File lastBuildIdFile = environment.outputDir.childFile('.last_build_id');
|
||||
if (!lastBuildIdFile.existsSync()) {
|
||||
lastBuildIdFile.parent.createSync(recursive: true);
|
||||
lastBuildIdFile.writeAsStringSync(currentBuildId);
|
||||
// No config file, either output was cleaned or this is the first build.
|
||||
return;
|
||||
@@ -704,7 +705,6 @@ class FlutterBuildSystem extends BuildSystem {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// An active instance of a build.
|
||||
class _BuildInstance {
|
||||
_BuildInstance({
|
||||
|
||||
@@ -475,6 +475,26 @@ void main() {
|
||||
'6666cd76f96956469e7be39d750cc7d9');
|
||||
});
|
||||
|
||||
testWithoutContext('trackSharedBuildDirectory handles a missing output dir', () {
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
outputDir: fileSystem.directory('a/b/c/d'),
|
||||
artifacts: MockArtifacts(),
|
||||
processManager: FakeProcessManager.any(),
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
);
|
||||
FlutterBuildSystem(
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
platform: FakePlatform(),
|
||||
).trackSharedBuildDirectory(environment, fileSystem, <String, File>{});
|
||||
|
||||
expect(environment.outputDir.childFile('.last_build_id'), exists);
|
||||
expect(environment.outputDir.childFile('.last_build_id').readAsStringSync(),
|
||||
'5954e2278dd01e1c4e747578776eeb94');
|
||||
});
|
||||
|
||||
testWithoutContext('trackSharedBuildDirectory does not modify .last_build_id when config is identical', () {
|
||||
environment.outputDir.childFile('.last_build_id')
|
||||
..writeAsStringSync('6666cd76f96956469e7be39d750cc7d9')
|
||||
|
||||
Reference in New Issue
Block a user