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

Side by Side Diff: tests/compiler/dart2js/exit_code_test.dart

Issue 206193002: Remove cancel and make crash exit with code 253. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Test the exit code of dart2js in case of exceptions, fatal errors, errors, 5 // Test the exit code of dart2js in case of exceptions, fatal errors, errors,
6 // warnings, etc. 6 // warnings, etc.
7 7
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:io' show Platform; 10 import 'dart:io' show Platform;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 test(String marker) { 78 test(String marker) {
79 if (marker == testMarker) { 79 if (marker == testMarker) {
80 switch (testType) { 80 switch (testType) {
81 case 'assert': 81 case 'assert':
82 onTest(testMarker, testType); 82 onTest(testMarker, testType);
83 assert(false); 83 assert(false);
84 break; 84 break;
85 case 'invariant': 85 case 'invariant':
86 onTest(testMarker, testType); 86 onTest(testMarker, testType);
87 invariant(CURRENT_ELEMENT_SPANNABLE, false, message: marker); 87 invariant(NO_LOCATION_SPANNABLE, false, message: marker);
88 break; 88 break;
89 case 'warning': 89 case 'warning':
90 onTest(testMarker, testType); 90 onTest(testMarker, testType);
91 reportWarning(CURRENT_ELEMENT_SPANNABLE, 91 reportWarning(NO_LOCATION_SPANNABLE,
92 MessageKind.GENERIC, {'text': marker}); 92 MessageKind.GENERIC, {'text': marker});
93 break; 93 break;
94 case 'error': 94 case 'error':
95 onTest(testMarker, testType); 95 onTest(testMarker, testType);
96 reportError(CURRENT_ELEMENT_SPANNABLE, 96 reportError(NO_LOCATION_SPANNABLE,
97 MessageKind.GENERIC, {'text': marker}); 97 MessageKind.GENERIC, {'text': marker});
98 break; 98 break;
99 case 'fatalError': 99 case 'fatalError':
100 onTest(testMarker, testType); 100 onTest(testMarker, testType);
101 reportFatalError(CURRENT_ELEMENT_SPANNABLE, 101 reportFatalError(NO_LOCATION_SPANNABLE,
102 MessageKind.GENERIC, {'text': marker}); 102 MessageKind.GENERIC, {'text': marker});
103 break; 103 break;
104 case 'internalError':
105 onTest(testMarker, testType);
106 internalError(NO_LOCATION_SPANNABLE, marker);
107 break;
104 case 'NoSuchMethodError': 108 case 'NoSuchMethodError':
105 onTest(testMarker, testType); 109 onTest(testMarker, testType);
106 null.foo; 110 null.foo;
107 break; 111 break;
108 case '': 112 case '':
109 onTest(testMarker, testType); 113 onTest(testMarker, testType);
110 break; 114 break;
111 } 115 }
112 } 116 }
113 } 117 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 Future<String> compile(Uri script, 153 Future<String> compile(Uri script,
150 Uri libraryRoot, 154 Uri libraryRoot,
151 Uri packageRoot, 155 Uri packageRoot,
152 api.CompilerInputProvider inputProvider, 156 api.CompilerInputProvider inputProvider,
153 api.DiagnosticHandler handler, 157 api.DiagnosticHandler handler,
154 [List<String> options = const [], 158 [List<String> options = const [],
155 api.CompilerOutputProvider outputProvider, 159 api.CompilerOutputProvider outputProvider,
156 Map<String, dynamic> environment = const {}]) { 160 Map<String, dynamic> environment = const {}]) {
157 libraryRoot = Platform.script.resolve('../../../sdk/'); 161 libraryRoot = Platform.script.resolve('../../../sdk/');
158 outputProvider = NullSink.outputProvider; 162 outputProvider = NullSink.outputProvider;
159 handler = (uri, begin, end, message, kind) {}; 163 // Use this to silence the test when debugging:
164 // handler = (uri, begin, end, message, kind) {};
160 Compiler compiler = new TestCompiler(inputProvider, 165 Compiler compiler = new TestCompiler(inputProvider,
161 outputProvider, 166 outputProvider,
162 handler, 167 handler,
163 libraryRoot, 168 libraryRoot,
164 packageRoot, 169 packageRoot,
165 options, 170 options,
166 environment, 171 environment,
167 marker, 172 marker,
168 type, 173 type,
169 onTest); 174 onTest);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 }); 216 });
212 } 217 }
213 218
214 Future testExitCodes(String marker, Map<String,int> expectedExitCodes) { 219 Future testExitCodes(String marker, Map<String,int> expectedExitCodes) {
215 return Future.forEach(expectedExitCodes.keys, (String type) { 220 return Future.forEach(expectedExitCodes.keys, (String type) {
216 return testExitCode(marker, type, expectedExitCodes[type]); 221 return testExitCode(marker, type, expectedExitCodes[type]);
217 }); 222 });
218 } 223 }
219 224
220 void main() { 225 void main() {
221 // TODO(johnniwinther): implement this test for unchecked mode.
222 bool isCheckedMode = false; 226 bool isCheckedMode = false;
223 assert(isCheckedMode = true); 227 assert((isCheckedMode = true));
224 Expect.isTrue(isCheckedMode, 'This test must be run in checked mode.');
225 228
226 const beforeRun = const { 229 final beforeRun = {
227 '': 0, 230 '': 0,
228 'NoSuchMethodError': 253, 231 'NoSuchMethodError': 253,
229 'assert': 253, 232 'assert': isCheckedMode ? 253 : 0,
230 'invariant': 253 233 'invariant': 253
231 }; 234 };
232 235
233 const duringRun = const { 236 final duringRun = {
234 '': 0, 237 '': 0,
235 'NoSuchMethodError': 253, 238 'NoSuchMethodError': 253,
236 'assert': 253, 239 'assert': isCheckedMode ? 253 : 0,
237 'invariant': 253, 240 'invariant': 253,
238 'warning': 0, 241 'warning': 0,
239 'error': 1, 242 'error': 1,
240 'fatalError': 1, 243 'fatalError': 1,
244 'internalError': 253,
241 }; 245 };
242 246
243 const tests = const { 247 final tests = {
244 'Compiler': beforeRun, 248 'Compiler': beforeRun,
245 'Compiler.run': beforeRun, 249 'Compiler.run': beforeRun,
246 'Compiler.scanBuiltinLibraries': beforeRun, 250 'Compiler.scanBuiltinLibraries': beforeRun,
247 'Compiler.initializeSpecialClasses': beforeRun, 251 'Compiler.initializeSpecialClasses': beforeRun,
248 'ScannerTask.scanElements': duringRun, 252 'ScannerTask.scanElements': duringRun,
249 'Compiler.withCurrentElement': duringRun, 253 'Compiler.withCurrentElement': duringRun,
250 'Compiler.analyzeElement': duringRun, 254 'Compiler.analyzeElement': duringRun,
251 'Compiler.codegen': duringRun, 255 'Compiler.codegen': duringRun,
252 'ResolverTask.computeClassMembers': duringRun, 256 'ResolverTask.computeClassMembers': duringRun,
253 }; 257 };
254 258
255 asyncStart(); 259 asyncStart();
256 Future.forEach(tests.keys, (marker) { 260 Future.forEach(tests.keys, (marker) {
257 return testExitCodes(marker, tests[marker]); 261 return testExitCodes(marker, tests[marker]);
258 }).then((_) { 262 }).then((_) {
259 int countResults(Map runType) { 263 int countResults(Map runType) {
260 return runType.length * 264 return runType.length *
261 tests.values.where((r) => r == runType).length; 265 tests.values.where((r) => r == runType).length;
262 } 266 }
263 267
264 Expect.equals(countResults(beforeRun) + countResults(duringRun), 268 Expect.equals(countResults(beforeRun) + countResults(duringRun),
265 checkedResults); 269 checkedResults);
266 asyncEnd(); 270 asyncEnd();
267 }); 271 });
268 } 272 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/world.dart ('k') | tests/compiler/dart2js/mock_compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698