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

Side by Side Diff: tests/compiler/dart2js/sourcemaps/stacktrace_test.dart

Issue 2654023003: Add no-info mappings at start of out.js and after mapped functions (Closed)
Patch Set: fixes Created 3 years, 10 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 | « tests/compiler/dart2js/sourcemaps/sourcemap_visualizer.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:async_helper/async_helper.dart'; 9 import 'package:async_helper/async_helper.dart';
10 import 'package:compiler/compiler_new.dart'; 10 import 'package:compiler/compiler_new.dart';
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 try { 110 try {
111 @{2:test}throw '$EXCEPTION_MARKER'; 111 @{2:test}throw '$EXCEPTION_MARKER';
112 } on String catch (e) { 112 } on String catch (e) {
113 rethrow; 113 rethrow;
114 } 114 }
115 } 115 }
116 ''', 116 ''',
117 ''' 117 '''
118 import 'package:expect/expect.dart'; 118 import 'package:expect/expect.dart';
119 main() { 119 main() {
120 @{1:main}test(new Class());
121 }
122 @NoInline()
123 test(c) {
124 @{2:test}c.field.method();
125 }
126 class Class {
127 var field;
128 }
129 ''',
130 '''
131 import 'package:expect/expect.dart';
132 main() {
120 // This call is no longer on the stack when the error is thrown. 133 // This call is no longer on the stack when the error is thrown.
121 @{:main}test(); 134 @{:main}test();
122 } 135 }
123 @NoInline() 136 @NoInline()
124 test() async { 137 test() async {
125 @{1:test}throw '$EXCEPTION_MARKER'; 138 @{1:test}throw '$EXCEPTION_MARKER';
126 } 139 }
127 ''', 140 ''',
128 ''' 141 '''
129 import 'package:expect/expect.dart'; 142 import 'package:expect/expect.dart';
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 print("Running d8 $output"); 283 print("Running d8 $output");
271 ProcessResult runResult = Process.runSync(d8executable, 284 ProcessResult runResult = Process.runSync(d8executable,
272 ['sdk/lib/_internal/js_runtime/lib/preambles/d8.js', output]); 285 ['sdk/lib/_internal/js_runtime/lib/preambles/d8.js', output]);
273 String out = '${runResult.stderr}\n${runResult.stdout}'; 286 String out = '${runResult.stderr}\n${runResult.stdout}';
274 if (verbose) { 287 if (verbose) {
275 print('d8 output:'); 288 print('d8 output:');
276 print(out); 289 print(out);
277 } 290 }
278 List<String> lines = out.split(new RegExp(r'(\r|\n|\r\n)')); 291 List<String> lines = out.split(new RegExp(r'(\r|\n|\r\n)'));
279 List<StackTraceLine> jsStackTrace = <StackTraceLine>[]; 292 List<StackTraceLine> jsStackTrace = <StackTraceLine>[];
280 bool seenMarker = false;
281 for (String line in lines) { 293 for (String line in lines) {
282 if (seenMarker) { 294 if (line.startsWith(' at ')) {
283 line = line.trim(); 295 jsStackTrace.add(new StackTraceLine.fromText(line));
284 if (line.startsWith('at ')) {
285 jsStackTrace.add(new StackTraceLine.fromText(line));
286 }
287 } else if (line == EXCEPTION_MARKER) {
288 seenMarker = true;
289 } 296 }
290 } 297 }
291 298
292 List<StackTraceLine> dartStackTrace = <StackTraceLine>[]; 299 List<StackTraceLine> dartStackTrace = <StackTraceLine>[];
293 for (StackTraceLine line in jsStackTrace) { 300 for (StackTraceLine line in jsStackTrace) {
294 TargetEntry targetEntry = _findColumn(line.lineNo - 1, line.columnNo - 1, 301 TargetEntry targetEntry = _findColumn(line.lineNo - 1, line.columnNo - 1,
295 _findLine(sourceMap, line.lineNo - 1)); 302 _findLine(sourceMap, line.lineNo - 1));
296 if (targetEntry == null) { 303 if (targetEntry == null || targetEntry.sourceUrlId == null) {
297 dartStackTrace.add(line); 304 dartStackTrace.add(line);
298 } else { 305 } else {
299 String methodName; 306 String methodName;
300 if (targetEntry.sourceNameId != 0) { 307 if (targetEntry.sourceNameId != null) {
301 methodName = sourceMap.names[targetEntry.sourceNameId]; 308 methodName = sourceMap.names[targetEntry.sourceNameId];
302 } 309 }
303 String fileName; 310 String fileName;
304 if (targetEntry.sourceUrlId != 0) { 311 if (targetEntry.sourceUrlId != null) {
305 fileName = sourceMap.urls[targetEntry.sourceUrlId]; 312 fileName = sourceMap.urls[targetEntry.sourceUrlId];
306 } 313 }
307 dartStackTrace.add(new StackTraceLine(methodName, fileName, 314 dartStackTrace.add(new StackTraceLine(methodName, fileName,
308 targetEntry.sourceLine + 1, targetEntry.sourceColumn + 1)); 315 targetEntry.sourceLine + 1, targetEntry.sourceColumn + 1));
309 } 316 }
310 } 317 }
311 318
312 int expectedIndex = 0; 319 int expectedIndex = 0;
313 List<StackTraceLine> unexpectedLines = <StackTraceLine>[]; 320 List<StackTraceLine> unexpectedLines = <StackTraceLine>[];
314 for (StackTraceLine line in dartStackTrace) { 321 for (StackTraceLine line in dartStackTrace) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 String get d8executable { 471 String get d8executable {
465 if (Platform.isWindows) { 472 if (Platform.isWindows) {
466 return 'third_party/d8/windows/d8.exe'; 473 return 'third_party/d8/windows/d8.exe';
467 } else if (Platform.isLinux) { 474 } else if (Platform.isLinux) {
468 return 'third_party/d8/linux/d8'; 475 return 'third_party/d8/linux/d8';
469 } else if (Platform.isMacOS) { 476 } else if (Platform.isMacOS) {
470 return 'third_party/d8/macos/d8'; 477 return 'third_party/d8/macos/d8';
471 } 478 }
472 throw new UnsupportedError('Unsupported platform.'); 479 throw new UnsupportedError('Unsupported platform.');
473 } 480 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/sourcemaps/sourcemap_visualizer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698