[flutter_conductor] Re-land auto-apply dart revision (#82985)
This commit is contained in:
committed by
GitHub
parent
0902576aba
commit
660ec207e6
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:dev_tools/repository.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
|
||||
@@ -12,9 +13,20 @@ import './common.dart';
|
||||
|
||||
void main() {
|
||||
group('repository', () {
|
||||
late FakePlatform platform;
|
||||
const String rootDir = '/';
|
||||
|
||||
setUp(() {
|
||||
final String pathSeparator = const LocalPlatform().pathSeparator;
|
||||
platform = FakePlatform(
|
||||
environment: <String, String>{
|
||||
'HOME': <String>['path', 'to', 'home'].join(pathSeparator),
|
||||
},
|
||||
pathSeparator: pathSeparator,
|
||||
);
|
||||
});
|
||||
|
||||
test('canCherryPick returns true if git cherry-pick returns 0', () {
|
||||
const LocalPlatform platform = LocalPlatform();
|
||||
const String rootDir = '/';
|
||||
const String commit = 'abc123';
|
||||
|
||||
final TestStdio stdio = TestStdio();
|
||||
@@ -66,8 +78,6 @@ void main() {
|
||||
});
|
||||
|
||||
test('canCherryPick returns false if git cherry-pick returns non-zero', () {
|
||||
const LocalPlatform platform = LocalPlatform();
|
||||
const String rootDir = '/';
|
||||
const String commit = 'abc123';
|
||||
|
||||
final TestStdio stdio = TestStdio();
|
||||
@@ -123,8 +133,6 @@ void main() {
|
||||
});
|
||||
|
||||
test('cherryPick() applies the commit', () {
|
||||
const LocalPlatform platform = LocalPlatform();
|
||||
const String rootDir = '/';
|
||||
const String commit = 'abc123';
|
||||
|
||||
final TestStdio stdio = TestStdio();
|
||||
@@ -168,5 +176,122 @@ void main() {
|
||||
repository.cherryPick(commit);
|
||||
expect(processManager.hasRemainingExpectations, false);
|
||||
});
|
||||
|
||||
test('updateDartRevision() updates the DEPS file', () {
|
||||
const String previousDartRevision = '171876a4e6cf56ee6da1f97d203926bd7afda7ef';
|
||||
const String nextDartRevision = 'f6c91128be6b77aef8351e1e3a9d07c85bc2e46e';
|
||||
final TestStdio stdio = TestStdio();
|
||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||
final FakeProcessManager processManager = FakeProcessManager.empty();
|
||||
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(rootDir),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
|
||||
final EngineRepository repo = EngineRepository(checkouts);
|
||||
final File depsFile = fileSystem.file('/DEPS');
|
||||
depsFile.writeAsStringSync(generateMockDeps(previousDartRevision));
|
||||
repo.updateDartRevision(nextDartRevision, depsFile: depsFile);
|
||||
final String updatedDepsFileContent = depsFile.readAsStringSync();
|
||||
expect(updatedDepsFileContent, generateMockDeps(nextDartRevision));
|
||||
});
|
||||
|
||||
test('updateDartRevision() throws exception on malformed DEPS file', () {
|
||||
const String nextDartRevision = 'f6c91128be6b77aef8351e1e3a9d07c85bc2e46e';
|
||||
final TestStdio stdio = TestStdio();
|
||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||
final FakeProcessManager processManager = FakeProcessManager.empty();
|
||||
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(rootDir),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
|
||||
final EngineRepository repo = EngineRepository(checkouts);
|
||||
final File depsFile = fileSystem.file('/DEPS');
|
||||
depsFile.writeAsStringSync('''
|
||||
vars = {
|
||||
}''');
|
||||
expect(
|
||||
() => repo.updateDartRevision(nextDartRevision, depsFile: depsFile),
|
||||
throwsExceptionWith('Unexpected content in the DEPS file at'),
|
||||
);
|
||||
});
|
||||
|
||||
test('commit() passes correct commit message', () {
|
||||
const String commit1 = 'abc123';
|
||||
const String commit2 = 'def456';
|
||||
const String message = 'This is a commit message.';
|
||||
final TestStdio stdio = TestStdio();
|
||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
EngineRepository.defaultUpstream,
|
||||
fileSystem.path
|
||||
.join(rootDir, 'flutter_conductor_checkouts', 'engine'),
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'checkout',
|
||||
'upstream/master',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: commit1),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'commit',
|
||||
"--message='$message'",
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: commit2),
|
||||
]);
|
||||
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(rootDir),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
|
||||
final EngineRepository repo = EngineRepository(checkouts);
|
||||
repo.commit(message);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
String generateMockDeps(String dartRevision) {
|
||||
return '''
|
||||
vars = {
|
||||
'chromium_git': 'https://chromium.googlesource.com',
|
||||
'swiftshader_git': 'https://swiftshader.googlesource.com',
|
||||
'dart_git': 'https://dart.googlesource.com',
|
||||
'flutter_git': 'https://flutter.googlesource.com',
|
||||
'fuchsia_git': 'https://fuchsia.googlesource.com',
|
||||
'github_git': 'https://github.com',
|
||||
'skia_git': 'https://skia.googlesource.com',
|
||||
'ocmock_git': 'https://github.com/erikdoe/ocmock.git',
|
||||
'skia_revision': '4e9d5e2bdf04c58bc0bff57be7171e469e5d7175',
|
||||
|
||||
'dart_revision': '$dartRevision',
|
||||
'dart_boringssl_gen_rev': '7322fc15cc065d8d2957fccce6b62a509dc4d641',
|
||||
}''';
|
||||
}
|
||||
|
||||
@@ -120,6 +120,14 @@ void main() {
|
||||
test('creates state file if provided correct inputs', () async {
|
||||
const String revision2 = 'def789';
|
||||
const String revision3 = '123abc';
|
||||
const String previousDartRevision = '171876a4e6cf56ee6da1f97d203926bd7afda7ef';
|
||||
const String nextDartRevision = 'f6c91128be6b77aef8351e1e3a9d07c85bc2e46e';
|
||||
|
||||
final Directory engine = fileSystem.directory(checkoutsParentDirectory)
|
||||
.childDirectory('flutter_conductor_checkouts')
|
||||
.childDirectory('engine');
|
||||
|
||||
final File depsFile = engine.childFile('DEPS');
|
||||
|
||||
final List<FakeCommand> engineCommands = <FakeCommand>[
|
||||
FakeCommand(
|
||||
@@ -130,12 +138,13 @@ void main() {
|
||||
'upstream',
|
||||
'--',
|
||||
EngineRepository.defaultUpstream,
|
||||
fileSystem.path.join(
|
||||
checkoutsParentDirectory,
|
||||
'flutter_conductor_checkouts',
|
||||
'engine',
|
||||
),
|
||||
engine.path,
|
||||
],
|
||||
onRun: () {
|
||||
// Create the DEPS file which the tool will update
|
||||
engine.createSync(recursive: true);
|
||||
depsFile.writeAsStringSync(generateMockDeps(previousDartRevision));
|
||||
}
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'remote', 'add', 'mirror', engineMirror],
|
||||
@@ -158,6 +167,16 @@ void main() {
|
||||
'cherrypicks-$candidateBranch',
|
||||
],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'add', '--all'],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'commit', "--message='Update Dart SDK to $nextDartRevision'"],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'rev-parse', 'HEAD'],
|
||||
stdout: revision2,
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'rev-parse', 'HEAD'],
|
||||
stdout: revision2,
|
||||
@@ -233,6 +252,8 @@ void main() {
|
||||
releaseChannel,
|
||||
'--$kStateOption',
|
||||
stateFilePath,
|
||||
'--$kDartRevisionOption',
|
||||
nextDartRevision,
|
||||
]);
|
||||
|
||||
final File stateFile = fileSystem.file(stateFilePath);
|
||||
@@ -246,6 +267,7 @@ void main() {
|
||||
expect(state.releaseChannel, releaseChannel);
|
||||
expect(state.engine.candidateBranch, candidateBranch);
|
||||
expect(state.engine.startingGitHead, revision2);
|
||||
expect(state.engine.dartRevision, nextDartRevision);
|
||||
expect(state.framework.candidateBranch, candidateBranch);
|
||||
expect(state.framework.startingGitHead, revision3);
|
||||
expect(state.lastPhase, ReleasePhase.INITIALIZE);
|
||||
@@ -255,3 +277,21 @@ void main() {
|
||||
'windows': const Skip('Flutter Conductor only supported on macos/linux'),
|
||||
});
|
||||
}
|
||||
|
||||
String generateMockDeps(String dartRevision) {
|
||||
return '''
|
||||
vars = {
|
||||
'chromium_git': 'https://chromium.googlesource.com',
|
||||
'swiftshader_git': 'https://swiftshader.googlesource.com',
|
||||
'dart_git': 'https://dart.googlesource.com',
|
||||
'flutter_git': 'https://flutter.googlesource.com',
|
||||
'fuchsia_git': 'https://fuchsia.googlesource.com',
|
||||
'github_git': 'https://github.com',
|
||||
'skia_git': 'https://skia.googlesource.com',
|
||||
'ocmock_git': 'https://github.com/erikdoe/ocmock.git',
|
||||
'skia_revision': '4e9d5e2bdf04c58bc0bff57be7171e469e5d7175',
|
||||
|
||||
'dart_revision': '$dartRevision',
|
||||
'dart_boringssl_gen_rev': '7322fc15cc065d8d2957fccce6b62a509dc4d641',
|
||||
}''';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user