Skip to content

Commit 8dab178

Browse files
DanTupCommit Queue
authored andcommitted
[dds/dap] Remove macro tests
This removes the macro tests but leaves the URI support until it's clearer we won't use this (or that it won't become a fully documented feature of DAP, in which case it would be better to use URIs instead of Paths anyway). Fixes #60034 Change-Id: I4df448c98eb4cc352558234c8365a5e849deed7c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408280 Commit-Queue: Ben Konyi <[email protected]> Reviewed-by: Ben Konyi <[email protected]> Reviewed-by: Derek Xu <[email protected]>
1 parent 93847ce commit 8dab178

File tree

3 files changed

+0
-176
lines changed

3 files changed

+0
-176
lines changed

pkg/dds/test/dap/integration/debug_test.dart

Lines changed: 0 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -525,125 +525,6 @@ main() {
525525
expect(vmServiceUri.path, matches(vmServiceAuthCodePathPattern));
526526
});
527527

528-
for (final folderName in ['bin', 'lib']) {
529-
/// Gets the expected name and URI for a macro-generated source.
530-
({String name, Uri fileLikeUri}) getExpectedMacroSource(File testFile) {
531-
// Drive letters are always normalized to uppercase so expect
532-
// uppercase in the path part of the macro URI.
533-
final fileLikeUri = Uri.file(uppercaseDriveLetter(testFile.path))
534-
.replace(scheme: 'dart-macro+file');
535-
// The expected source name will differ for inside/outside the lib
536-
// folder.
537-
final name = folderName == 'lib'
538-
? 'dart-macro+package:my_test_project/main.dart'
539-
: fileLikeUri.toString();
540-
541-
return (name: name, fileLikeUri: fileLikeUri);
542-
}
543-
544-
test(
545-
'can download source code from the VM for macro-generated files '
546-
'in "$folderName" when the client does not support Dart URIs',
547-
() async {
548-
final client = dap.client;
549-
550-
// Create the macro impl, the script that uses it and set up macro
551-
// support.
552-
dap.createTestFile(
553-
filename: '$folderName/with_hello.dart',
554-
withHelloMacroImplementation,
555-
);
556-
final testFile = dap.createTestFile(
557-
filename: '$folderName/main.dart',
558-
withHelloMacroProgram,
559-
);
560-
dap.createPubspec(dap.testAppDir, 'my_test_project');
561-
await dap.enableMacroSupport();
562-
final macroSource = getExpectedMacroSource(testFile);
563-
564-
// Hit the initial breakpoint.
565-
final breakpointLine = lineWith(testFile, breakpointMarker);
566-
final stop = await dap.client.hitBreakpoint(
567-
testFile,
568-
breakpointLine,
569-
toolArgs: ['--enable-experiment=macros'],
570-
);
571-
572-
// Step in to the hello() method provided by the macro.
573-
final responses = await Future.wait([
574-
client.expectStop('step', sourceName: macroSource.name),
575-
client.stepIn(stop.threadId!),
576-
], eagerError: true);
577-
final stopResponse = responses.first as StoppedEventBody;
578-
579-
// Fetch the top stack frame (which should be inside print).
580-
final stack = await client.getValidStack(
581-
stopResponse.threadId!,
582-
startFrame: 0,
583-
numFrames: 1,
584-
);
585-
final topFrame = stack.stackFrames.first;
586-
587-
// Downloaded macro sources should have a sourceReference and no path.
588-
expect(topFrame.source!.path, isNull);
589-
expect(topFrame.source!.sourceReference, isPositive);
590-
591-
// Source code should contain the augmentation for class A.
592-
final source = await client.getValidSource(topFrame.source!);
593-
expect(source.content, contains('augment class A'));
594-
});
595-
596-
test(
597-
'can use local source code for macro-generated files '
598-
'in "$folderName" when the client supports Dart URIs', () async {
599-
final client = dap.client;
600-
601-
// Create the macro impl, the script that uses it and set up macro
602-
// support.
603-
dap.createTestFile(
604-
filename: '$folderName/with_hello.dart',
605-
withHelloMacroImplementation,
606-
);
607-
final testFile = dap.createTestFile(
608-
filename: '$folderName/main.dart',
609-
withHelloMacroProgram,
610-
);
611-
dap.createPubspec(dap.testAppDir, 'my_test_project');
612-
await dap.enableMacroSupport();
613-
final macroSource = getExpectedMacroSource(testFile);
614-
// Tell the DA we can handle the special URIs.
615-
client.supportUris = true;
616-
617-
// Hit the initial breakpoint.
618-
final breakpointLine = lineWith(testFile, breakpointMarker);
619-
final stop = await dap.client.hitBreakpoint(
620-
testFile,
621-
breakpointLine,
622-
toolArgs: ['--enable-experiment=macros'],
623-
);
624-
625-
// Step in to the hello() method provided by the macro.
626-
final responses = await Future.wait([
627-
client.expectStop('step', sourceName: macroSource.name),
628-
client.stepIn(stop.threadId!),
629-
], eagerError: true);
630-
final stopResponse = responses.first as StoppedEventBody;
631-
632-
// Fetch the top stack frame (which should be inside print).
633-
final stack = await client.getValidStack(
634-
stopResponse.threadId!,
635-
startFrame: 0,
636-
numFrames: 1,
637-
);
638-
final topFrame = stack.stackFrames.first;
639-
640-
// When we use local editor-provided sources, there should be a URI in
641-
// pathand no sourceReference.
642-
expect(topFrame.source!.sourceReference, isNull);
643-
expect(topFrame.source!.path, macroSource.fileLikeUri.toString());
644-
});
645-
}
646-
647528
test('can map SDK source code to a local path', () async {
648529
final client = dap.client;
649530
final testFile = dap.createTestFile(simpleBreakpointProgram);

pkg/dds/test/dap/integration/test_scripts.dart

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -163,42 +163,6 @@ const simpleBreakpointProgram = '''
163163
}
164164
''';
165165

166-
/// A simple script that provides a @withHello macro that adds a
167-
/// `hello()` method to a class that prints "Hello".
168-
const withHelloMacroImplementation = '''
169-
import 'package:macros/macros.dart';
170-
171-
macro class WithHello implements ClassDeclarationsMacro {
172-
const WithHello();
173-
174-
@override
175-
Future<void> buildDeclarationsForClass(
176-
ClassDeclaration clazz,
177-
MemberDeclarationBuilder builder,
178-
) async {
179-
builder.declareInType(DeclarationCode.fromString(\'''
180-
void hello() {
181-
print('Hello');
182-
}
183-
\'''));
184-
}
185-
}
186-
''';
187-
188-
/// A simple script that uses [withHelloMacroImplementation] and calls the
189-
/// `hello()` method.
190-
const withHelloMacroProgram = '''
191-
import 'with_hello.dart';
192-
193-
void main() {
194-
final a = A();
195-
a.hello(); $breakpointMarker
196-
}
197-
198-
@WithHello()
199-
class A {}
200-
''';
201-
202166
/// A simple Dart script that prints "Hello" and then "World" with a breakpoint
203167
/// on the line that prints "World". By restarting from the parent frame after
204168
/// hitting the breakpoint, the output would be "Hello", "Hello", "World".

pkg/dds/test/dap/integration/test_support.dart

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -199,27 +199,6 @@ foo() {
199199
);
200200
}
201201

202-
/// Sets up packages for macro support.
203-
Future<void> enableMacroSupport() async {
204-
// Compute a path to the local package that we can use.
205-
final dapIntegrationTestFolder = path.dirname(Platform.script.toFilePath());
206-
assert(path.split(dapIntegrationTestFolder).last == 'integration');
207-
208-
final sdkRoot =
209-
path.normalize(path.join(dapIntegrationTestFolder, '../../../../..'));
210-
final macrosPath = path.join(sdkRoot, 'pkg', 'macros');
211-
await addPackageDependency(testAppDir, 'macros', Uri.file(macrosPath));
212-
213-
createTestFile(
214-
filename: 'analysis_options.yaml',
215-
'''
216-
analyzer:
217-
enable-experiment:
218-
- macros
219-
''',
220-
);
221-
}
222-
223202
void createPubspec(Directory dir, String projectName) {
224203
final pubspecFile = File(path.join(dir.path, 'pubspec.yaml'));
225204
pubspecFile

0 commit comments

Comments
 (0)