[DDC] Stacktrace tests

This CL copied stacktrace test ccases from dart2js and updates them
to DDC (mostly kernel version).

Some tests fail (marked in status file) because of dartbug.com/31451.

Bug:
Change-Id: If89c292eedb162fe7fe2832e909654e4ee083340
Reviewed-on: https://dart-review.googlesource.com/23500
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Jens Johansen 2017-11-24 14:05:20 +00:00
parent c69cf9312d
commit b561850fb5
20 changed files with 209 additions and 8 deletions

View file

@ -46,15 +46,16 @@ class Compile extends Step<Data, Data, ChainContext> {
class TestStackTrace extends Step<Data, Data, ChainContext> {
final DdcRunner ddcRunner;
final String marker;
final List<String> knownMarkers;
const TestStackTrace(this.ddcRunner, this.marker);
const TestStackTrace(this.ddcRunner, this.marker, this.knownMarkers);
String get name => "TestStackTrace";
Future<Result<Data>> run(Data data, ChainContext context) async {
data.outDir = await Directory.systemTemp.createTemp("stacktrace-test");
String code = await new File.fromUri(data.uri).readAsString();
Test test = processTestCode(code, [marker]);
Test test = processTestCode(code, knownMarkers);
await testStackTrace(test, marker, _compile,
jsPreambles: _getPreambles,
useJsMethodNamesOnAbsence: true,
@ -81,6 +82,7 @@ class TestStackTrace extends Step<Data, Data, ChainContext> {
if (name == null) return null;
// Hack for DDC naming scheme.
String result = name;
if (result.startsWith("new ")) result = result.substring(4);
if (result.startsWith("Object.")) result = result.substring(7);
String inputName =
INPUT_FILE_NAME.substring(0, INPUT_FILE_NAME.indexOf(".") + 1);

View file

@ -2,3 +2,11 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE.md file.
/null_interceptor_field: Crash
/throw_in_constructor: Crash
/throw_in_constructor_from_async: Crash
/throw_in_instance_method: Crash
/throw_in_async: Crash # dartbug.com/31451
/throw_in_awaited_async: Crash # dartbug.com/31451
/throw_in_top_level_method_from_async: Crash # dartbug.com/31451

View file

@ -13,7 +13,8 @@ class StackTraceContext extends ChainContextWithCleanupHelper {
final List<Step> steps = <Step>[
const Setup(),
const SetCwdToSdkRoot(),
const TestStackTrace(const ddc.RunDdc(), "ddc."),
const TestStackTrace(
const ddc.RunDdc(false), "ddc.", const ["ddc.", "ddk."]),
];
}

View file

@ -2,3 +2,7 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE.md file.
/throw_in_async: Crash # dartbug.com/31451
/throw_in_awaited_async: Crash # dartbug.com/31451
/throw_in_constructor_from_async: Crash # dartbug.com/31451
/throw_in_top_level_method_from_async: Crash # dartbug.com/31451

View file

@ -13,7 +13,8 @@ class StackTraceContext extends ChainContextWithCleanupHelper {
final List<Step> steps = <Step>[
const Setup(),
const SetCwdToSdkRoot(),
const TestStackTrace(const ddk.RunDdc(), "ddk."),
const TestStackTrace(
const ddk.RunDdc(false), "ddk.", const ["ddk.", "ddc."]),
];
}

View file

@ -0,0 +1,15 @@
// Copyright (c) 2017, 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.
main() {
/*1:main*/ test(new Class());
}
test(c) {
/*ddc.2:test*/ c.field. /*ddk.2:test*/ method();
}
class Class {
var field;
}

View file

@ -0,0 +1,16 @@
// Copyright (c) 2017, 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.
class MyType {
get length => 3; // ensures we build an interceptor for `.length`
}
main() {
confuse('').trim(); // includes some code above the interceptors
confuse([]).length;
confuse(new MyType()).length;
confuse(null). /*1:main*/ length; // called through the interceptor
}
confuse(x) => x;

View file

@ -0,0 +1,16 @@
// Copyright (c) 2017, 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.
main() {
/*1:main*/ test();
}
test() {
try {
/*2:test*/ throw '>ExceptionMarker<';
// ignore: UNUSED_CATCH_CLAUSE
} on String catch (e) {
rethrow;
}
}

View file

@ -0,0 +1,12 @@
// Copyright (c) 2017, 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.
main() {
// This call is no longer on the stack when the error is thrown.
/*:main*/ test();
}
test() async {
/*1:test*/ throw '>ExceptionMarker<';
}

View file

@ -0,0 +1,16 @@
// Copyright (c) 2017, 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.
main() {
test1();
}
test1() async {
// This call is no longer on the stack when the error is thrown.
await /*:test1*/ test2();
}
test2() async {
/*1:test2*/ throw '>ExceptionMarker<';
}

View file

@ -0,0 +1,14 @@
// Copyright (c) 2017, 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.
main() {
// ignore: UNUSED_LOCAL_VARIABLE
var c = new /*1:main*/ Class();
}
class Class {
Class() {
/*2:Class.new*/ throw '>ExceptionMarker<';
}
}

View file

@ -0,0 +1,20 @@
// Copyright (c) 2017, 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.
main() {
// This call is no longer on the stack when the error is thrown.
/*:main*/ test();
}
test() async {
// ignore: UNUSED_LOCAL_VARIABLE
var c = new /*1:test*/ Class();
}
class Class {
Class() {
// Some comment
/*2:Class.new*/ throw '>ExceptionMarker<';
}
}

View file

@ -0,0 +1,14 @@
// Copyright (c) 2017, 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.
main() {
var c = new Class();
c. /*1:main*/ test();
}
class Class {
test() {
/*2:Class.new.test*/ throw '>ExceptionMarker<';
}
}

View file

@ -0,0 +1,7 @@
// Copyright (c) 2017, 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.
main() {
/*1:main*/ throw '>ExceptionMarker<';
}

View file

@ -0,0 +1,13 @@
// Copyright (c) 2017, 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.
main() {
/*ddc.1:main*/ Class. /*ddk.1:main*/ test();
}
class Class {
static test() {
/*2:Function.test*/ throw '>ExceptionMarker<';
}
}

View file

@ -2,13 +2,10 @@
// 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.
import 'package:expect/expect.dart';
main() {
/*1:main*/ test();
}
@NoInline()
test() {
/*2:test*/ throw 'throw me';
}

View file

@ -0,0 +1,15 @@
// Copyright (c) 2017, 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.
main() {
test1();
}
test1() async {
/*1:test1*/ test2();
}
test2() {
/*2:test2*/ throw '>ExceptionMarker<';
}

View file

@ -0,0 +1,14 @@
// Copyright (c) 2017, 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.
main() {
/*1:main*/ test();
}
test() {
try {
/*2:test*/ throw '>ExceptionMarker<';
// ignore: UNUSED_CATCH_CLAUSE
} on Error catch (e) {}
}

View file

@ -0,0 +1,13 @@
// Copyright (c) 2017, 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.
main() {
/*1:main*/ test();
}
test() {
try {
/*2:test*/ throw '>ExceptionMarker<';
} finally {}
}

View file

@ -144,7 +144,10 @@ Future testStackTrace(Test test, String config, CompileFunc compile,
List<StackTraceLine> jsStackTrace = <StackTraceLine>[];
for (String line in lines) {
if (line.startsWith(' at ')) {
jsStackTrace.add(new StackTraceLine.fromText(line));
StackTraceLine stackTraceLine = new StackTraceLine.fromText(line);
if (stackTraceLine.lineNo != null && stackTraceLine.columnNo != null) {
jsStackTrace.add(stackTraceLine);
}
}
}