[flutter_conductor] migrate conductor to null-safety (#86117)
This commit is contained in:
committed by
GitHub
parent
5456cad343
commit
711f9b7c43
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:conductor/clean.dart';
|
||||
import 'package:conductor/repository.dart';
|
||||
@@ -19,32 +17,19 @@ void main() {
|
||||
const String flutterRoot = '/flutter';
|
||||
const String checkoutsParentDirectory = '$flutterRoot/dev/tools/';
|
||||
|
||||
MemoryFileSystem fileSystem;
|
||||
FakePlatform platform;
|
||||
TestStdio stdio;
|
||||
FakeProcessManager processManager;
|
||||
late MemoryFileSystem fileSystem;
|
||||
late FakePlatform platform;
|
||||
late TestStdio stdio;
|
||||
late FakeProcessManager processManager;
|
||||
late CommandRunner<void> runner;
|
||||
|
||||
setUp(() {
|
||||
stdio = TestStdio();
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
// Ensure these don't get re-used between tests
|
||||
stdio = null;
|
||||
fileSystem = null;
|
||||
processManager = null;
|
||||
platform = null;
|
||||
});
|
||||
|
||||
CommandRunner<void> createRunner({
|
||||
List<FakeCommand> commands,
|
||||
String operatingSystem,
|
||||
}) {
|
||||
operatingSystem ??= const LocalPlatform().operatingSystem;
|
||||
final String operatingSystem = const LocalPlatform().operatingSystem;
|
||||
final String pathSeparator = operatingSystem == 'windows' ? r'\' : '/';
|
||||
|
||||
processManager = FakeProcessManager.list(commands ?? <FakeCommand>[]);
|
||||
processManager = FakeProcessManager.empty();
|
||||
platform = FakePlatform(
|
||||
environment: <String, String>{'HOME': '/path/to/user/home'},
|
||||
pathSeparator: pathSeparator,
|
||||
@@ -59,11 +44,10 @@ void main() {
|
||||
final CleanCommand command = CleanCommand(
|
||||
checkouts: checkouts,
|
||||
);
|
||||
return CommandRunner<void>('clean-test', '')..addCommand(command);
|
||||
}
|
||||
runner = CommandRunner<void>('clean-test', '')..addCommand(command);
|
||||
});
|
||||
|
||||
test('throws if no state file found', () async {
|
||||
final CommandRunner<void> runner = createRunner();
|
||||
const String stateFile = '/state-file.json';
|
||||
|
||||
await expectLater(
|
||||
@@ -80,7 +64,6 @@ void main() {
|
||||
});
|
||||
|
||||
test('deletes state file', () async {
|
||||
final CommandRunner<void> runner = createRunner();
|
||||
final File stateFile = fileSystem.file('/state-file.json');
|
||||
stateFile.writeAsStringSync('{}');
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class TestStdio extends Stdio {
|
||||
|
||||
class FakeArgResults implements ArgResults {
|
||||
FakeArgResults({
|
||||
required String level,
|
||||
required String? level,
|
||||
required String candidateBranch,
|
||||
String remote = 'upstream',
|
||||
bool justPrint = false,
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:conductor/next.dart';
|
||||
import 'package:conductor/proto/conductor_state.pb.dart' as pb;
|
||||
@@ -12,7 +10,6 @@ import 'package:conductor/repository.dart';
|
||||
import 'package:conductor/state.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
|
||||
import './common.dart';
|
||||
@@ -31,8 +28,8 @@ void main() {
|
||||
const String revision3 = '789aaa';
|
||||
const String releaseVersion = '1.2.0-3.0.pre';
|
||||
const String releaseChannel = 'beta';
|
||||
MemoryFileSystem fileSystem;
|
||||
TestStdio stdio;
|
||||
late MemoryFileSystem fileSystem;
|
||||
late TestStdio stdio;
|
||||
const String stateFile = '/state-file.json';
|
||||
|
||||
setUp(() {
|
||||
@@ -41,7 +38,7 @@ void main() {
|
||||
});
|
||||
|
||||
CommandRunner<void> createRunner({
|
||||
@required Checkouts checkouts,
|
||||
required Checkouts checkouts,
|
||||
}) {
|
||||
final NextCommand command = NextCommand(
|
||||
checkouts: checkouts,
|
||||
@@ -239,9 +236,9 @@ void main() {
|
||||
});
|
||||
|
||||
group('CODESIGN_ENGINE_BINARIES to APPLY_FRAMEWORK_CHERRYPICKS', () {
|
||||
pb.ConductorState state;
|
||||
FakeProcessManager processManager;
|
||||
FakePlatform platform;
|
||||
late pb.ConductorState state;
|
||||
late FakeProcessManager processManager;
|
||||
late FakePlatform platform;
|
||||
|
||||
setUp(() {
|
||||
state = pb.ConductorState(
|
||||
@@ -341,9 +338,9 @@ void main() {
|
||||
const String frameworkCheckoutPath = '$checkoutsParentDirectory/framework';
|
||||
const String engineCheckoutPath = '$checkoutsParentDirectory/engine';
|
||||
const String oldEngineVersion = '000000001';
|
||||
FakeProcessManager processManager;
|
||||
FakePlatform platform;
|
||||
pb.ConductorState state;
|
||||
late FakeProcessManager processManager;
|
||||
late FakePlatform platform;
|
||||
late pb.ConductorState state;
|
||||
|
||||
setUp(() {
|
||||
processManager = FakeProcessManager.empty();
|
||||
@@ -640,8 +637,8 @@ void main() {
|
||||
group('PUBLISH_VERSION to PUBLISH_CHANNEL', () {
|
||||
const String remoteName = 'upstream';
|
||||
const String releaseVersion = '1.2.0-3.0.pre';
|
||||
pb.ConductorState state;
|
||||
FakePlatform platform;
|
||||
late pb.ConductorState state;
|
||||
late FakePlatform platform;
|
||||
|
||||
setUp(() {
|
||||
state = pb.ConductorState(
|
||||
@@ -766,8 +763,8 @@ void main() {
|
||||
|
||||
group('PUBLISH_CHANNEL to VERIFY_RELEASE', () {
|
||||
const String remoteName = 'upstream';
|
||||
pb.ConductorState state;
|
||||
FakePlatform platform;
|
||||
late pb.ConductorState state;
|
||||
late FakePlatform platform;
|
||||
|
||||
setUp(() {
|
||||
state = pb.ConductorState(
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:conductor/globals.dart';
|
||||
import 'package:conductor/repository.dart';
|
||||
import 'package:conductor/roll_dev.dart';
|
||||
@@ -23,13 +21,13 @@ void main() {
|
||||
const String nextVersion = '1.2.0-2.0.pre';
|
||||
const String candidateBranch = 'flutter-1.2-candidate.2';
|
||||
const String checkoutsParentDirectory = '/path/to/directory/';
|
||||
FakeArgResults fakeArgResults;
|
||||
MemoryFileSystem fileSystem;
|
||||
TestStdio stdio;
|
||||
FrameworkRepository repo;
|
||||
Checkouts checkouts;
|
||||
FakePlatform platform;
|
||||
FakeProcessManager processManager;
|
||||
late FakeArgResults fakeArgResults;
|
||||
late MemoryFileSystem fileSystem;
|
||||
late TestStdio stdio;
|
||||
late FrameworkRepository repo;
|
||||
late Checkouts checkouts;
|
||||
late FakePlatform platform;
|
||||
late FakeProcessManager processManager;
|
||||
|
||||
setUp(() {
|
||||
stdio = TestStdio();
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:convert' show jsonDecode;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
@@ -28,11 +26,11 @@ void main() {
|
||||
const String candidateBranch = 'flutter-1.2-candidate.3';
|
||||
const String releaseChannel = 'stable';
|
||||
const String revision = 'abcd1234';
|
||||
Checkouts checkouts;
|
||||
MemoryFileSystem fileSystem;
|
||||
FakePlatform platform;
|
||||
TestStdio stdio;
|
||||
FakeProcessManager processManager;
|
||||
late Checkouts checkouts;
|
||||
late MemoryFileSystem fileSystem;
|
||||
late FakePlatform platform;
|
||||
late TestStdio stdio;
|
||||
late FakeProcessManager processManager;
|
||||
|
||||
setUp(() {
|
||||
stdio = TestStdio();
|
||||
@@ -40,9 +38,9 @@ void main() {
|
||||
});
|
||||
|
||||
CommandRunner<void> createRunner({
|
||||
Map<String, String> environment,
|
||||
String operatingSystem,
|
||||
List<FakeCommand> commands,
|
||||
Map<String, String>? environment,
|
||||
String? operatingSystem,
|
||||
List<FakeCommand>? commands,
|
||||
}) {
|
||||
operatingSystem ??= const LocalPlatform().operatingSystem;
|
||||
final String pathSeparator = operatingSystem == 'windows' ? r'\' : '/';
|
||||
@@ -74,13 +72,6 @@ void main() {
|
||||
return CommandRunner<void>('codesign-test', '')..addCommand(command);
|
||||
}
|
||||
|
||||
tearDown(() {
|
||||
// Ensure we don't re-use these between tests.
|
||||
processManager = null;
|
||||
checkouts = null;
|
||||
platform = null;
|
||||
});
|
||||
|
||||
test('throws exception if run from Windows', () async {
|
||||
final CommandRunner<void> runner = createRunner(
|
||||
commands: <FakeCommand>[
|
||||
@@ -251,7 +242,7 @@ void main() {
|
||||
);
|
||||
|
||||
final String stateFilePath = fileSystem.path.join(
|
||||
platform.environment['HOME'],
|
||||
platform.environment['HOME']!,
|
||||
kStateFileName,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user