OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 @TestOn("vm") | 5 @TestOn("vm") |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
10 import 'package:unittest/src/util/exit_codes.dart' as exit_codes; | 10 import 'package:unittest/src/util/exit_codes.dart' as exit_codes; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 var result = _runUnittest(["test.dart"]); | 121 var result = _runUnittest(["test.dart"]); |
122 | 122 |
123 expect(result.stderr, equals( | 123 expect(result.stderr, equals( |
124 'Failed to load "${p.relative(testPath, from: _sandbox)}":\n' | 124 'Failed to load "${p.relative(testPath, from: _sandbox)}":\n' |
125 "Error on line 1, column 8: TestOn takes one argument.\n" | 125 "Error on line 1, column 8: TestOn takes one argument.\n" |
126 "@TestOn()\n" | 126 "@TestOn()\n" |
127 " ^^\n")); | 127 " ^^\n")); |
128 expect(result.exitCode, equals(exit_codes.data)); | 128 expect(result.exitCode, equals(exit_codes.data)); |
129 }); | 129 }); |
130 | 130 |
| 131 test("an annotation's contents are invalid", () { |
| 132 var testPath = p.join(_sandbox, "test.dart"); |
| 133 new File(testPath).writeAsStringSync("@TestOn('zim')\nlibrary foo;"); |
| 134 var result = _runUnittest(["test.dart"]); |
| 135 |
| 136 expect(result.stderr, equals( |
| 137 'Failed to load "${p.relative(testPath, from: _sandbox)}":\n' |
| 138 "Error on line 1, column 10: Undefined variable.\n" |
| 139 "@TestOn('zim')\n" |
| 140 " ^^^\n")); |
| 141 expect(result.exitCode, equals(exit_codes.data)); |
| 142 }); |
| 143 |
131 test("a test file throws", () { | 144 test("a test file throws", () { |
132 var testPath = p.join(_sandbox, "test.dart"); | 145 var testPath = p.join(_sandbox, "test.dart"); |
133 new File(testPath).writeAsStringSync("void main() => throw 'oh no';"); | 146 new File(testPath).writeAsStringSync("void main() => throw 'oh no';"); |
134 | 147 |
135 var result = _runUnittest(["test.dart"]); | 148 var result = _runUnittest(["test.dart"]); |
136 expect(result.stderr, startsWith( | 149 expect(result.stderr, startsWith( |
137 'Failed to load "${p.relative(testPath, from: _sandbox)}": oh no\n')); | 150 'Failed to load "${p.relative(testPath, from: _sandbox)}": oh no\n')); |
138 expect(result.exitCode, equals(exit_codes.data)); | 151 expect(result.exitCode, equals(exit_codes.data)); |
139 }); | 152 }); |
140 | 153 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 expect(result.stdout, contains("\u001b[31m")); | 272 expect(result.stdout, contains("\u001b[31m")); |
260 }); | 273 }); |
261 }); | 274 }); |
262 } | 275 } |
263 | 276 |
264 ProcessResult _runUnittest(List<String> args) => | 277 ProcessResult _runUnittest(List<String> args) => |
265 runUnittest(args, workingDirectory: _sandbox); | 278 runUnittest(args, workingDirectory: _sandbox); |
266 | 279 |
267 ProcessResult _runDart(List<String> args) => | 280 ProcessResult _runDart(List<String> args) => |
268 runDart(args, workingDirectory: _sandbox); | 281 runDart(args, workingDirectory: _sandbox); |
OLD | NEW |