Add --device-id option for devicelab/bin/run.dart (#59276)

* Implement device selection for devicelab/run.dart

* Add test to --device-id option for devicelab/run

* Update dev/devicelab/bin/run.dart by jonahwilliam

* Rename deviceOperatingSystem enum mock -> fake

Co-authored-by: Jonah Williams <jonahwilliams@google.com>
This commit is contained in:
Ming Lyu (CareF)
2020-06-26 09:29:46 -04:00
committed by GitHub
parent 0412c470ef
commit 99f5eebc6b
6 changed files with 271 additions and 11 deletions

View File

@@ -28,8 +28,13 @@ void main() {
}
Future<void> expectScriptResult(
List<String> testNames, int expectedExitCode) async {
final ProcessResult result = await runScript(testNames);
List<String> testNames,
int expectedExitCode,
{String deviceId}
) async {
final ProcessResult result = await runScript(testNames, <String>[
if (deviceId != null) ...<String>['-d', deviceId],
]);
expect(result.exitCode, expectedExitCode,
reason:
'[ stderr from test process ]\n\n${result.stderr}\n\n[ end of stderr ]'
@@ -71,6 +76,17 @@ void main() {
);
});
test('exits with code 0 when provided a valid device ID', () async {
await expectScriptResult(<String>['smoke_test_device'], 0,
deviceId: 'FAKE');
});
test('exits with code 1 when provided a bad device ID', () async {
await expectScriptResult(<String>['smoke_test_device'], 1,
deviceId: 'THIS_IS_NOT_VALID');
});
test('runs A/B test', () async {
final ProcessResult result = await runScript(
<String>['smoke_test_success'],