Skip to content

Commit

Permalink
[stable][ddc] Cleanup sourcemap and stacktrace tests
Browse files Browse the repository at this point in the history
- Remove all refrences to "ddk" vs "ddc".
- Update throw_in_instance_method to reflect the current sourcemappings
  and start running the test again.

Issue: #51481
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/279473
Change-Id: I7bb30149e83938498d6d95cf52f14c66441d798f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285921
Reviewed-by: Alexander Thomas <athom@google.com>
  • Loading branch information
nshahan authored and athomas committed Feb 28, 2023
1 parent da32dab commit 739ad03
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 30 deletions.
6 changes: 3 additions & 3 deletions pkg/dev_compiler/test/sourcemap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ See `README.md` in `pkg/sourcemap_testing`.

One can filter which tests are run by running (from the sourcemap folder):
```
dart sourcemaps_ddk_suite.dart -- sourcemaps_ddk/printing_class_fields
dart sourcemaps_suite.dart -- sourcemaps/printing_class_fields
```

One can additionally get debug output for failing tests (i.e. tests with different outcome than
expected), e.g.:
```
dart sourcemaps_ddk_suite.dart -Ddebug=true -- sourcemaps_ddk/printing_class_fields
dart sourcemaps_suite.dart -Ddebug=true -- sourcemaps/printing_class_fields
```

The latter is also useful in combination with `/*fail*/` when adding new tests to see all the places
where the debugger stopped (both in JS positions and translated to dart positions).

For instance `-Ddebug=true -- sourcemaps_ddk/next_through_catch_test` with a `/*fail*/`
For instance `-Ddebug=true -- sourcemaps/next_through_catch_test` with a `/*fail*/`
currently gives output like the following:

```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# 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.md file.

throw_in_instance_method: Crash # Test works, but DDC's hover support means the expected column in the test is wrong
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:testing/testing.dart';

import 'common.dart';
import 'ddc_common.dart';
import 'sourcemaps_ddk_suite.dart' as ddk;
import 'sourcemaps_suite.dart';

Future<ChainContext> createContext(
Chain suite, Map<String, String> environment) async {
Expand All @@ -26,8 +26,7 @@ class StackTraceContext extends ChainContextWithCleanupHelper
return _steps ??= <Step>[
const Setup(),
const SetCwdToSdkRoot(),
TestStackTrace(ddk.DevCompilerRunner(this, debugging: false), 'ddk',
const ['ddk', 'ddc']),
TestStackTrace(DevCompilerRunner(this, debugging: false), 'ddc', ['ddc']),
];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void main() {
}

void test(c) {
/*ddc.2:test*/ c.field. /*ddk.2:test*/ method();
c.field. /*2:test*/ method();
}

class Class {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ void main() {
/*1:main*/ test();
}

void test /*ddk.2:test*/ () /*ddc.2:test*/ async {
void test /*2:test*/ () async {
/*3:test*/ throw '>ExceptionMarker<';
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ void main() {
/*1:main*/ test1();
}

Future<void> test1 /*ddk.2:test1*/ () /*ddc.2:test1*/ async {
Future<void> test1 /*2:test1*/ () async {
await /*3:test1*/ test2();
}

Future<void> test2 /*ddk.4:test2*/ () /*ddc.4:test2*/ async {
Future<void> test2 /*4:test2*/ () async {
/*5:test2*/ throw '>ExceptionMarker<';
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

void main() {
// ignore: UNUSED_LOCAL_VARIABLE
var /*ddc.1:main*/ c = /*ddk.1:main*/ Class();
var c = /*1:main*/ Class();
}

class Class {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void main() {
/*1:main*/ test();
}

void test /*ddk.2:test*/ () /*ddc.2:test*/ async {
void test /*2:test*/ () async {
// ignore: UNUSED_LOCAL_VARIABLE
var c = /*3:test*/ Class();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

void main() {
var c = Class();
c. /*1:main*/ test();
// NOTE: The following line should not be formatted because spaces are
// inserted around the comment that throw off the expected column.
c/*1:main*/.test();
}

class Class {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

void main() {
/*ddc.1:main*/ Class. /*ddk.1:main*/ test();
Class. /*1:main*/ test();
}

class Class {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void main() {
/*1:main*/ test1();
}

Future<void> test1 /*ddk.2:test1*/ () /*ddc.2:test1*/ async {
Future<void> test1 /*2:test1*/ () async {
/*3:test1*/ test2();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Class2 {
dynamic operator [](index) => index;

dynamic code() {
/*bl*/ /*sl:1*/ this[42]; // DDK fails to hover on `this`
/*bl*/ /*sl:1*/ this[42]; // fails to hover on `this`
return /*sl:2*/ this[42];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class Foo {
int? x, y, z;

Foo(int a, int b)
: /*sl:2*/ x = a, // `s:2` fails, DDK is missing hover info
: /*sl:2*/ x = a, // `s:2` fails, missing hover info
/*sl:3*/ y = b {
// `s:3` fails, DDK is missing hover info
// `s:3` fails, missing hover info
z = a /*sl:4*/ + b;
}
}
12 changes: 6 additions & 6 deletions pkg/dev_compiler/test/sourcemap/testing.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"packages": "../../../../.dart_tool/package_config.json",
"suites": [
{
"name": "sourcemaps_ddk",
"name": "sourcemaps",
"kind": "Chain",
"source": "sourcemaps_ddk_suite.dart",
"source": "sourcemaps_suite.dart",
"path": "testfiles",
"status": "sourcemaps_ddk.status",
"status": "sourcemaps.status",
"pattern": [
"\\.dart$",
"\\.unformatteddart$"
Expand All @@ -18,11 +18,11 @@
]
},
{
"name": "stacktrace_ddk",
"name": "stacktrace",
"kind": "Chain",
"source": "stacktrace_ddk_suite.dart",
"source": "stacktrace_suite.dart",
"path": "stacktrace_testfiles",
"status": "stacktrace_ddk.status",
"status": "stacktrace.status",
"pattern": [
"\\.dart$"
],
Expand Down
8 changes: 4 additions & 4 deletions tools/bots/test_matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -2260,15 +2260,15 @@
"name": "ddk sourcemap tests",
"script": "out/ReleaseX64/dart",
"arguments": [
"pkg/dev_compiler/test/sourcemap/sourcemaps_ddk_suite.dart",
"pkg/dev_compiler/test/sourcemap/sourcemaps_suite.dart",
"-rnone"
]
},
{
"name": "ddk sourcemap stacktrace tests",
"script": "out/ReleaseX64/dart",
"arguments": [
"pkg/dev_compiler/test/sourcemap/stacktrace_ddk_suite.dart",
"pkg/dev_compiler/test/sourcemap/stacktrace_suite.dart",
"-rnone"
]
},
Expand Down Expand Up @@ -2515,15 +2515,15 @@
"name": "ddk sourcemap tests",
"script": "xcodebuild/ReleaseX64/dart",
"arguments": [
"pkg/dev_compiler/test/sourcemap/sourcemaps_ddk_suite.dart",
"pkg/dev_compiler/test/sourcemap/sourcemaps_suite.dart",
"-rnone"
]
},
{
"name": "ddk sourcemap stacktrace tests",
"script": "xcodebuild/ReleaseX64/dart",
"arguments": [
"pkg/dev_compiler/test/sourcemap/stacktrace_ddk_suite.dart",
"pkg/dev_compiler/test/sourcemap/stacktrace_suite.dart",
"-rnone"
]
},
Expand Down

0 comments on commit 739ad03

Please sign in to comment.