Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1630)

Unified Diff: lib/src/runner/plugin/platform.dart

Issue 1704773002: Load web tests using the plugin infrastructure. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/src/runner/plugin/platform.dart
diff --git a/lib/src/runner/plugin/platform.dart b/lib/src/runner/plugin/platform.dart
index be5a14ee0bdaa243c99e0fbb6fd29a92bdf81924..820f4c0371aaa94c6b271f0fec6767330d775d47 100644
--- a/lib/src/runner/plugin/platform.dart
+++ b/lib/src/runner/plugin/platform.dart
@@ -4,20 +4,14 @@
import 'dart:async';
-import 'package:stack_trace/stack_trace.dart';
import 'package:stream_channel/stream_channel.dart';
-import '../../backend/group.dart';
import '../../backend/metadata.dart';
-import '../../backend/test.dart';
import '../../backend/test_platform.dart';
-import '../../util/io.dart';
-import '../../util/remote_exception.dart';
import '../environment.dart';
-import '../load_exception.dart';
import '../runner_suite.dart';
-import '../runner_test.dart';
import 'environment.dart';
+import 'platform_helpers.dart';
/// A class that defines a platform for which test suites can be loaded.
///
@@ -30,16 +24,10 @@ import 'environment.dart';
/// well, which returns a [RunnerSuite] that can contain a custom [Environment]
/// and control debugging metadata such as [RunnerSuite.isDebugging] and
/// [RunnerSuite.onDebugging]. To make this easier, implementations can call
-/// [deserializeSuite].
+/// [deserializeSuite] in `platform_helpers.dart`.
///
/// A platform plugin can be registered with [Loader.registerPlatformPlugin].
abstract class PlatformPlugin {
- /// The platforms supported by this plugin.
- ///
- /// A plugin may declare support for existing platform, in which case it
- /// overrides the previous loading functionality for that platform.
- List<TestPlatform> get platforms;
-
/// Loads and establishes a connection with the test file at [path] using
/// [platform].
///
@@ -65,7 +53,8 @@ abstract class PlatformPlugin {
/// implementation of [Environment].
///
/// It's recommended that subclasses overriding this method call
- /// [deserializeSuite] to obtain a [RunnerSuiteController].
+ /// [deserializeSuite] in `platform_helpers.dart` to obtain a
+ /// [RunnerSuiteController].
Future<RunnerSuite> load(String path, TestPlatform platform,
Metadata metadata) async {
// loadChannel may throw an exception. That's fine; it will cause the
@@ -76,105 +65,7 @@ abstract class PlatformPlugin {
return controller.suite;
}
- /// A helper method for creating a [RunnerSuiteController] containing tests
- /// that communicate over [channel].
- ///
- /// This is notionally a protected method. It may be called by subclasses, but
- /// it shouldn't be accessed by externally.
- ///
- /// This returns a controller so that the caller has a chance to control the
- /// runner suite's debugging state based on plugin-specific logic.
- Future<RunnerSuiteController> deserializeSuite(String path,
- TestPlatform platform, Metadata metadata, Environment environment,
- StreamChannel channel) async {
- var disconnector = new Disconnector();
- var suiteChannel = new MultiChannel(channel.transform(disconnector));
-
- suiteChannel.sink.add({
- 'platform': platform.identifier,
- 'metadata': metadata.serialize(),
- 'os': platform == TestPlatform.vm ? currentOS.name : null
- });
-
- var completer = new Completer();
-
- handleError(error, stackTrace) {
- disconnector.disconnect();
-
- if (completer.isCompleted) {
- // If we've already provided a controller, send the error to the
- // LoadSuite. This will cause the virtual load test to fail, which will
- // notify the user of the error.
- Zone.current.handleUncaughtError(error, stackTrace);
- } else {
- completer.completeError(error, stackTrace);
- }
- }
-
- suiteChannel.stream.listen((response) {
- switch (response["type"]) {
- case "print":
- print(response["line"]);
- break;
-
- case "loadException":
- handleError(
- new LoadException(path, response["message"]),
- new Trace.current());
- break;
-
- case "error":
- var asyncError = RemoteException.deserialize(response["error"]);
- handleError(
- new LoadException(path, asyncError.error),
- asyncError.stackTrace);
- break;
-
- case "success":
- completer.complete(
- _deserializeGroup(suiteChannel, response["root"]));
- break;
- }
- }, onError: handleError, onDone: () {
- if (completer.isCompleted) return;
- completer.completeError(
- new LoadException(
- path, "Connection closed before test suite loaded."),
- new Trace.current());
- });
-
- return new RunnerSuiteController(
- environment,
- await completer.future,
- path: path,
- platform: platform,
- os: currentOS,
- onClose: disconnector.disconnect);
- }
-
- /// Deserializes [group] into a concrete [Group].
- Group _deserializeGroup(MultiChannel suiteChannel, Map group) {
- var metadata = new Metadata.deserialize(group['metadata']);
- return new Group(group['name'], group['entries'].map((entry) {
- if (entry['type'] == 'group') {
- return _deserializeGroup(suiteChannel, entry);
- }
+ Future closeEphemeral() async {}
- return _deserializeTest(suiteChannel, entry);
- }),
- metadata: metadata,
- setUpAll: _deserializeTest(suiteChannel, group['setUpAll']),
- tearDownAll: _deserializeTest(suiteChannel, group['tearDownAll']));
- }
-
- /// Deserializes [test] into a concrete [Test] class.
- ///
- /// Returns `null` if [test] is `null`.
- Test _deserializeTest(MultiChannel suiteChannel, Map test) {
- if (test == null) return null;
-
- var metadata = new Metadata.deserialize(test['metadata']);
- var testChannel = suiteChannel.virtualChannel(test['channel']);
- return new RunnerTest(test['name'], metadata, testChannel);
- }
+ Future close() async {}
}

Powered by Google App Engine
This is Rietveld 408576698