diff --git a/dev/conductor/bin/conductor.dart b/dev/conductor/bin/conductor.dart index 26243efe56..8513038c09 100644 --- a/dev/conductor/bin/conductor.dart +++ b/dev/conductor/bin/conductor.dart @@ -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; diff --git a/dev/conductor/lib/clean.dart b/dev/conductor/lib/clean.dart index 19075573b5..30324bc20d 100644 --- a/dev/conductor/lib/clean.dart +++ b/dev/conductor/lib/clean.dart @@ -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 { CleanCommand({ - @required this.checkouts, + required this.checkouts, }) : platform = checkouts.platform, fileSystem = checkouts.fileSystem, stdio = checkouts.stdio { @@ -52,13 +50,14 @@ class CleanCommand extends Command { @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)?', diff --git a/dev/conductor/lib/next.dart b/dev/conductor/lib/next.dart index 368b616111..cef5e89b67 100644 --- a/dev/conductor/lib/next.dart +++ b/dev/conductor/lib/next.dart @@ -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 { NextCommand({ - @required this.checkouts, + required this.checkouts, }) { final String defaultPath = defaultStateFilePath(checkouts.platform); argParser.addOption( @@ -51,10 +49,10 @@ class NextCommand extends Command { @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 finishedStates = [ @@ -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'); diff --git a/dev/conductor/lib/proto/compile_proto.sh b/dev/conductor/lib/proto/compile_proto.sh index b5e928d004..06cc5a145e 100755 --- a/dev/conductor/lib/proto/compile_proto.sh +++ b/dev/conductor/lib/proto/compile_proto.sh @@ -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" diff --git a/dev/conductor/lib/proto/conductor_state.pb.dart b/dev/conductor/lib/proto/conductor_state.pb.dart index 8df5f2659f..7da9b37e4c 100644 --- a/dev/conductor/lib/proto/conductor_state.pb.dart +++ b/dev/conductor/lib/proto/conductor_state.pb.dart @@ -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 createRepeated() => $pb.PbList(); @$core.pragma('dart2js:noInline') static Remote getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(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 createRepeated() => $pb.PbList(); @$core.pragma('dart2js:noInline') static Cherrypick getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(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 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? 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 createRepeated() => $pb.PbList(); @$core.pragma('dart2js:noInline') static Repository getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(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 createRepeated() => $pb.PbList(); @$core.pragma('dart2js:noInline') static ConductorState getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ConductorState _defaultInstance; + static ConductorState? _defaultInstance; @$pb.TagNumber(1) $core.String get releaseChannel => $_getSZ(0); diff --git a/dev/conductor/lib/proto/conductor_state.pbenum.dart b/dev/conductor/lib/proto/conductor_state.pbenum.dart index 0e14fba55c..dfdc5f7074 100644 --- a/dev/conductor/lib/proto/conductor_state.pbenum.dart +++ b/dev/conductor/lib/proto/conductor_state.pbenum.dart @@ -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); } diff --git a/dev/conductor/lib/proto/conductor_state.pbjson.dart b/dev/conductor/lib/proto/conductor_state.pbjson.dart index 55bdb97c42..6f16e23da6 100644 --- a/dev/conductor/lib/proto/conductor_state.pbjson.dart +++ b/dev/conductor/lib/proto/conductor_state.pbjson.dart @@ -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; diff --git a/dev/conductor/lib/proto/conductor_state.pbserver.dart b/dev/conductor/lib/proto/conductor_state.pbserver.dart index f97847ad74..e1b793df47 100644 --- a/dev/conductor/lib/proto/conductor_state.pbserver.dart +++ b/dev/conductor/lib/proto/conductor_state.pbserver.dart @@ -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'; diff --git a/dev/conductor/lib/roll_dev.dart b/dev/conductor/lib/roll_dev.dart index 4a5c4c3a2d..a5eaa504ed 100644 --- a/dev/conductor/lib/roll_dev.dart +++ b/dev/conductor/lib/roll_dev.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; diff --git a/dev/conductor/lib/start.dart b/dev/conductor/lib/start.dart index 31b3825704..932fd9bdfc 100644 --- a/dev/conductor/lib/start.dart +++ b/dev/conductor/lib/start.dart @@ -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 { 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 { 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 { @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 { } 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 frameworkCherrypickRevisions = getValuesFromEnvOrArgs( kFrameworkCherrypicksOption, - argResults, + argumentResults, platform.environment, ); final List 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 { 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 { 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 { // To minimize merge conflicts, sort the commits by rev-list order. List _sortCherrypicks({ - @required Repository repository, - @required List cherrypicks, - @required String upstreamRef, - @required String releaseRef, + required Repository repository, + required List cherrypicks, + required String upstreamRef, + required String releaseRef, }) { if (cherrypicks.isEmpty) { return cherrypicks; diff --git a/dev/conductor/lib/state.dart b/dev/conductor/lib/state.dart index c0482208e3..eb97d1a4a4 100644 --- a/dev/conductor/lib/state.dart +++ b/dev/conductor/lib/state.dart @@ -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 [ - 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 logs) { diff --git a/dev/conductor/lib/status.dart b/dev/conductor/lib/status.dart index 0548ef58d3..9c5ad0a9ee 100644 --- a/dev/conductor/lib/status.dart +++ b/dev/conductor/lib/status.dart @@ -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 { StatusCommand({ - @required this.checkouts, + required this.checkouts, }) : platform = checkouts.platform, fileSystem = checkouts.fileSystem, stdio = checkouts.stdio { @@ -51,16 +48,16 @@ class StatusCommand extends Command { @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); } diff --git a/dev/conductor/test/clean_test.dart b/dev/conductor/test/clean_test.dart index 55258b16d1..4bfdf82490 100644 --- a/dev/conductor/test/clean_test.dart +++ b/dev/conductor/test/clean_test.dart @@ -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 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 createRunner({ - List commands, - String operatingSystem, - }) { - operatingSystem ??= const LocalPlatform().operatingSystem; + final String operatingSystem = const LocalPlatform().operatingSystem; final String pathSeparator = operatingSystem == 'windows' ? r'\' : '/'; - processManager = FakeProcessManager.list(commands ?? []); + processManager = FakeProcessManager.empty(); platform = FakePlatform( environment: {'HOME': '/path/to/user/home'}, pathSeparator: pathSeparator, @@ -59,11 +44,10 @@ void main() { final CleanCommand command = CleanCommand( checkouts: checkouts, ); - return CommandRunner('clean-test', '')..addCommand(command); - } + runner = CommandRunner('clean-test', '')..addCommand(command); + }); test('throws if no state file found', () async { - final CommandRunner runner = createRunner(); const String stateFile = '/state-file.json'; await expectLater( @@ -80,7 +64,6 @@ void main() { }); test('deletes state file', () async { - final CommandRunner runner = createRunner(); final File stateFile = fileSystem.file('/state-file.json'); stateFile.writeAsStringSync('{}'); diff --git a/dev/conductor/test/common.dart b/dev/conductor/test/common.dart index a397dc3afe..274d949aee 100644 --- a/dev/conductor/test/common.dart +++ b/dev/conductor/test/common.dart @@ -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, diff --git a/dev/conductor/test/next_test.dart b/dev/conductor/test/next_test.dart index caa7c773fa..e991dc4e07 100644 --- a/dev/conductor/test/next_test.dart +++ b/dev/conductor/test/next_test.dart @@ -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 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( diff --git a/dev/conductor/test/roll_dev_test.dart b/dev/conductor/test/roll_dev_test.dart index 86e507b518..acac496a92 100644 --- a/dev/conductor/test/roll_dev_test.dart +++ b/dev/conductor/test/roll_dev_test.dart @@ -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(); diff --git a/dev/conductor/test/start_test.dart b/dev/conductor/test/start_test.dart index 0279c8777c..1eb2826200 100644 --- a/dev/conductor/test/start_test.dart +++ b/dev/conductor/test/start_test.dart @@ -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 createRunner({ - Map environment, - String operatingSystem, - List commands, + Map? environment, + String? operatingSystem, + List? commands, }) { operatingSystem ??= const LocalPlatform().operatingSystem; final String pathSeparator = operatingSystem == 'windows' ? r'\' : '/'; @@ -74,13 +72,6 @@ void main() { return CommandRunner('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 runner = createRunner( commands: [ @@ -251,7 +242,7 @@ void main() { ); final String stateFilePath = fileSystem.path.join( - platform.environment['HOME'], + platform.environment['HOME']!, kStateFileName, );