Unverified Commit 711f9b7c authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

[flutter_conductor] migrate conductor to null-safety (#86117)

parent 5456cad3
......@@ -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
// See: https://github.com/flutter/flutter/wiki/Release-process
import 'dart:io' as io;
......
......@@ -2,11 +2,9 @@
// 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/args.dart';
import 'package:args/command_runner.dart';
import 'package:file/file.dart';
import 'package:meta/meta.dart';
import 'package:platform/platform.dart';
import './globals.dart';
......@@ -22,7 +20,7 @@ const String kStateOption = 'state-file';
/// If the release was not completed, this command will abort the release.
class CleanCommand extends Command<void> {
CleanCommand({
@required this.checkouts,
required this.checkouts,
}) : platform = checkouts.platform,
fileSystem = checkouts.fileSystem,
stdio = checkouts.stdio {
......@@ -52,13 +50,14 @@ class CleanCommand extends Command<void> {
@override
void run() {
final File stateFile = checkouts.fileSystem.file(argResults[kStateOption]);
final ArgResults argumentResults = argResults!;
final File stateFile = checkouts.fileSystem.file(argumentResults[kStateOption]);
if (!stateFile.existsSync()) {
throw ConductorException(
'No persistent state file found at ${stateFile.path}!');
}
if (!(argResults[kYesFlag] as bool)) {
if (!(argumentResults[kYesFlag] as bool)) {
stdio.printStatus(
'Are you sure you want to clean up the persistent state file at\n'
'${stateFile.path} (y/n)?',
......
......@@ -2,11 +2,9 @@
// 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:file/file.dart' show File;
import 'package:meta/meta.dart' show required, visibleForTesting;
import 'package:meta/meta.dart' show visibleForTesting;
import './globals.dart';
import './proto/conductor_state.pb.dart' as pb;
import './proto/conductor_state.pbenum.dart';
......@@ -21,7 +19,7 @@ const String kForceFlag = 'force';
/// Command to proceed from one [pb.ReleasePhase] to the next.
class NextCommand extends Command<void> {
NextCommand({
@required this.checkouts,
required this.checkouts,
}) {
final String defaultPath = defaultStateFilePath(checkouts.platform);
argParser.addOption(
......@@ -51,10 +49,10 @@ class NextCommand extends Command<void> {
@override
void run() {
runNext(
autoAccept: argResults[kYesFlag] as bool,
autoAccept: argResults![kYesFlag] as bool,
checkouts: checkouts,
force: argResults[kForceFlag] as bool,
stateFile: checkouts.fileSystem.file(argResults[kStateOption]),
force: argResults![kForceFlag] as bool,
stateFile: checkouts.fileSystem.file(argResults![kStateOption]),
);
}
}
......@@ -77,10 +75,10 @@ bool prompt(String message, Stdio stdio) {
@visibleForTesting
void runNext({
@required bool autoAccept,
@required bool force,
@required Checkouts checkouts,
@required File stateFile,
required bool autoAccept,
required bool force,
required Checkouts checkouts,
required File stateFile,
}) {
final Stdio stdio = checkouts.stdio;
const List<CherrypickState> finishedStates = <CherrypickState>[
......@@ -341,7 +339,6 @@ void runNext({
break;
case pb.ReleasePhase.RELEASE_COMPLETED:
throw ConductorException('This release is finished.');
break;
}
final ReleasePhase nextPhase = getNextPhase(state.currentPhase);
stdio.printStatus('\nUpdating phase from ${state.currentPhase} to $nextPhase...\n');
......
......@@ -22,8 +22,8 @@ if ! type dart >/dev/null 2>&1; then
exit 1
fi
# Pin protoc-gen-dart to pre-nullsafe version.
dart pub global activate protoc_plugin 19.3.1
# Use null-safe protoc_plugin
dart pub global activate protoc_plugin 20.0.0
protoc --dart_out="$DIR" --proto_path="$DIR" "$DIR/conductor_state.proto"
......
......@@ -6,7 +6,7 @@
// Generated code. Do not modify.
// source: conductor_state.proto
//
// @dart = 2.7
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
......@@ -30,8 +30,8 @@ class Remote extends $pb.GeneratedMessage {
Remote._() : super();
factory Remote({
$core.String name,
$core.String url,
$core.String? name,
$core.String? url,
}) {
final _result = create();
if (name != null) {
......@@ -62,7 +62,7 @@ class Remote extends $pb.GeneratedMessage {
static $pb.PbList<Remote> createRepeated() => $pb.PbList<Remote>();
@$core.pragma('dart2js:noInline')
static Remote getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Remote>(create);
static Remote _defaultInstance;
static Remote? _defaultInstance;
@$pb.TagNumber(1)
$core.String get name => $_getSZ(0);
......@@ -106,9 +106,9 @@ class Cherrypick extends $pb.GeneratedMessage {
Cherrypick._() : super();
factory Cherrypick({
$core.String trunkRevision,
$core.String appliedRevision,
CherrypickState state,
$core.String? trunkRevision,
$core.String? appliedRevision,
CherrypickState? state,
}) {
final _result = create();
if (trunkRevision != null) {
......@@ -142,7 +142,7 @@ class Cherrypick extends $pb.GeneratedMessage {
static $pb.PbList<Cherrypick> createRepeated() => $pb.PbList<Cherrypick>();
@$core.pragma('dart2js:noInline')
static Cherrypick getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Cherrypick>(create);
static Cherrypick _defaultInstance;
static Cherrypick? _defaultInstance;
@$pb.TagNumber(1)
$core.String get trunkRevision => $_getSZ(0);
......@@ -210,15 +210,15 @@ class Repository extends $pb.GeneratedMessage {
Repository._() : super();
factory Repository({
$core.String candidateBranch,
$core.String startingGitHead,
$core.String currentGitHead,
$core.String checkoutPath,
Remote upstream,
Remote mirror,
$core.Iterable<Cherrypick> cherrypicks,
$core.String dartRevision,
$core.String workingBranch,
$core.String? candidateBranch,
$core.String? startingGitHead,
$core.String? currentGitHead,
$core.String? checkoutPath,
Remote? upstream,
Remote? mirror,
$core.Iterable<Cherrypick>? cherrypicks,
$core.String? dartRevision,
$core.String? workingBranch,
}) {
final _result = create();
if (candidateBranch != null) {
......@@ -270,7 +270,7 @@ class Repository extends $pb.GeneratedMessage {
static $pb.PbList<Repository> createRepeated() => $pb.PbList<Repository>();
@$core.pragma('dart2js:noInline')
static Repository getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Repository>(create);
static Repository _defaultInstance;
static Repository? _defaultInstance;
@$pb.TagNumber(1)
$core.String get candidateBranch => $_getSZ(0);
......@@ -407,15 +407,15 @@ class ConductorState extends $pb.GeneratedMessage {
ConductorState._() : super();
factory ConductorState({
$core.String releaseChannel,
$core.String releaseVersion,
Repository engine,
Repository framework,
$fixnum.Int64 createdDate,
$fixnum.Int64 lastUpdatedDate,
$core.Iterable<$core.String> logs,
ReleasePhase currentPhase,
$core.String conductorVersion,
$core.String? releaseChannel,
$core.String? releaseVersion,
Repository? engine,
Repository? framework,
$fixnum.Int64? createdDate,
$fixnum.Int64? lastUpdatedDate,
$core.Iterable<$core.String>? logs,
ReleasePhase? currentPhase,
$core.String? conductorVersion,
}) {
final _result = create();
if (releaseChannel != null) {
......@@ -468,7 +468,7 @@ class ConductorState extends $pb.GeneratedMessage {
static $pb.PbList<ConductorState> createRepeated() => $pb.PbList<ConductorState>();
@$core.pragma('dart2js:noInline')
static ConductorState getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<ConductorState>(create);
static ConductorState _defaultInstance;
static ConductorState? _defaultInstance;
@$pb.TagNumber(1)
$core.String get releaseChannel => $_getSZ(0);
......
......@@ -6,7 +6,7 @@
// Generated code. Do not modify.
// source: conductor_state.proto
//
// @dart = 2.7
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
// ignore_for_file: UNDEFINED_SHOWN_NAME
......@@ -40,7 +40,7 @@ class ReleasePhase extends $pb.ProtobufEnum {
];
static final $core.Map<$core.int, ReleasePhase> _byValue = $pb.ProtobufEnum.initByValue(values);
static ReleasePhase valueOf($core.int value) => _byValue[value];
static ReleasePhase? valueOf($core.int value) => _byValue[value];
const ReleasePhase._($core.int v, $core.String n) : super(v, n);
}
......@@ -63,7 +63,7 @@ class CherrypickState extends $pb.ProtobufEnum {
];
static final $core.Map<$core.int, CherrypickState> _byValue = $pb.ProtobufEnum.initByValue(values);
static CherrypickState valueOf($core.int value) => _byValue[value];
static CherrypickState? valueOf($core.int value) => _byValue[value];
const CherrypickState._($core.int v, $core.String n) : super(v, n);
}
......@@ -6,7 +6,7 @@
// Generated code. Do not modify.
// source: conductor_state.proto
//
// @dart = 2.7
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
import 'dart:core' as $core;
......
......@@ -6,7 +6,7 @@
// Generated code. Do not modify.
// source: conductor_state.proto
//
// @dart = 2.7
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
export 'conductor_state.pb.dart';
......@@ -111,7 +111,7 @@ bool rollDev({
required FrameworkRepository repository,
}) {
final String remoteName = argResults[kRemoteName] as String;
final String level = argResults[kIncrement] as String;
final String? level = argResults[kIncrement] as String?;
final String candidateBranch = argResults[kCandidateBranch] as String;
final bool justPrint = argResults[kJustPrint] as bool;
final bool autoApprove = argResults[kYes] as bool;
......
......@@ -2,12 +2,10 @@
// 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/args.dart';
import 'package:args/command_runner.dart';
import 'package:file/file.dart';
import 'package:fixnum/fixnum.dart';
import 'package:meta/meta.dart';
import 'package:platform/platform.dart';
import 'package:process/process.dart';
......@@ -35,8 +33,8 @@ const String kStateOption = 'state-file';
/// Command to print the status of the current Flutter release.
class StartCommand extends Command<void> {
StartCommand({
@required this.checkouts,
@required this.flutterRoot,
required this.checkouts,
required this.flutterRoot,
}) : platform = checkouts.platform,
processManager = checkouts.processManager,
fileSystem = checkouts.fileSystem,
......@@ -125,7 +123,7 @@ class StartCommand extends Command<void> {
final Stdio stdio;
/// Git revision for the currently running Conductor.
String conductorVersion;
late final String conductorVersion;
@override
String get name => 'start';
......@@ -135,6 +133,7 @@ class StartCommand extends Command<void> {
@override
void run() {
final ArgResults argumentResults = argResults!;
if (!platform.isMacOS && !platform.isLinux) {
throw ConductorException(
'Error! This tool is only supported on macOS and Linux',
......@@ -142,64 +141,64 @@ class StartCommand extends Command<void> {
}
final File stateFile = checkouts.fileSystem.file(
getValueFromEnvOrArgs(kStateOption, argResults, platform.environment),
getValueFromEnvOrArgs(kStateOption, argumentResults, platform.environment),
);
if (stateFile.existsSync()) {
throw ConductorException(
'Error! A persistent state file already found at ${argResults[kStateOption]}.\n\n'
'Error! A persistent state file already found at ${argResults![kStateOption]}.\n\n'
'Run `conductor clean` to cancel a previous release.');
}
final String frameworkUpstream = getValueFromEnvOrArgs(
kFrameworkUpstreamOption,
argResults,
argumentResults,
platform.environment,
);
)!;
final String frameworkMirror = getValueFromEnvOrArgs(
kFrameworkMirrorOption,
argResults,
argumentResults,
platform.environment,
);
)!;
final String engineUpstream = getValueFromEnvOrArgs(
kEngineUpstreamOption,
argResults,
argumentResults,
platform.environment,
);
)!;
final String engineMirror = getValueFromEnvOrArgs(
kEngineMirrorOption,
argResults,
argumentResults,
platform.environment,
);
)!;
final String candidateBranch = getValueFromEnvOrArgs(
kCandidateOption,
argResults,
argumentResults,
platform.environment,
);
)!;
final String releaseChannel = getValueFromEnvOrArgs(
kReleaseOption,
argResults,
argumentResults,
platform.environment,
);
)!;
final List<String> frameworkCherrypickRevisions = getValuesFromEnvOrArgs(
kFrameworkCherrypicksOption,
argResults,
argumentResults,
platform.environment,
);
final List<String> engineCherrypickRevisions = getValuesFromEnvOrArgs(
kEngineCherrypicksOption,
argResults,
argumentResults,
platform.environment,
);
final String dartRevision = getValueFromEnvOrArgs(
final String? dartRevision = getValueFromEnvOrArgs(
kDartRevisionOption,
argResults,
argumentResults,
platform.environment,
allowNull: true,
);
final String incrementLetter = getValueFromEnvOrArgs(
kIncrementOption,
argResults,
argumentResults,
platform.environment,
);
)!;
if (!releaseCandidateBranchRegex.hasMatch(candidateBranch)) {
throw ConductorException(
......@@ -270,7 +269,7 @@ class StartCommand extends Command<void> {
cherrypicks: engineCherrypicks,
dartRevision: dartRevision,
upstream: pb.Remote(name: 'upstream', url: engine.upstreamRemote.url),
mirror: pb.Remote(name: 'mirror', url: engine.mirrorRemote.url),
mirror: pb.Remote(name: 'mirror', url: engine.mirrorRemote!.url),
);
final FrameworkRepository framework = FrameworkRepository(
checkouts,
......@@ -328,7 +327,7 @@ class StartCommand extends Command<void> {
checkoutPath: framework.checkoutDirectory.path,
cherrypicks: frameworkCherrypicks,
upstream: pb.Remote(name: 'upstream', url: framework.upstreamRemote.url),
mirror: pb.Remote(name: 'mirror', url: framework.mirrorRemote.url),
mirror: pb.Remote(name: 'mirror', url: framework.mirrorRemote!.url),
);
state.currentPhase = ReleasePhase.APPLY_ENGINE_CHERRYPICKS;
......@@ -344,10 +343,10 @@ class StartCommand extends Command<void> {
// To minimize merge conflicts, sort the commits by rev-list order.
List<String> _sortCherrypicks({
@required Repository repository,
@required List<String> cherrypicks,
@required String upstreamRef,
@required String releaseRef,
required Repository repository,
required List<String> cherrypicks,
required String upstreamRef,
required String releaseRef,
}) {
if (cherrypicks.isEmpty) {
return cherrypicks;
......
......@@ -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, jsonEncode;
import 'package:file/file.dart' show File;
......@@ -29,9 +27,12 @@ String luciConsoleLink(String channel, String groupName) {
}
String defaultStateFilePath(Platform platform) {
assert(platform.environment['HOME'] != null);
final String? home = platform.environment['HOME'];
if (home == null) {
throw ConductorException(r'Environment variable $HOME must be set!');
}
return <String>[
platform.environment['HOME'],
home,
kStateFileName,
].join(platform.pathSeparator);
}
......@@ -170,12 +171,13 @@ String phaseInstructions(pb.ConductorState state) {
///
/// Will throw a [ConductorException] if [ReleasePhase.RELEASE_COMPLETED] is
/// passed as an argument, as there is no next phase.
ReleasePhase getNextPhase(ReleasePhase previousPhase) {
assert(previousPhase != null);
if (previousPhase == ReleasePhase.RELEASE_COMPLETED) {
ReleasePhase getNextPhase(ReleasePhase currentPhase) {
assert(currentPhase != null);
final ReleasePhase? nextPhase = ReleasePhase.valueOf(currentPhase.value + 1);
if (nextPhase == null) {
throw ConductorException('There is no next ReleasePhase!');
}
return ReleasePhase.valueOf(previousPhase.value + 1);
return nextPhase;
}
void writeStateToFile(File file, pb.ConductorState state, List<String> logs) {
......
......@@ -2,11 +2,8 @@
// 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:file/file.dart';
import 'package:meta/meta.dart';
import 'package:platform/platform.dart';
import './proto/conductor_state.pb.dart' as pb;
......@@ -20,7 +17,7 @@ const String kStateOption = 'state-file';
/// Command to print the status of the current Flutter release.
class StatusCommand extends Command<void> {
StatusCommand({
@required this.checkouts,
required this.checkouts,
}) : platform = checkouts.platform,
fileSystem = checkouts.fileSystem,
stdio = checkouts.stdio {
......@@ -51,16 +48,16 @@ class StatusCommand extends Command<void> {
@override
void run() {
final File stateFile = checkouts.fileSystem.file(argResults[kStateOption]);
final File stateFile = checkouts.fileSystem.file(argResults![kStateOption]);
if (!stateFile.existsSync()) {
stdio.printStatus(
'No persistent state file found at ${argResults[kStateOption]}.');
'No persistent state file found at ${argResults![kStateOption]}.');
return;
}
final pb.ConductorState state = readStateFromFile(stateFile);
stdio.printStatus(presentState(state));
if (argResults[kVerboseFlag] as bool) {
if (argResults![kVerboseFlag] as bool) {
stdio.printStatus('\nLogs:');
state.logs.forEach(stdio.printStatus);
}
......
......@@ -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,
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment