19e56613cf
Extend test_runner VMOptions support with an ability to specify
paths relative to temporary compilation directory.
// VMOptions=--foo=$TEST_COMPILATION_DIR/foo.file
The same directory will also be passed as an environment variable
to execution command.
Migrate most of the tests which used to write stuff into the SDK
root to use this feature. I am leaving vm/dart/causal/* tests
unmigrated because migrating requires time consuming manual
update of expectations (which encode raw line numbers). I have
a follow up CL which changes how these tests are written which
will make migration trivial.
Change-Id: Id53008be66de8ff18623efac27ff15750f407749
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300600
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
54 lines
1.7 KiB
Dart
54 lines
1.7 KiB
Dart
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
//
|
|
// VMOptions=--dwarf-stack-traces --save-debugging-info=$TEST_COMPILATION_DIR/socket_connect_debug.so
|
|
//
|
|
// Tests stack trace on socket exceptions.
|
|
//
|
|
|
|
import "dart:async";
|
|
import "dart:convert";
|
|
import "dart:io";
|
|
|
|
import "package:async_helper/async_helper.dart";
|
|
import "package:expect/expect.dart";
|
|
import "package:native_stack_traces/native_stack_traces.dart";
|
|
import "package:path/path.dart" as path;
|
|
|
|
Future<List<String>> findFrames(
|
|
Dwarf dwarf, RegExp re, StackTrace stackTrace) async {
|
|
final dwarfed = await Stream.value(stackTrace.toString())
|
|
.transform(const LineSplitter())
|
|
.toList();
|
|
return Stream.fromIterable(dwarfed)
|
|
.transform(DwarfStackTraceDecoder(dwarf))
|
|
.where(re.hasMatch)
|
|
.toList();
|
|
}
|
|
|
|
Future<void> main() async {
|
|
asyncStart();
|
|
final dwarf = Dwarf.fromFile(path.join(
|
|
Platform.environment['TEST_COMPILATION_DIR']!,
|
|
'socket_connect_debug.so'))!;
|
|
// Test stacktrace when lookup fails
|
|
try {
|
|
await WebSocket.connect('ws://localhost.tld:0/ws');
|
|
} catch (err, stackTrace) {
|
|
Expect.contains('Failed host lookup', err.toString());
|
|
final decoded = await findFrames(dwarf, RegExp("main"), stackTrace);
|
|
Expect.equals(1, decoded.length);
|
|
}
|
|
|
|
// Test stacktrace when connection fails
|
|
try {
|
|
await WebSocket.connect('ws://localhost:0/ws');
|
|
} catch (err, stackTrace) {
|
|
Expect.contains('was not upgraded to websocket', err.toString());
|
|
final decoded = await findFrames(dwarf, RegExp("main"), stackTrace);
|
|
Expect.equals(1, decoded.length);
|
|
}
|
|
asyncEnd();
|
|
}
|