From 545305d12a64ce088fc9578baecb664819d8f842 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sat, 10 Oct 2026 17:14:43 +0800 Subject: [PATCH] test: consume GUI credentials before the logging fixture exits --- crates/gpapi/src/process/gui_launcher.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/gpapi/src/process/gui_launcher.rs b/crates/gpapi/src/process/gui_launcher.rs index dff0abb..9724cdf 100644 --- a/crates/gpapi/src/process/gui_launcher.rs +++ b/crates/gpapi/src/process/gui_launcher.rs @@ -203,12 +203,20 @@ mod tests { let log_file = dir.path().join("desktop.log"); fs::write(&log_file, "[gpservice] started\n").unwrap(); let program = dir.path().join("gui"); - fs::write(&program, "#!/bin/sh\nprintf '[gpgui] initialized\\n' >&2\n").unwrap(); - fs::set_permissions(&program, fs::Permissions::from_mode(0o755)).unwrap(); let launcher = launcher(VERSION, vec![]).envs(HashMap::from([( "GP_LOG_FILE".to_owned(), log_file.to_str().unwrap().to_owned(), )])); + let frame_len = launcher.credential.encode_frame().unwrap().len(); + // Consume the credential frame like the real GUI before exiting. + fs::write( + &program, + format!( + "#!/bin/sh\ndd bs=1 count={frame_len} of=/dev/null 2>/dev/null || exit 1\nprintf '[gpgui] initialized\\n' >&2\n" + ), + ) + .unwrap(); + fs::set_permissions(&program, fs::Permissions::from_mode(0o755)).unwrap(); assert!(launcher.launch_program(&program).await.unwrap().success()); assert!(launcher.launch_program(&program).await.unwrap().success());