Craft Anything: understand how any software works, and craft your own.
Rust
The Windows pipe gap in project_play is noted in its tool help and kept as an ignored test (#212)
GGWAfff225d31962
diff --git a/crates/engine/src/tools/project_tools.rs b/crates/engine/src/tools/project_tools.rsindex 438c84b4..7893315f 100644--- a/crates/engine/src/tools/project_tools.rs+++ b/crates/engine/src/tools/project_tools.rs@@ -56,7 +56,7 @@ pub fn specs() -> Vec<ToolSpec> {ToolSpec {id: "project_play",title: "Play a project's result",- summary: "Start the finished game or app a project built (its program, a Unity or Unreal package, or a Godot project in Godot), in its own window. If it's already running, says so instead of starting a second copy, unless `another` is true. A start that quits within two seconds is reported with its exit code and last output. It runs the code the builder wrote, so it needs the person's consent. Websites use project_preview instead.",+ summary: "Start the finished game or app a project built (its program, a Unity or Unreal package, or a Godot project in Godot), in its own window. If it's already running, says so instead of starting a second copy, unless `another` is true. A start that quits within two seconds is reported with its exit code and last output. It runs the code the builder wrote, so it needs the person's consent. Websites use project_preview instead. Known limit on Windows: when the caller's output is a pipe, the started program inherits it, so a caller reading that output to its end waits until the program exits (#207).",beginner: "Opens the game or app that was made.",toolset: Toolset::Projects,effects: Effects::LAUNCHES_PROCESS.union(Effects::EXECUTES_FOREIGN_CODE),diff --git a/crates/platform/src/process.rs b/crates/platform/src/process.rsindex a6fb218a..e0630fd5 100644--- a/crates/platform/src/process.rs+++ b/crates/platform/src/process.rs@@ -1054,6 +1054,100 @@ fn windows_form(p: &str) -> String {mod launch_tests {use super::*;+ #[cfg(windows)]+ #[test]+ #[ignore = "stand-in invoked by launch_does_not_hold_callers_output_pipes"]+ fn pipe_launcher_stand_in() {+ if std::env::var_os("PIPE_TEST_DIR").is_none() {+ return;+ }+ let exe = std::env::current_exe().unwrap();+ let launch = Launch::new(exe).args(["--ignored", "--exact", "process::launch_tests::pipe_sleeper_stand_in"]).hide_console();+ let launch = if std::env::var_os("PIPE_TEST_LOG").is_some() { launch.log_to("run.log") } else { launch };+ launch.start_watched().unwrap();+ }++ #[cfg(windows)]+ #[test]+ #[ignore = "stand-in invoked by pipe_launcher_stand_in"]+ fn pipe_sleeper_stand_in() {+ if std::env::var_os("PIPE_TEST_DIR").is_none() {+ return;+ }+ std::fs::write("started", b"ready").unwrap();+ std::thread::sleep(Duration::from_secs(6));+ std::fs::write("finished", b"done").unwrap();+ }++ // Documents a known gap (#207): a started program inherits the caller's output pipes, so the+ // caller's command doesn't return until the program exits. Run it with `--ignored` to see it fail.+ #[cfg(windows)]+ #[test]+ #[ignore = "known gap, see #207: started programs inherit the caller's output pipes"]+ fn launch_does_not_hold_callers_output_pipes() {+ use std::os::windows::process::CommandExt;++ let mut held_open = false;+ for log_to_file in [false, true] {+ let dir = tempfile::tempdir().unwrap();+ // This process is the CLI stand-in: its real standard handles are pipes.+ let mut cmd = std::process::Command::new(std::env::current_exe().unwrap());+ cmd.args(["--ignored", "--exact", "process::launch_tests::pipe_launcher_stand_in"])+ .current_dir(dir.path())+ .env("PIPE_TEST_DIR", dir.path())+ .env_remove("PIPE_TEST_LOG")+ .stdin(Stdio::null())+ .stdout(Stdio::piped())+ .stderr(Stdio::piped())+ .creation_flags(0x0800_0000);+ if log_to_file {+ cmd.env("PIPE_TEST_LOG", "1");+ }+ let started = Instant::now();+ let mut launcher = cmd.spawn().unwrap();+ let stdout = launcher.stdout.take().unwrap();+ let stderr = launcher.stderr.take().unwrap();+ let mut receivers = Vec::new();+ for (name, mut pipe) in [("stdout", Box::new(stdout) as Box<dyn Read + Send>), ("stderr", Box::new(stderr) as Box<dyn Read + Send>)] {+ let (tx, rx) = std::sync::mpsc::channel();+ receivers.push((name, rx));+ std::thread::spawn(move || {+ let mut bytes = Vec::new();+ pipe.read_to_end(&mut bytes).unwrap();+ let _ = tx.send(started.elapsed());+ });+ }+ let status = launcher.wait().unwrap();+ let launcher_after = started.elapsed();+ println!("log_to_file={log_to_file}: launcher returned after {launcher_after:?}");+ let eof: Vec<_> = receivers.iter().map(|(name, rx)| (*name, rx.recv_timeout(Duration::from_secs(3)))).collect();+ let child_still_running = !dir.path().join("finished").exists();+ // Let the stand-in finish even on assertion failure; no detached test is left behind.+ let deadline = Instant::now() + Duration::from_secs(15);+ while !dir.path().join("finished").exists() && Instant::now() < deadline {+ std::thread::sleep(Duration::from_millis(25));+ }+ assert!(status.success(), "launcher failed: {status}");+ assert!(launcher_after < Duration::from_secs(3), "launcher itself did not return promptly");+ assert!(dir.path().join("started").exists(), "stand-in never started");+ assert!(dir.path().join("finished").exists(), "stand-in did not finish");+ for (name, result) in eof {+ match result {+ Ok(elapsed) => {+ println!("log_to_file={log_to_file}: {name} EOF after {elapsed:?}");+ held_open |= elapsed >= Duration::from_secs(3);+ }+ Err(error) => {+ println!("log_to_file={log_to_file}: {name} pipe held open after launcher returned: {error:?}");+ held_open = true;+ }+ }+ }+ held_open |= !child_still_running;+ }+ assert!(!held_open, "caller pipe held open after launcher returned");+ }+#[test]fn a_missing_program_is_a_tool_error_with_remediation() {let e = Launch::new("craft-anything-no-such-program-xyz").remediation("Install it.").start().unwrap_err();diff --git a/docs/ROADMAP.md b/docs/ROADMAP.mdindex 2ef71899..a46e39b2 100644--- a/docs/ROADMAP.md+++ b/docs/ROADMAP.md@@ -811,7 +811,7 @@ Gaps found while using the app for real projects.total, so a forked answer shows none; count questions in the project's usage- [ ] "Make this change" on an answer that suggests one (sends it as a normal message)- [ ] A program started from the CLI (`project_play`) keeps the shell's output pipe open, so the- command doesn't return until it closes: start it without inheriting the CLI's handles+ command doesn't return until it closes: start it without inheriting the CLI's handles (#207)- [x] The desktop app keeps `desktop.log` beside its settings: startup steps, warnings, a windowthat couldn't start, panics- [x] The cost says when it's an estimate: Claude Code's figure is its own guess at API prices,