[Conductor] Add ability to override mirror, add tests for default arg parsing and custom arg parsing (#154363)
fixes #154342
This commit is contained in:
@@ -23,8 +23,7 @@ void main() {
|
||||
const String flutterRoot = '/flutter';
|
||||
const String checkoutsParentDirectory = '$flutterRoot/dev/tools/';
|
||||
const String githubUsername = 'user';
|
||||
const String frameworkMirror =
|
||||
'git@github.com:$githubUsername/flutter.git';
|
||||
const String frameworkMirror = 'git@github.com:$githubUsername/flutter.git';
|
||||
const String engineMirror = 'git@github.com:$githubUsername/engine.git';
|
||||
const String candidateBranch = 'flutter-1.2-candidate.3';
|
||||
const String releaseChannel = 'beta';
|
||||
@@ -76,6 +75,85 @@ void main() {
|
||||
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 {
|
||||
final CommandRunner<void> runner = createRunner(
|
||||
commands: <FakeCommand>[
|
||||
|
||||
Reference in New Issue
Block a user