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

Side by Side Diff: test/source_map_stack_trace_test.dart

Issue 2555223004: Fix behavior causing frames lacking a source map to always be omitted. Add `includeUnmappedFrames` … (Closed)
Patch Set: Support extended source maps. Created 4 years 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
« pubspec.yaml ('K') | « pubspec.yaml ('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 import 'package:package_resolver/package_resolver.dart'; 5 import 'package:package_resolver/package_resolver.dart';
6 import 'package:path/path.dart' as p;
6 import 'package:source_maps/source_maps.dart'; 7 import 'package:source_maps/source_maps.dart';
7 import 'package:source_span/source_span.dart'; 8 import 'package:source_span/source_span.dart';
8 import 'package:stack_trace/stack_trace.dart'; 9 import 'package:stack_trace/stack_trace.dart';
9 import 'package:source_map_stack_trace/source_map_stack_trace.dart'; 10 import 'package:source_map_stack_trace/source_map_stack_trace.dart';
10 import 'package:test/test.dart'; 11 import 'package:test/test.dart';
11 12
12 /// A simple [Mapping] for tests that don't need anything special. 13 /// A simple [Mapping] for tests that don't need anything special.
13 final _simpleMapping = parseJson( 14 final _simpleMapping = parseJson(
14 (new SourceMapBuilder() 15 (new SourceMapBuilder()
15 ..addSpan( 16 ..addSpan(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 foo.dart.js 10:11 baz 56 foo.dart.js 10:11 baz
56 """); 57 """);
57 58
58 var frames = _mapTrace(_simpleMapping, trace).frames; 59 var frames = _mapTrace(_simpleMapping, trace).frames;
59 60
60 expect(frames.length, equals(2)); 61 expect(frames.length, equals(2));
61 expect(frames.first.member, equals("foo")); 62 expect(frames.first.member, equals("foo"));
62 expect(frames.last.member, equals("baz")); 63 expect(frames.last.member, equals("baz"));
63 }); 64 });
64 65
66 test("include JS frames from external libraries with source map bundle", () {
67 var trace = new Trace.parse("""
68 foo.dart.js 10:11 foo
69 jquery.js 10:1 foo
70 """);
71 var builder = new SourceMapBuilder()
72 ..addSpan(
73 new SourceMapSpan.identifier(
74 new SourceLocation(1,
75 line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"),
76 "qux"),
77 new SourceSpan(new SourceLocation(8, line: 5, column: 0),
78 new SourceLocation(12, line: 9, column: 1), "\n" * 4));
79 var sourceMapJson = builder.build("foo.dart.js.map");
80 sourceMapJson['file'] = "foo.dart.js";
81
82 var bundle = [sourceMapJson];
83 var mapping = parseJsonExtended(bundle);
84 var frames = _mapTrace(mapping, trace,
85 packageResolver: new SyncPackageResolver.root("packages/"))
86 .frames;
87
88 expect(frames.length, equals(2));
89
90 var frame = frames.first;
91 expect(frame.uri, equals(Uri.parse("package:foo/foo.dart")));
92 expect(frame.line, equals(2));
93 expect(frame.column, equals(4));
94
95 frame = frames.last;
96 expect(p.basename(frame.uri.toString()), equals("jquery.js"));
97 expect(frame.line, equals(10));
98 });
99
65 test("falls back to column 0 for unlisted column", () { 100 test("falls back to column 0 for unlisted column", () {
66 var trace = new Trace.parse("foo.dart.js 10 foo"); 101 var trace = new Trace.parse("foo.dart.js 10 foo");
67 var builder = new SourceMapBuilder() 102 var builder = new SourceMapBuilder()
68 ..addSpan( 103 ..addSpan(
69 new SourceMapSpan.identifier( 104 new SourceMapSpan.identifier(
70 new SourceLocation(1, 105 new SourceLocation(1,
71 line: 1, column: 3, sourceUrl: "foo.dart"), 106 line: 1, column: 3, sourceUrl: "foo.dart"),
72 "qux"), 107 "qux"),
73 new SourceSpan( 108 new SourceSpan(
74 new SourceLocation(8, line: 5, column: 0), 109 new SourceLocation(8, line: 5, column: 0),
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 return new Chain.forTrace(mapStackTrace(sourceMap, stackTrace, 296 return new Chain.forTrace(mapStackTrace(sourceMap, stackTrace,
262 minified: minified, packageResolver: packageResolver, sdkRoot: sdkRoot, 297 minified: minified, packageResolver: packageResolver, sdkRoot: sdkRoot,
263 packageRoot: packageRoot)); 298 packageRoot: packageRoot));
264 } 299 }
265 300
266 /// Runs the mapper's prettification logic on [member] and returns the result. 301 /// Runs the mapper's prettification logic on [member] and returns the result.
267 String _prettify(String member) { 302 String _prettify(String member) {
268 var trace = new Trace([new Frame(Uri.parse("foo.dart.js"), 10, 11, member)]); 303 var trace = new Trace([new Frame(Uri.parse("foo.dart.js"), 10, 11, member)]);
269 return _mapTrace(_simpleMapping, trace).frames.first.member; 304 return _mapTrace(_simpleMapping, trace).frames.first.member;
270 } 305 }
OLDNEW
« pubspec.yaml ('K') | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698