Skip to content

Commit

Permalink
Remove usages of StackTraceMapper (#50153)
Browse files Browse the repository at this point in the history
* Remove usages of StackTraceMapper

This class will be replaced with a function type in `test_api`, clean up
usages ahead of time.

In `build_script.dart` the only reference to `StackTraceMapper` is in
the `browser_test.dart` file, but since nothing would call
`setStackTraceMapper` from that import it should be safe to remove the
definition. After reading a serialized mapper from the
`test.browser.mapper` channel, it was ignored.

In `flutter_web_platform.dart` we only were reading from `_mappers`,
never putting values in, so we can remove it entirely. The `load()`
function was never called with a `mapper` argument.
  • Loading branch information
natebosch committed Feb 6, 2020
1 parent 81525fa commit 8159178
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
18 changes: 1 addition & 17 deletions packages/flutter_tools/lib/src/build_runner/build_script.dart
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ import 'dart:js';
import 'package:stream_channel/stream_channel.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:test_api/src/backend/stack_trace_formatter.dart'; // ignore: implementation_imports
import 'package:test_api/src/util/stack_trace_mapper.dart'; // ignore: implementation_imports
import 'package:test_api/src/remote_listener.dart'; // ignore: implementation_imports
import 'package:test_api/src/suite_channel_manager.dart'; // ignore: implementation_imports
Expand All @@ -289,12 +288,7 @@ Future<void> main() async {
}
void internalBootstrapBrowserTest(Function getMain()) {
var channel =
serializeSuite(getMain, hidePrints: false, beforeLoad: () async {
var serialized =
await suiteChannel("test.browser.mapper").stream.first as Map;
if (serialized == null) return;
});
var channel = serializeSuite(getMain, hidePrints: false);
postMessageChannel().pipe(channel);
}
StreamChannel serializeSuite(Function getMain(),
Expand Down Expand Up @@ -335,16 +329,6 @@ StreamChannel postMessageChannel() {
]);
return controller.foreign;
}
void setStackTraceMapper(StackTraceMapper mapper) {
var formatter = StackTraceFormatter.current;
if (formatter == null) {
throw StateError(
'setStackTraceMapper() may only be called within a test worker.');
}
formatter.configure(mapper: mapper);
}
''');
}
}
Expand Down
12 changes: 3 additions & 9 deletions packages/flutter_tools/lib/src/test/flutter_web_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import 'package:shelf_web_socket/shelf_web_socket.dart';
import 'package:stream_channel/stream_channel.dart';
import 'package:test_api/src/backend/runtime.dart';
import 'package:test_api/src/backend/suite_platform.dart';
import 'package:test_api/src/util/stack_trace_mapper.dart';
import 'package:test_core/src/runner/configuration.dart';
import 'package:test_core/src/runner/environment.dart';
import 'package:test_core/src/runner/platform.dart';
Expand Down Expand Up @@ -301,9 +300,6 @@ class FlutterWebPlatform extends PlatformPlugin {
final Map<Runtime, Future<BrowserManager>> _browserManagers =
<Runtime, Future<BrowserManager>>{};

// Mappers for Dartifying stack traces, indexed by test path.
final Map<String, StackTraceMapper> _mappers = <String, StackTraceMapper>{};

// A handler that serves wrapper files used to bootstrap tests.
shelf.Response _wrapperHandler(shelf.Request request) {
final String path = globals.fs.path.fromUri(request.url);
Expand Down Expand Up @@ -346,7 +342,7 @@ class FlutterWebPlatform extends PlatformPlugin {
globals.fs.path.relative(path, from: globals.fs.path.join(_root, 'test'))) +
'.html'));
final RunnerSuite suite = await browserManager
.load(path, suiteUrl, suiteConfig, message, mapper: _mappers[path]);
.load(path, suiteUrl, suiteConfig, message);
if (_closed) {
return null;
}
Expand Down Expand Up @@ -696,9 +692,8 @@ class BrowserManager {
String path,
Uri url,
SuiteConfiguration suiteConfig,
Object message, {
StackTraceMapper mapper,
}) async {
Object message,
) async {
url = url.replace(fragment: Uri.encodeFull(jsonEncode(<String, Object>{
'metadata': suiteConfig.metadata.serialize(),
'browser': _runtime.identifier,
Expand Down Expand Up @@ -737,7 +732,6 @@ class BrowserManager {
try {
controller = deserializeSuite(path, SuitePlatform(Runtime.chrome),
suiteConfig, await _environment, suiteChannel, message);
controller.channel('test.browser.mapper').sink.add(mapper?.serialize());

_controllers.add(controller);
return await controller.suite;
Expand Down

0 comments on commit 8159178

Please sign in to comment.