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

Unified Diff: test/runner/runner_test.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: test/runner/runner_test.dart
diff --git a/test/runner/runner_test.dart b/test/runner/runner_test.dart
index 002824a966a0ae7c1c891e553a737e966fbf7ecc..478ff77d120815486ad820aae34aaa3d13eaabd4 100644
--- a/test/runner/runner_test.dart
+++ b/test/runner/runner_test.dart
@@ -2,6 +2,8 @@
// 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.
+@TestOn("vm")
+
import 'dart:io';
import 'package:path/path.dart' as p;
@@ -98,6 +100,34 @@ $_usage"""));
expect(result.exitCode, equals(exit_codes.data));
});
+ // This is slightly different from the above test because it's an error
+ // that's caught first by the analyzer when it's used to parse the file.
+ test("a test file fails to parse", () {
+ var testPath = p.join(_sandbox, "test.dart");
+ new File(testPath).writeAsStringSync("@TestOn)");
+ var result = _runUnittest(["test.dart"]);
+
+ expect(result.stderr, equals(
+ 'Failed to load "${p.relative(testPath, from: _sandbox)}":\n'
+ "line 1 pos 8: unexpected token ')'\n"
+ "@TestOn)\n"
+ " ^\n"));
+ expect(result.exitCode, equals(exit_codes.data));
+ });
+
+ test("an annotation's structure is invalid", () {
+ var testPath = p.join(_sandbox, "test.dart");
+ new File(testPath).writeAsStringSync("@TestOn()\nlibrary foo;");
+ var result = _runUnittest(["test.dart"]);
+
+ expect(result.stderr, equals(
+ 'Failed to load "${p.relative(testPath, from: _sandbox)}":\n'
+ "Error on line 1, column 8: TestOn takes one argument.\n"
+ "@TestOn()\n"
+ " ^^\n"));
+ expect(result.exitCode, equals(exit_codes.data));
+ });
+
test("a test file throws", () {
var testPath = p.join(_sandbox, "test.dart");
new File(testPath).writeAsStringSync("void main() => throw 'oh no';");

Powered by Google App Engine
This is Rietveld 408576698