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

Unified Diff: lib/src/runner/loader.dart

Issue 1027193004: Respect top-level @TestOn declarations. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Add another test. Created 5 years, 9 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/loader.dart
diff --git a/lib/src/runner/loader.dart b/lib/src/runner/loader.dart
index 6188cd5bd47cafa2c962b1a0a1cf590b60cb7461..be39363383a5fcdd77eaa9dc2052c5c3ff12f6ff 100644
--- a/lib/src/runner/loader.dart
+++ b/lib/src/runner/loader.dart
@@ -8,8 +8,10 @@ import 'dart:async';
import 'dart:io';
import 'dart:isolate';
+import 'package:analyzer/analyzer.dart';
import 'package:path/path.dart' as p;
+import '../backend/metadata.dart';
import '../backend/suite.dart';
import '../backend/test_platform.dart';
import '../util/dart.dart';
@@ -18,6 +20,7 @@ import '../util/remote_exception.dart';
import '../utils.dart';
import 'browser/server.dart';
import 'load_exception.dart';
+import 'parse_metadata.dart';
import 'vm/isolate_test.dart';
/// A class for finding test files and loading them into a runnable form.
@@ -82,11 +85,27 @@ class Loader {
///
/// This will throw a [LoadException] if the file fails to load.
Future<List<Suite>> loadFile(String path) {
+ var metadata;
+ try {
+ metadata = parseMetadata(path);
+ } on AnalyzerErrorGroup catch (_) {
+ // Ignore the analyzer's error, since its formatting is much worse than
+ // the VM's or dart2js's.
+ metadata = new Metadata();
+ } on FormatException catch (error) {
+ throw new LoadException(path, error);
+ }
+
return Future.wait(_platforms.map((platform) {
- if (platform == TestPlatform.chrome) return _loadBrowserFile(path);
- assert(platform == TestPlatform.vm);
- return _loadVmFile(path);
- }));
+ return new Future.sync(() {
+ if (!metadata.testOn.evaluate(platform, os: currentOS)) return null;
+
+ if (platform == TestPlatform.chrome) return _loadBrowserFile(path);
+ assert(platform == TestPlatform.vm);
+ return _loadVmFile(path);
+ }).then((suite) =>
+ suite == null ? null : suite.change(metadata: metadata));
+ })).then((suites) => suites.where((suite) => suite != null).toList());
}
/// Load the test suite at [path] in a browser.

Powered by Google App Engine
This is Rietveld 408576698