move CI tests into the main repo (#5758)

This commit is contained in:
Yegor
2016-09-14 13:22:53 -07:00
committed by GitHub
parent 4ec5144427
commit 1ba1562293
42 changed files with 2624 additions and 3 deletions

101
dev/devicelab/bin/run.dart Normal file
View File

@@ -0,0 +1,101 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:args/args.dart';
import 'package:flutter_devicelab/framework/manifest.dart';
import 'package:flutter_devicelab/framework/runner.dart';
import 'package:flutter_devicelab/framework/utils.dart';
/// Runs tasks.
///
/// The tasks are chosen depending on the command-line options
/// (see [_argParser]).
Future<Null> main(List<String> rawArgs) async {
ArgResults args;
try {
args = _argParser.parse(rawArgs);
} on FormatException catch(error) {
stderr.writeln('${error.message}\n');
stderr.writeln('Usage:\n');
stderr.writeln(_argParser.usage);
exitCode = 1;
return null;
}
List<String> taskNames = <String>[];
if (args.wasParsed('task')) {
taskNames.addAll(args['task']);
} else if (args.wasParsed('stage')) {
String stageName = args['stage'];
List<ManifestTask> tasks = loadTaskManifest().tasks;
for (ManifestTask task in tasks) {
if (task.stage == stageName)
taskNames.add(task.name);
}
} else if (args.wasParsed('all')) {
List<ManifestTask> tasks = loadTaskManifest().tasks;
for (ManifestTask task in tasks) {
taskNames.add(task.name);
}
}
if (taskNames.isEmpty) {
stderr.writeln('Failed to find tasks to run based on supplied options.');
exitCode = 1;
return null;
}
for (String taskName in taskNames) {
section('Running task "$taskName"');
Map<String, dynamic> result = await runTask(taskName);
if (!result['success'])
exitCode = 1;
print('Task result:');
print(new JsonEncoder.withIndent(' ').convert(result));
section('Finished task "$taskName"');
}
}
/// Command-line options for the `run.dart` command.
final ArgParser _argParser = new ArgParser()
..addOption(
'task',
abbr: 't',
allowMultiple: true,
splitCommas: true,
help: 'Name of the task to run. This option may be repeated to '
'specify multiple tasks. A task selected by name does not have to be '
'defined in manifest.yaml. It only needs a Dart executable in bin/tasks.',
)
..addOption(
'stage',
abbr: 's',
help: 'Name of the stage. Runs all tasks for that stage. '
'The tasks and their stages are read from manifest.yaml.',
)
..addOption(
'all',
abbr: 'a',
help: 'Runs all tasks defined in manifest.yaml.',
)
..addOption(
'test',
hide: true,
allowMultiple: true,
splitCommas: true,
callback: (List<String> value) {
if (value.isNotEmpty) {
throw new FormatException(
'Invalid option --test. Did you mean --task (-t)?',
);
}
},
);

View File

@@ -0,0 +1,20 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/analysis.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/utils.dart';
Future<Null> main() async {
String revision = await getCurrentFlutterRepoCommit();
DateTime revisionTimestamp = await getFlutterRepoCommitTimestamp(revision);
String dartSdkVersion = await getDartVersion();
await task(createAnalyzerCliTest(
sdk: dartSdkVersion,
commit: revision,
timestamp: revisionTimestamp,
));
}

View File

@@ -0,0 +1,20 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/analysis.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/utils.dart';
Future<Null> main() async {
String revision = await getCurrentFlutterRepoCommit();
DateTime revisionTimestamp = await getFlutterRepoCommitTimestamp(revision);
String dartSdkVersion = await getDartVersion();
await task(createAnalyzerServerTest(
sdk: dartSdkVersion,
commit: revision,
timestamp: revisionTimestamp,
));
}

View File

@@ -0,0 +1,12 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/size_tests.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
await task(createBasicMaterialAppSizeTest());
}

View File

@@ -0,0 +1,12 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/perf_tests.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
await task(createComplexLayoutBuildTest());
}

View File

@@ -0,0 +1,12 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/perf_tests.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
await task(createComplexLayoutStartupTest(ios: false));
}

View File

@@ -0,0 +1,12 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/perf_tests.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
await task(createComplexLayoutStartupTest(ios: true));
}

View File

@@ -0,0 +1,12 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/perf_tests.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
await task(createComplexLayoutScrollPerfTest(ios: false));
}

View File

@@ -0,0 +1,12 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/perf_tests.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
await task(createComplexLayoutScrollPerfTest(ios: true));
}

View File

@@ -0,0 +1,12 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/perf_tests.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
await task(createFlutterGalleryBuildTest());
}

View File

@@ -0,0 +1,12 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/perf_tests.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
await task(createFlutterGalleryStartupTest(ios: false));
}

View File

@@ -0,0 +1,12 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/gallery.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
await task(createGalleryTransitionTest(ios: false));
}

View File

@@ -0,0 +1,12 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/perf_tests.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
await task(createFlutterGalleryStartupTest(ios: true));
}

View File

@@ -0,0 +1,12 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/gallery.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
await task(createGalleryTransitionTest(ios: true));
}

View File

@@ -0,0 +1,18 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/refresh.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/utils.dart';
Future<Null> main() async {
String revision = await getCurrentFlutterRepoCommit();
DateTime revisionTimestamp = await getFlutterRepoCommitTimestamp(revision);
await task(createRefreshTest(
commit: revision,
timestamp: revisionTimestamp,
));
}

View File

@@ -0,0 +1,14 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/framework/framework.dart';
/// Smoke test of a task that fails by returning an unsuccessful response.
Future<Null> main() async {
await task(() async {
return new TaskResult.failure('Failed');
});
}

View File

@@ -0,0 +1,13 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
/// Creates a situation when the test framework was not properly initialized.
///
/// By not calling `task()` the VM service extension is not registered and
/// therefore will not accept requests to run tasks. When the runner attempts to
/// connect and run the test it will receive a "method not found" error from the
/// VM service, will likely retry and finally time out.
Future<Null> main() async {}

View File

@@ -0,0 +1,14 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/framework/framework.dart';
/// Smoke test of a successful task.
Future<Null> main() async {
await task(() async {
return new TaskResult.success(<String, dynamic>{});
});
}

View File

@@ -0,0 +1,14 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/framework/framework.dart';
/// Smoke test of a task that fails with an exception.
Future<Null> main() async {
await task(() async {
throw 'failed';
});
}