set up stack trace mappers in precompiled mode if source maps exist (#1378)
diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md
index 3afab02..4be8718 100644
--- a/pkgs/test/CHANGELOG.md
+++ b/pkgs/test/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 1.16.0-nullsafety.11
+
+* Set up a stack trace mapper in precompiled mode if source maps exist. If
+ the stack traces are already mapped then this has no effect, otherwise it
+ will try to map any JS lines it sees.
+
## 1.16.0-nullsafety.10
* Allow injecting a test channel for browser tests.
diff --git a/pkgs/test/lib/src/runner/browser/platform.dart b/pkgs/test/lib/src/runner/browser/platform.dart
index d0e88a0..1af5dab 100644
--- a/pkgs/test/lib/src/runner/browser/platform.dart
+++ b/pkgs/test/lib/src/runner/browser/platform.dart
@@ -259,6 +259,8 @@
if (browser.isJS) {
if (suiteConfig.precompiledPath == null) {
await _compileSuite(path, suiteConfig);
+ } else {
+ await _addPrecompiledStackTraceMapper(path, suiteConfig);
}
}
@@ -410,6 +412,20 @@
});
}
+ Future<void> _addPrecompiledStackTraceMapper(
+ String dartPath, SuiteConfiguration suiteConfig) async {
+ if (suiteConfig.jsTrace) return;
+ var mapPath = p.join(
+ suiteConfig.precompiledPath, dartPath + '.browser_test.dart.js.map');
+ var mapFile = File(mapPath);
+ if (mapFile.existsSync()) {
+ _mappers[dartPath] = JSStackTraceMapper(mapFile.readAsStringSync(),
+ mapUrl: p.toUri(mapPath),
+ sdkRoot: Uri.parse(r'/packages/$sdk'),
+ packageMap: (await currentPackageConfig).toPackageMap());
+ }
+ }
+
/// Returns the [BrowserManager] for [runtime], which should be a browser.
///
/// If no browser manager is running yet, starts one.
diff --git a/pkgs/test/pubspec.yaml b/pkgs/test/pubspec.yaml
index b182206..5d35fb7 100644
--- a/pkgs/test/pubspec.yaml
+++ b/pkgs/test/pubspec.yaml
@@ -1,5 +1,5 @@
name: test
-version: 1.16.0-nullsafety.10
+version: 1.16.0-nullsafety.11
description: A full featured library for writing and running Dart tests.
homepage: https://github.com/dart-lang/test/blob/master/pkgs/test