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

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

Issue 1731503002: Add a hack to globally register a platform plugin. (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
« no previous file with comments | « lib/src/runner/loader.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/plugin/hack_register_platform.dart
diff --git a/lib/src/runner/plugin/hack_register_platform.dart b/lib/src/runner/plugin/hack_register_platform.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ce2cfbf56dba545432f764e92ea6ea5eba4717ab
--- /dev/null
+++ b/lib/src/runner/plugin/hack_register_platform.dart
@@ -0,0 +1,34 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. 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:collection';
+
+import '../../backend/test_platform.dart';
+import '../../utils.dart';
+import 'platform.dart';
+
+/// The functions to use to load [_platformPlugins] in all loaders.
+///
+/// **Do not access this outside the test package**.
+final platformCallbacks =
+ new UnmodifiableMapView<TestPlatform, AsyncFunction>(_platformCallbacks);
+final _platformCallbacks = <TestPlatform, AsyncFunction>{};
+
+/// **Do not call this function without express permission from the test package
+/// authors**.
+///
+/// Registers a [PlatformPlugin] for [platforms].
+///
+/// This globally registers a plugin for all [Loader]s. When the runner first
+/// requests that a suite be loaded for one of the given platforms, this will
+/// call [getPlugin] to load the platform plugin. It may return either a
+/// [PlatformPlugin] or a [Future<PlatformPlugin>]. That plugin is then
+/// preserved and used to load all suites for all matching platforms.
+///
+/// This overwrites the default plugins for those platforms.
+void registerPlatformPlugin(Iterable<TestPlatform> platforms, getPlugin()) {
kevmoo 2016/02/23 22:54:50 Feels weird that getPlugin() doesn't take in an ar
nweiz 2016/02/24 00:21:22 What arg do you expect it to take in?
kevmoo 2016/02/24 00:28:54 The platform? – although I guess you can call this
+ for (var platform in platforms) {
+ _platformCallbacks[platform] = getPlugin;
+ }
+}
« no previous file with comments | « lib/src/runner/loader.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698