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

Side by Side Diff: test/runner/runner_test.dart

Issue 1172213002: Improve the capture and display of syntax errors in VM tests. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « lib/src/runner/vm/isolate_listener.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 contains('-1: load error'), 125 contains('-1: load error'),
126 contains( 126 contains(
127 ' Failed to load "${p.relative(testPath, from: _sandbox)}":\n' 127 ' Failed to load "${p.relative(testPath, from: _sandbox)}":\n'
128 " line 1 pos 1: unexpected token 'invalid'\n" 128 " line 1 pos 1: unexpected token 'invalid'\n"
129 " invalid Dart file\n" 129 " invalid Dart file\n"
130 " ^\n") 130 " ^\n")
131 ])); 131 ]));
132 expect(result.exitCode, equals(1)); 132 expect(result.exitCode, equals(1));
133 }); 133 });
134 134
135 // This syntax error is detected lazily, and so requires some extra
136 // machinery to support.
137 test("a test file fails to parse due to a missing semicolon", () {
138 var testPath = p.join(_sandbox, "test.dart");
139 new File(testPath).writeAsStringSync("void main() {foo}");
140 var result = _runTest(["test.dart"]);
141
142 expect(result.stdout, allOf([
143 contains('-1: load error'),
144 contains(
145 ' Failed to load "${p.relative(testPath, from: _sandbox)}":\n'
146 " line 1 pos 17: semicolon expected\n"
147 " void main() {foo}\n"
148 " ^\n")
149 ]));
150 expect(result.exitCode, equals(1));
151 });
152
135 // This is slightly different from the above test because it's an error 153 // This is slightly different from the above test because it's an error
136 // that's caught first by the analyzer when it's used to parse the file. 154 // that's caught first by the analyzer when it's used to parse the file.
137 test("a test file fails to parse", () { 155 test("a test file fails to parse", () {
138 var testPath = p.join(_sandbox, "test.dart"); 156 var testPath = p.join(_sandbox, "test.dart");
139 new File(testPath).writeAsStringSync("@TestOn)"); 157 new File(testPath).writeAsStringSync("@TestOn)");
140 var result = _runTest(["test.dart"]); 158 var result = _runTest(["test.dart"]);
141 159
142 expect(result.stdout, allOf([ 160 expect(result.stdout, allOf([
143 contains('-1: load error'), 161 contains('-1: load error'),
144 contains( 162 contains(
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 }); 685 });
668 }); 686 });
669 }); 687 });
670 } 688 }
671 689
672 ProcessResult _runTest(List<String> args) => 690 ProcessResult _runTest(List<String> args) =>
673 runTest(args, workingDirectory: _sandbox); 691 runTest(args, workingDirectory: _sandbox);
674 692
675 ProcessResult _runDart(List<String> args) => 693 ProcessResult _runDart(List<String> args) =>
676 runDart(args, workingDirectory: _sandbox); 694 runDart(args, workingDirectory: _sandbox);
OLDNEW
« no previous file with comments | « lib/src/runner/vm/isolate_listener.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698