mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[flutter_tools] Update the mapping for the Dart SDK internal URI (#151170)
This changes the mapping for the Dart SDK inside Flutter from `org-dartlang-sdk:///third_party/dart/sdk` to org-dartlang-sdk:///flutter/third_party/dart/sdk`. This URI changed in https://github.com/flutter/engine/pull/51917 but was not caught by tests because they only tested a specific set of mappings and there were no integration tests checking what URIs were actually produced by a running app. So, this change also adds an integration tests that ensures that a real running app produces URIs that are then correctly mapped. Fixes https://github.com/Dart-Code/Dart-Code/issues/5164.
This commit is contained in:
parent
d0852df663
commit
ce0e5c4330
@ -100,9 +100,9 @@ abstract class FlutterBaseDebugAdapter extends DartDebugAdapter<FlutterLaunchReq
|
||||
final String flutterRoot = fileSystem.path.join(flutterSdkRoot, 'bin', 'cache', 'pkg', 'sky_engine', 'lib', 'ui');
|
||||
orgDartlangSdkMappings[flutterRoot] = Uri.parse('org-dartlang-sdk:///flutter/lib/ui');
|
||||
|
||||
// The rest of the Dart SDK maps to /third_party/dart/sdk
|
||||
// The rest of the Dart SDK maps to /flutter/third_party/dart/sdk
|
||||
final String dartRoot = fileSystem.path.join(flutterSdkRoot, 'bin', 'cache', 'pkg', 'sky_engine');
|
||||
orgDartlangSdkMappings[dartRoot] = Uri.parse('org-dartlang-sdk:///third_party/dart/sdk');
|
||||
orgDartlangSdkMappings[dartRoot] = Uri.parse('org-dartlang-sdk:///flutter/third_party/dart/sdk');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -737,7 +737,7 @@ void main() {
|
||||
|
||||
test('dart:core URI to file path', () async {
|
||||
expect(
|
||||
adapter.convertOrgDartlangSdkToPath(Uri.parse('org-dartlang-sdk:///third_party/dart/sdk/lib/core/core.dart')),
|
||||
adapter.convertOrgDartlangSdkToPath(Uri.parse('org-dartlang-sdk:///flutter/third_party/dart/sdk/lib/core/core.dart')),
|
||||
Uri.file(fs.path.join(flutterRoot, 'bin', 'cache', 'pkg', 'sky_engine', 'lib', 'core', 'core.dart')),
|
||||
);
|
||||
});
|
||||
@ -745,7 +745,7 @@ void main() {
|
||||
test('dart:core file path to URI', () async {
|
||||
expect(
|
||||
adapter.convertUriToOrgDartlangSdk(Uri.file(fs.path.join(flutterRoot, 'bin', 'cache', 'pkg', 'sky_engine', 'lib', 'core', 'core.dart'))),
|
||||
Uri.parse('org-dartlang-sdk:///third_party/dart/sdk/lib/core/core.dart'),
|
||||
Uri.parse('org-dartlang-sdk:///flutter/third_party/dart/sdk/lib/core/core.dart'),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -584,6 +584,46 @@ The relevant error-causing widget was:
|
||||
|
||||
await dap.client.terminate();
|
||||
});
|
||||
|
||||
group('can step', () {
|
||||
test('into SDK sources mapped to local files when debugSdkLibraries=true', () async {
|
||||
final BasicProject project = BasicProject();
|
||||
await project.setUpIn(tempDir);
|
||||
|
||||
final String breakpointFilePath = globals.fs.path.join(project.dir.path, 'lib', 'main.dart');
|
||||
final int breakpointLine = project.topLevelFunctionBreakpointLine;
|
||||
final String expectedPrintLibraryPath = globals.fs.path.join('pkg', 'sky_engine', 'lib', 'core', 'print.dart');
|
||||
|
||||
// Launch the app and wait for it to print "topLevelFunction".
|
||||
await Future.wait(<Future<void>>[
|
||||
dap.client.stdoutOutput.firstWhere((String output) => output.startsWith('topLevelFunction')),
|
||||
dap.client.start(
|
||||
launch: () => dap.client.launch(
|
||||
cwd: project.dir.path,
|
||||
debugSdkLibraries: true,
|
||||
toolArgs: <String>['-d', 'flutter-tester'],
|
||||
),
|
||||
),
|
||||
], eagerError: true);
|
||||
|
||||
// Add a breakpoint to the `print()` line and hit it.
|
||||
unawaited(dap.client.setBreakpoint(breakpointFilePath, breakpointLine));
|
||||
int stoppedThreadId = (await dap.client.stoppedEvents.firstWhere((StoppedEventBody e) => e.reason == 'breakpoint')).threadId!;
|
||||
|
||||
// Step into `print()` and wait for the next stop.
|
||||
unawaited(dap.client.stepIn(stoppedThreadId));
|
||||
stoppedThreadId = (await dap.client.stoppedEvents.first).threadId!;
|
||||
|
||||
// Fetch the top stack frame and ensure it's been mapped to a local file
|
||||
// correctly.
|
||||
final StackFrame topFrame = (await dap.client.getValidStack(stoppedThreadId, startFrame: 0, numFrames: 1)).stackFrames.single;
|
||||
expect(topFrame.source!.name, 'dart:core/print.dart');
|
||||
// We should have a resolved path ending with the path to the print library.
|
||||
expect(topFrame.source!.path, endsWith(expectedPrintLibraryPath));
|
||||
|
||||
await dap.client.terminate();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
group('attach', () {
|
||||
@ -697,7 +737,6 @@ The relevant error-causing widget was:
|
||||
// Trigger the detach.
|
||||
dap.client.terminate(),
|
||||
]);
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -430,6 +430,37 @@ extension DapTestClientExtension on DapTestClient {
|
||||
Future<Response> continue_(int threadId) =>
|
||||
sendRequest(ContinueArguments(threadId: threadId));
|
||||
|
||||
/// Sends a stepIn request for the given thread.
|
||||
///
|
||||
/// Returns a Future that completes when the server returns a corresponding
|
||||
/// response.
|
||||
Future<Response> stepIn(int threadId) =>
|
||||
sendRequest(StepInArguments(threadId: threadId));
|
||||
|
||||
/// Fetches a stack trace and asserts it was a valid response.
|
||||
Future<StackTraceResponseBody> getValidStack(int threadId,
|
||||
{required int startFrame, required int numFrames}) async {
|
||||
final Response response = await stackTrace(threadId,
|
||||
startFrame: startFrame, numFrames: numFrames);
|
||||
assert(response.success);
|
||||
assert(response.command == 'stackTrace');
|
||||
return StackTraceResponseBody.fromJson(
|
||||
response.body! as Map<String, Object?>);
|
||||
}
|
||||
|
||||
/// Sends a stackTrace request to the server to request the call stack for a
|
||||
/// given thread.
|
||||
///
|
||||
/// If [startFrame] and/or [numFrames] are supplied, only a slice of the
|
||||
/// frames will be returned.
|
||||
///
|
||||
/// Returns a Future that completes when the server returns a corresponding
|
||||
/// response.
|
||||
Future<Response> stackTrace(int threadId,
|
||||
{int? startFrame, int? numFrames}) =>
|
||||
sendRequest(StackTraceArguments(
|
||||
threadId: threadId, startFrame: startFrame, levels: numFrames));
|
||||
|
||||
/// Clears breakpoints in [file].
|
||||
Future<void> clearBreakpoints(String filePath) async {
|
||||
await sendRequest(
|
||||
|
Loading…
Reference in New Issue
Block a user