Enable Travis, rename analysis_options, update .gitignore (#3)
* Enable Travis, rename analysis_options, update .gitignore
* dartfmt
diff --git a/.gitignore b/.gitignore
index 25a1df3..f73b2f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,4 @@
-.buildlog
-.DS_Store
-.idea
-.pub/
-.settings/
-build/
-packages
+.dart_tool/
.packages
+.pub/
pubspec.lock
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..3895dfc
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,27 @@
+language: dart
+
+# trying to get chrome working
+sudo: true
+
+dart:
+ - dev
+ - stable
+
+dart_task:
+ - test: -p chrome,vm
+
+matrix:
+ include:
+ # Only validate formatting using the dev release
+ - dart: dev
+ dart_task: dartfmt
+ - dart: dev
+ dart_task: analyzer
+
+# Only building master means that we don't run two builds for each pull request.
+branches:
+ only: [master]
+
+cache:
+ directories:
+ - $HOME/.pub-cache
diff --git a/.analysis_options b/analysis_options.yaml
similarity index 100%
rename from .analysis_options
rename to analysis_options.yaml
diff --git a/lib/source_map_stack_trace.dart b/lib/source_map_stack_trace.dart
index c9e49f2..d0252e0 100644
--- a/lib/source_map_stack_trace.dart
+++ b/lib/source_map_stack_trace.dart
@@ -23,7 +23,9 @@
/// [packageRoot] is deprecated and shouldn't be used in new code. This throws
/// an [ArgumentError] if [packageRoot] and [packageResolver] are both passed.
StackTrace mapStackTrace(Mapping sourceMap, StackTrace stackTrace,
- {bool minified: false, SyncPackageResolver packageResolver, sdkRoot,
+ {bool minified: false,
+ SyncPackageResolver packageResolver,
+ sdkRoot,
@Deprecated("Use the packageResolver parameter instead.") packageRoot}) {
if (packageRoot != null) {
if (packageResolver != null) {
@@ -36,8 +38,7 @@
if (stackTrace is Chain) {
return new Chain(stackTrace.traces.map((trace) {
- return new Trace.from(mapStackTrace(
- sourceMap, trace,
+ return new Trace.from(mapStackTrace(sourceMap, trace,
minified: minified,
packageResolver: packageResolver,
sdkRoot: sdkRoot));
@@ -75,15 +76,16 @@
} else if (packageResolver != null) {
if (packageResolver.packageRoot != null &&
p.url.isWithin(packageResolver.packageRoot.toString(), sourceUrl)) {
- sourceUrl = "package:" + p.url.relative(sourceUrl,
- from: packageResolver.packageRoot.toString());
+ sourceUrl = "package:" +
+ p.url.relative(sourceUrl,
+ from: packageResolver.packageRoot.toString());
} else if (packageResolver.packageConfigMap != null) {
for (var package in packageResolver.packageConfigMap.keys) {
var packageUrl = packageResolver.packageConfigMap[package].toString();
if (!p.url.isWithin(packageUrl, sourceUrl)) continue;
- sourceUrl = "package:$package/" +
- p.url.relative(sourceUrl, from: packageUrl);
+ sourceUrl =
+ "package:$package/" + p.url.relative(sourceUrl, from: packageUrl);
break;
}
}
@@ -110,7 +112,8 @@
// Get rid of arity indicators and named arguments.
.replaceAll(new RegExp(r"\$\d+(\$[a-zA-Z_0-9]+)*$"), "")
// Convert closures to <fn>.
- .replaceAllMapped(new RegExp(r"(_+)closure\d*\.call$"),
+ .replaceAllMapped(
+ new RegExp(r"(_+)closure\d*\.call$"),
// The number of underscores before "closure" indicates how nested it
// is.
(match) => ".<fn>" * match[1].length)
@@ -126,6 +129,6 @@
// Convert underscores after identifiers to dots. This runs the risk of
// incorrectly converting members that contain underscores, but those are
// contrary to the style guide anyway.
- .replaceAllMapped(new RegExp(r"([a-zA-Z0-9]+)_"),
- (match) => match[1] + ".");
+ .replaceAllMapped(
+ new RegExp(r"([a-zA-Z0-9]+)_"), (match) => match[1] + ".");
}
diff --git a/pubspec.yaml b/pubspec.yaml
index f890ed7..c103c6c 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: source_map_stack_trace
-version: 1.1.4
+version: 1.1.5-dev
description: >
A package for applying source maps to stack traces.
author: Dart Team <misc@dartlang.org>
diff --git a/test/source_map_stack_trace_test.dart b/test/source_map_stack_trace_test.dart
index 14ec86b..18a5652 100644
--- a/test/source_map_stack_trace_test.dart
+++ b/test/source_map_stack_trace_test.dart
@@ -11,18 +11,14 @@
import 'package:test/test.dart';
/// A simple [Mapping] for tests that don't need anything special.
-final _simpleMapping = parseJson(
- (new SourceMapBuilder()
- ..addSpan(
- new SourceMapSpan.identifier(
- new SourceLocation(1,
- line: 1, column: 3, sourceUrl: "foo.dart"),
- "qux"),
- new SourceSpan(
- new SourceLocation(8, line: 5, column: 0),
- new SourceLocation(18, line: 15, column: 0),
- "\n" * 10)))
- .build("foo.dart.js.map"));
+final _simpleMapping = parseJson((new SourceMapBuilder()
+ ..addSpan(
+ new SourceMapSpan.identifier(
+ new SourceLocation(1, line: 1, column: 3, sourceUrl: "foo.dart"),
+ "qux"),
+ new SourceSpan(new SourceLocation(8, line: 5, column: 0),
+ new SourceLocation(18, line: 15, column: 0), "\n" * 10)))
+ .build("foo.dart.js.map"));
void main() {
test("maps a JS line and column to a Dart line and span", () {
@@ -63,8 +59,7 @@
expect(frames.last.member, equals("baz"));
});
- test("include frames from JS files not covered by the source map bundle",
- () {
+ test("include frames from JS files not covered by the source map bundle", () {
var trace = new Trace.parse("""
foo.dart.js 10:11 foo
jquery.js 10:1 foo
@@ -118,15 +113,12 @@
test("falls back to column 0 for unlisted column", () {
var trace = new Trace.parse("foo.dart.js 10 foo");
var builder = new SourceMapBuilder()
- ..addSpan(
- new SourceMapSpan.identifier(
- new SourceLocation(1,
- line: 1, column: 3, sourceUrl: "foo.dart"),
- "qux"),
- new SourceSpan(
- new SourceLocation(8, line: 5, column: 0),
- new SourceLocation(12, line: 9, column: 1),
- "\n" * 4));
+ ..addSpan(
+ new SourceMapSpan.identifier(
+ new SourceLocation(1, line: 1, column: 3, sourceUrl: "foo.dart"),
+ "qux"),
+ new SourceSpan(new SourceLocation(8, line: 5, column: 0),
+ new SourceLocation(12, line: 9, column: 1), "\n" * 4));
var mapping = parseJson(builder.build("foo.dart.js.map"));
var frame = _mapTrace(mapping, trace).frames.first;
@@ -138,19 +130,17 @@
test("uses package: URIs for frames within packageRoot", () {
var trace = new Trace.parse("foo.dart.js 10 foo");
var builder = new SourceMapBuilder()
- ..addSpan(
- new SourceMapSpan.identifier(
- new SourceLocation(1,
- line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"),
- "qux"),
- new SourceSpan(
- new SourceLocation(8, line: 5, column: 0),
- new SourceLocation(12, line: 9, column: 1),
- "\n" * 4));
+ ..addSpan(
+ new SourceMapSpan.identifier(
+ new SourceLocation(1,
+ line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"),
+ "qux"),
+ new SourceSpan(new SourceLocation(8, line: 5, column: 0),
+ new SourceLocation(12, line: 9, column: 1), "\n" * 4));
var mapping = parseJson(builder.build("foo.dart.js.map"));
- var frame = _mapTrace(mapping, trace, packageRoot: "packages/")
- .frames.first;
+ var frame =
+ _mapTrace(mapping, trace, packageRoot: "packages/").frames.first;
expect(frame.uri, equals(Uri.parse("package:foo/foo.dart")));
expect(frame.line, equals(2));
expect(frame.column, equals(4));
@@ -159,15 +149,13 @@
test("uses package: URIs for frames within packageResolver.packageRoot", () {
var trace = new Trace.parse("foo.dart.js 10 foo");
var builder = new SourceMapBuilder()
- ..addSpan(
- new SourceMapSpan.identifier(
- new SourceLocation(1,
- line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"),
- "qux"),
- new SourceSpan(
- new SourceLocation(8, line: 5, column: 0),
- new SourceLocation(12, line: 9, column: 1),
- "\n" * 4));
+ ..addSpan(
+ new SourceMapSpan.identifier(
+ new SourceLocation(1,
+ line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"),
+ "qux"),
+ new SourceSpan(new SourceLocation(8, line: 5, column: 0),
+ new SourceLocation(12, line: 9, column: 1), "\n" * 4));
var mapping = parseJson(builder.build("foo.dart.js.map"));
var mappedTrace = _mapTrace(mapping, trace,
@@ -182,21 +170,18 @@
() {
var trace = new Trace.parse("foo.dart.js 10 foo");
var builder = new SourceMapBuilder()
- ..addSpan(
- new SourceMapSpan.identifier(
- new SourceLocation(1,
- line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"),
- "qux"),
- new SourceSpan(
- new SourceLocation(8, line: 5, column: 0),
- new SourceLocation(12, line: 9, column: 1),
- "\n" * 4));
+ ..addSpan(
+ new SourceMapSpan.identifier(
+ new SourceLocation(1,
+ line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"),
+ "qux"),
+ new SourceSpan(new SourceLocation(8, line: 5, column: 0),
+ new SourceLocation(12, line: 9, column: 1), "\n" * 4));
var mapping = parseJson(builder.build("foo.dart.js.map"));
var mappedTrace = _mapTrace(mapping, trace,
- packageResolver: new SyncPackageResolver.config({
- "foo": Uri.parse("packages/foo")
- }));
+ packageResolver:
+ new SyncPackageResolver.config({"foo": Uri.parse("packages/foo")}));
var frame = mappedTrace.frames.first;
expect(frame.uri, equals(Uri.parse("package:foo/foo.dart")));
expect(frame.line, equals(2));
@@ -206,15 +191,13 @@
test("uses dart: URIs for frames within sdkRoot", () {
var trace = new Trace.parse("foo.dart.js 10 foo");
var builder = new SourceMapBuilder()
- ..addSpan(
- new SourceMapSpan.identifier(
- new SourceLocation(1,
- line: 1, column: 3, sourceUrl: "sdk/lib/async/foo.dart"),
- "qux"),
- new SourceSpan(
- new SourceLocation(8, line: 5, column: 0),
- new SourceLocation(12, line: 9, column: 1),
- "\n" * 4));
+ ..addSpan(
+ new SourceMapSpan.identifier(
+ new SourceLocation(1,
+ line: 1, column: 3, sourceUrl: "sdk/lib/async/foo.dart"),
+ "qux"),
+ new SourceSpan(new SourceLocation(8, line: 5, column: 0),
+ new SourceLocation(12, line: 9, column: 1), "\n" * 4));
var mapping = parseJson(builder.build("foo.dart.js.map"));
var frame = _mapTrace(mapping, trace, sdkRoot: "sdk/").frames.first;
@@ -265,8 +248,8 @@
test("nested closures", () {
expect(_prettify("foo__closure.call"), equals("foo.<fn>.<fn>"));
- expect(_prettify("foo____closure.call"),
- equals("foo.<fn>.<fn>.<fn>.<fn>"));
+ expect(
+ _prettify("foo____closure.call"), equals("foo.<fn>.<fn>.<fn>.<fn>"));
});
test(".call", () {
@@ -299,20 +282,28 @@
/// Like [mapStackTrace], but is guaranteed to return a [Trace] so it can be
/// inspected.
Trace _mapTrace(Mapping sourceMap, StackTrace stackTrace,
- {bool minified: false, SyncPackageResolver packageResolver, sdkRoot,
+ {bool minified: false,
+ SyncPackageResolver packageResolver,
+ sdkRoot,
packageRoot}) {
return new Trace.from(mapStackTrace(sourceMap, stackTrace,
- minified: minified, packageResolver: packageResolver, sdkRoot: sdkRoot,
+ minified: minified,
+ packageResolver: packageResolver,
+ sdkRoot: sdkRoot,
packageRoot: packageRoot));
}
/// Like [mapStackTrace], but is guaranteed to return a [Chain] so it can be
/// inspected.
Chain _mapChain(Mapping sourceMap, StackTrace stackTrace,
- {bool minified: false, SyncPackageResolver packageResolver, sdkRoot,
+ {bool minified: false,
+ SyncPackageResolver packageResolver,
+ sdkRoot,
packageRoot}) {
return new Chain.forTrace(mapStackTrace(sourceMap, stackTrace,
- minified: minified, packageResolver: packageResolver, sdkRoot: sdkRoot,
+ minified: minified,
+ packageResolver: packageResolver,
+ sdkRoot: sdkRoot,
packageRoot: packageRoot));
}