Skip to content

Commit 5a52c7e

Browse files
Add test to for shutdown on launch/attach failure
Co-Authored-By: Anthony Eid <[email protected]>
1 parent 9bca023 commit 5a52c7e

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

crates/debugger_ui/src/tests/debugger_panel.rs

+79
Original file line numberDiff line numberDiff line change
@@ -1300,3 +1300,82 @@ async fn test_it_send_breakpoint_request_if_breakpoint_buffer_is_unopened(
13001300

13011301
shutdown_session.await.unwrap();
13021302
}
1303+
1304+
#[gpui::test]
1305+
async fn test_debug_session_is_shutdown_when_attach_and_launch_request_fails(
1306+
executor: BackgroundExecutor,
1307+
cx: &mut TestAppContext,
1308+
) {
1309+
init_test(cx);
1310+
1311+
let fs = FakeFs::new(executor.clone());
1312+
1313+
let project = Project::test(fs, [], cx).await;
1314+
let workspace = init_test_workspace(&project, cx).await;
1315+
let cx = &mut VisualTestContext::from_window(*workspace, cx);
1316+
1317+
let task = project.update(cx, |project, cx| {
1318+
project.dap_store().update(cx, |store, cx| {
1319+
store.start_debug_session(
1320+
task::DebugAdapterConfig {
1321+
label: "test config".into(),
1322+
kind: task::DebugAdapterKind::Fake,
1323+
request: task::DebugRequestType::Launch,
1324+
program: None,
1325+
cwd: None,
1326+
initialize_args: None,
1327+
},
1328+
cx,
1329+
)
1330+
})
1331+
});
1332+
1333+
let (session, client) = task.await.unwrap();
1334+
let session_id = cx.update(|cx| session.read(cx).id());
1335+
1336+
client
1337+
.on_request::<Initialize, _>(move |_, _| {
1338+
Ok(dap::Capabilities {
1339+
supports_step_back: Some(false),
1340+
..Default::default()
1341+
})
1342+
})
1343+
.await;
1344+
1345+
client
1346+
.on_request::<Launch, _>(move |_, _| {
1347+
Err(ErrorResponse {
1348+
error: Some(dap::Message {
1349+
id: 1,
1350+
format: "error".into(),
1351+
variables: None,
1352+
send_telemetry: None,
1353+
show_user: None,
1354+
url: None,
1355+
url_label: None,
1356+
}),
1357+
})
1358+
})
1359+
.await;
1360+
1361+
client
1362+
.on_request::<StackTrace, _>(move |_, _| {
1363+
Ok(dap::StackTraceResponse {
1364+
stack_frames: Vec::default(),
1365+
total_frames: None,
1366+
})
1367+
})
1368+
.await;
1369+
1370+
client.on_request::<Disconnect, _>(move |_, _| Ok(())).await;
1371+
1372+
cx.run_until_parked();
1373+
1374+
project.update(cx, |project, cx| {
1375+
assert!(project
1376+
.dap_store()
1377+
.read(cx)
1378+
.session_by_id(&session_id)
1379+
.is_none());
1380+
});
1381+
}

0 commit comments

Comments
 (0)