[Conductor] Add ability to override mirror, add tests for default arg parsing and custom arg parsing (#154363)
fixes #154342
This commit is contained in:
parent
35b0349294
commit
9d9ec70b4e
@ -60,6 +60,11 @@ class StartCommand extends Command<void> {
|
|||||||
help: 'The target release channel for the release.',
|
help: 'The target release channel for the release.',
|
||||||
allowed: kBaseReleaseChannels,
|
allowed: kBaseReleaseChannels,
|
||||||
);
|
);
|
||||||
|
argParser.addOption(
|
||||||
|
kFrameworkMirrorOption,
|
||||||
|
help:
|
||||||
|
'Configurable Framework repo mirror remote.',
|
||||||
|
);
|
||||||
argParser.addOption(
|
argParser.addOption(
|
||||||
kFrameworkUpstreamOption,
|
kFrameworkUpstreamOption,
|
||||||
defaultsTo: FrameworkRepository.defaultUpstream,
|
defaultsTo: FrameworkRepository.defaultUpstream,
|
||||||
@ -112,14 +117,8 @@ class StartCommand extends Command<void> {
|
|||||||
@override
|
@override
|
||||||
String get description => 'Initialize a new Flutter release.';
|
String get description => 'Initialize a new Flutter release.';
|
||||||
|
|
||||||
@override
|
@visibleForTesting
|
||||||
Future<void> run() async {
|
StartContext createContext(ArgResults argumentResults) {
|
||||||
final ArgResults argumentResults = argResults!;
|
|
||||||
if (!platform.isMacOS && !platform.isLinux) {
|
|
||||||
throw ConductorException(
|
|
||||||
'Error! This tool is only supported on macOS and Linux',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final String frameworkUpstream = getValueFromEnvOrArgs(
|
final String frameworkUpstream = getValueFromEnvOrArgs(
|
||||||
kFrameworkUpstreamOption,
|
kFrameworkUpstreamOption,
|
||||||
@ -131,7 +130,12 @@ class StartCommand extends Command<void> {
|
|||||||
argumentResults,
|
argumentResults,
|
||||||
platform.environment,
|
platform.environment,
|
||||||
)!;
|
)!;
|
||||||
final String frameworkMirror =
|
final String frameworkMirror = getValueFromEnvOrArgs(
|
||||||
|
kFrameworkMirrorOption,
|
||||||
|
argumentResults,
|
||||||
|
platform.environment,
|
||||||
|
allowNull: true,
|
||||||
|
) ??
|
||||||
'git@github.com:$githubUsername/flutter.git';
|
'git@github.com:$githubUsername/flutter.git';
|
||||||
final String engineUpstream = getValueFromEnvOrArgs(
|
final String engineUpstream = getValueFromEnvOrArgs(
|
||||||
kEngineUpstreamOption,
|
kEngineUpstreamOption,
|
||||||
@ -175,7 +179,7 @@ class StartCommand extends Command<void> {
|
|||||||
versionOverride = Version.fromString(versionOverrideString);
|
versionOverride = Version.fromString(versionOverrideString);
|
||||||
}
|
}
|
||||||
|
|
||||||
final StartContext context = StartContext(
|
return StartContext(
|
||||||
candidateBranch: candidateBranch,
|
candidateBranch: candidateBranch,
|
||||||
checkouts: checkouts,
|
checkouts: checkouts,
|
||||||
dartRevision: dartRevision,
|
dartRevision: dartRevision,
|
||||||
@ -191,7 +195,18 @@ class StartCommand extends Command<void> {
|
|||||||
versionOverride: versionOverride,
|
versionOverride: versionOverride,
|
||||||
githubUsername: githubUsername,
|
githubUsername: githubUsername,
|
||||||
);
|
);
|
||||||
return context.run();
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> run() async {
|
||||||
|
final ArgResults argumentResults = argResults!;
|
||||||
|
if (!platform.isMacOS && !platform.isLinux) {
|
||||||
|
throw ConductorException(
|
||||||
|
'Error! This tool is only supported on macOS and Linux',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return createContext(argumentResults).run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,8 +23,7 @@ void main() {
|
|||||||
const String flutterRoot = '/flutter';
|
const String flutterRoot = '/flutter';
|
||||||
const String checkoutsParentDirectory = '$flutterRoot/dev/tools/';
|
const String checkoutsParentDirectory = '$flutterRoot/dev/tools/';
|
||||||
const String githubUsername = 'user';
|
const String githubUsername = 'user';
|
||||||
const String frameworkMirror =
|
const String frameworkMirror = 'git@github.com:$githubUsername/flutter.git';
|
||||||
'git@github.com:$githubUsername/flutter.git';
|
|
||||||
const String engineMirror = 'git@github.com:$githubUsername/engine.git';
|
const String engineMirror = 'git@github.com:$githubUsername/engine.git';
|
||||||
const String candidateBranch = 'flutter-1.2-candidate.3';
|
const String candidateBranch = 'flutter-1.2-candidate.3';
|
||||||
const String releaseChannel = 'beta';
|
const String releaseChannel = 'beta';
|
||||||
@ -76,6 +75,85 @@ void main() {
|
|||||||
return CommandRunner<void>('codesign-test', '')..addCommand(command);
|
return CommandRunner<void>('codesign-test', '')..addCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
group('start arg parser', () {
|
||||||
|
const String nextDartRevision =
|
||||||
|
'f6c91128be6b77aef8351e1e3a9d07c85bc2e46e';
|
||||||
|
late StartCommand startCommand;
|
||||||
|
setUp(() {
|
||||||
|
final String operatingSystem = const LocalPlatform().operatingSystem;
|
||||||
|
final Map<String, String> environment = <String, String>{
|
||||||
|
'HOME': '/path/to/user/home',
|
||||||
|
};
|
||||||
|
final Directory homeDir = fileSystem.directory(
|
||||||
|
environment['HOME'],
|
||||||
|
);
|
||||||
|
// Tool assumes this exists
|
||||||
|
homeDir.createSync(recursive: true);
|
||||||
|
platform = FakePlatform(
|
||||||
|
environment: environment,
|
||||||
|
operatingSystem: operatingSystem,
|
||||||
|
pathSeparator: '/',
|
||||||
|
);
|
||||||
|
processManager = FakeProcessManager.list(<FakeCommand>[]);
|
||||||
|
checkouts = Checkouts(
|
||||||
|
fileSystem: fileSystem,
|
||||||
|
parentDirectory: fileSystem.directory(checkoutsParentDirectory),
|
||||||
|
platform: platform,
|
||||||
|
processManager: processManager,
|
||||||
|
stdio: stdio,
|
||||||
|
);
|
||||||
|
startCommand = StartCommand(
|
||||||
|
checkouts: checkouts, conductorVersion: conductorVersion);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('default args', () async {
|
||||||
|
final List<String> args = <String>[
|
||||||
|
'start',
|
||||||
|
'--$kCandidateOption',
|
||||||
|
candidateBranch,
|
||||||
|
'--$kReleaseOption',
|
||||||
|
'stable',
|
||||||
|
'--$kStateOption',
|
||||||
|
'/path/to/statefile.json',
|
||||||
|
'--$kDartRevisionOption',
|
||||||
|
nextDartRevision,
|
||||||
|
'--$kGithubUsernameOption',
|
||||||
|
githubUsername,
|
||||||
|
];
|
||||||
|
final StartContext context =
|
||||||
|
startCommand.createContext(startCommand.argParser.parse(args));
|
||||||
|
expect(context.frameworkUpstream, FrameworkRepository.defaultUpstream);
|
||||||
|
expect(context.frameworkMirror, contains(githubUsername));
|
||||||
|
expect(context.frameworkMirror, contains('/flutter.git'));
|
||||||
|
expect(context.engineUpstream, EngineRepository.defaultUpstream);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('overridden mirror', () async {
|
||||||
|
const String customFrameworkMirror =
|
||||||
|
'git@github.com:$githubUsername/flutter-work.git';
|
||||||
|
final List<String> args = <String>[
|
||||||
|
'start',
|
||||||
|
'--$kCandidateOption',
|
||||||
|
candidateBranch,
|
||||||
|
'--$kReleaseOption',
|
||||||
|
'stable',
|
||||||
|
'--$kStateOption',
|
||||||
|
'/path/to/statefile.json',
|
||||||
|
'--$kDartRevisionOption',
|
||||||
|
nextDartRevision,
|
||||||
|
'--$kGithubUsernameOption',
|
||||||
|
githubUsername,
|
||||||
|
'--$kFrameworkMirrorOption',
|
||||||
|
customFrameworkMirror,
|
||||||
|
];
|
||||||
|
final StartContext context =
|
||||||
|
startCommand.createContext(startCommand.argParser.parse(args));
|
||||||
|
expect(
|
||||||
|
context.frameworkMirror, customFrameworkMirror
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('throws exception if run from Windows', () async {
|
test('throws exception if run from Windows', () async {
|
||||||
final CommandRunner<void> runner = createRunner(
|
final CommandRunner<void> runner = createRunner(
|
||||||
commands: <FakeCommand>[
|
commands: <FakeCommand>[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user