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

Unified Diff: test/runner/browser/runner_test.dart

Issue 1083433002: More gracefully handle load errors. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 8 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 | « test/runner/browser/loader_test.dart ('k') | test/runner/loader_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/runner/browser/runner_test.dart
diff --git a/test/runner/browser/runner_test.dart b/test/runner/browser/runner_test.dart
index 6b396be79ef567140f47be9a3a1a30914a07337e..2ca23420d4951e357bd4815f98e25e07ae11e39e 100644
--- a/test/runner/browser/runner_test.dart
+++ b/test/runner/browser/runner_test.dart
@@ -42,10 +42,13 @@ void main() {
expect(result.stdout,
contains("Expected a declaration, but got 'invalid'"));
- expect(result.stderr, equals(
- 'Failed to load "${p.relative(testPath, from: _sandbox)}": dart2js '
- 'failed.\n'));
- expect(result.exitCode, equals(exit_codes.data));
+ expect(result.stdout, allOf([
+ contains('-1: load error'),
+ contains(
+ 'Failed to load "${p.relative(testPath, from: _sandbox)}": dart2js '
+ 'failed.')
+ ]));
+ expect(result.exitCode, equals(1));
});
test("a test file throws", () {
@@ -53,9 +56,12 @@ void main() {
new File(testPath).writeAsStringSync("void main() => throw 'oh no';");
var result = _runUnittest(["-p", "chrome", "test.dart"]);
- expect(result.stderr, startsWith(
- 'Failed to load "${p.relative(testPath, from: _sandbox)}": oh no\n'));
- expect(result.exitCode, equals(exit_codes.data));
+ expect(result.stdout, allOf([
+ contains('-1: load error'),
+ contains(
+ 'Failed to load "${p.relative(testPath, from: _sandbox)}": oh no')
+ ]));
+ expect(result.exitCode, equals(1));
});
test("a test file doesn't have a main defined", () {
@@ -63,10 +69,13 @@ void main() {
new File(testPath).writeAsStringSync("void foo() {}");
var result = _runUnittest(["-p", "chrome", "test.dart"]);
- expect(result.stderr, startsWith(
- 'Failed to load "${p.relative(testPath, from: _sandbox)}": No '
- 'top-level main() function defined.\n'));
- expect(result.exitCode, equals(exit_codes.data));
+ expect(result.stdout, allOf([
+ contains('-1: load error'),
+ contains(
+ 'Failed to load "${p.relative(testPath, from: _sandbox)}": No '
+ 'top-level main() function defined.')
+ ]));
+ expect(result.exitCode, equals(1));
});
test("a test file has a non-function main", () {
@@ -74,10 +83,13 @@ void main() {
new File(testPath).writeAsStringSync("int main;");
var result = _runUnittest(["-p", "chrome", "test.dart"]);
- expect(result.stderr, startsWith(
- 'Failed to load "${p.relative(testPath, from: _sandbox)}": Top-level '
- 'main getter is not a function.\n'));
- expect(result.exitCode, equals(exit_codes.data));
+ expect(result.stdout, allOf([
+ contains('-1: load error'),
+ contains(
+ 'Failed to load "${p.relative(testPath, from: _sandbox)}": '
+ 'Top-level main getter is not a function.\n')
+ ]));
+ expect(result.exitCode, equals(1));
});
test("a test file has a main with arguments", () {
@@ -85,10 +97,13 @@ void main() {
new File(testPath).writeAsStringSync("void main(arg) {}");
var result = _runUnittest(["-p", "chrome", "test.dart"]);
- expect(result.stderr, startsWith(
- 'Failed to load "${p.relative(testPath, from: _sandbox)}": Top-level '
- 'main() function takes arguments.\n'));
- expect(result.exitCode, equals(exit_codes.data));
+ expect(result.stdout, allOf([
+ contains('-1: load error'),
+ contains(
+ 'Failed to load "${p.relative(testPath, from: _sandbox)}": '
+ 'Top-level main() function takes arguments.\n')
+ ]));
+ expect(result.exitCode, equals(1));
});
// TODO(nweiz): test what happens when a test file is unreadable once issue
« no previous file with comments | « test/runner/browser/loader_test.dart ('k') | test/runner/loader_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698