C1: alpha dry run fixes (Ctrl+C in terminal, ignored colour, find singular)
Some checks failed
ci / ci (macos-15) (push) Has been cancelled
ci / ci (ubuntu-24.04) (push) Has been cancelled
ci / ci (windows-2025) (push) Has been cancelled

- Terminal: undo an inherited "ignore Ctrl+C" flag before starting a
  ConPTY shell (lutra_proc::enable_ctrl_c). Lutra started by the lutra
  CLI (CREATE_NEW_PROCESS_GROUP) passed it to every shell, so Ctrl+C
  stopped nothing. Test reruns itself with that flag.
- Engine: an edited .gitignore/.ignore reports TreeChanged for its
  folder, so the tree greys newly ignored files (Add to .gitignore).
- Find: "1 match", "1 file" instead of "1 files".
- docs/alpha-checklist.md: steps corrected after the Windows dry run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-11-02 17:55:58 +01:00
parent 30de747ad6
commit e228d11ef9
11 changed files with 173 additions and 20 deletions

View file

@ -184,6 +184,11 @@ fn spawn_error(e: impl std::fmt::Display) -> TerminalError {
impl Session {
/// Starts a shell in a new pseudo terminal.
///
/// On Windows it first undoes an "ignore Ctrl+C" flag Lutra may have
/// inherited ([`lutra_proc::enable_ctrl_c`]), because the shell and the
/// programs it runs inherit it in turn and Ctrl+C would stop nothing. A
/// failure there is ignored: the shell works without it.
///
/// # Errors
/// [`TerminalError::InvalidSize`] for a size outside `1..=MAX_SIZE`,
/// [`TerminalError::Spawn`] if the pty cannot be created, the program
@ -210,6 +215,8 @@ impl Session {
for (key, value) in &options.env {
cmd.env(key, value);
}
#[cfg(windows)]
let _ = lutra_proc::enable_ctrl_c();
let mut child = pair.slave.spawn_command(cmd).map_err(spawn_error)?;
drop(pair.slave);
#[cfg(windows)]

View file

@ -261,3 +261,50 @@ fn spawn_errors() {
Err(TerminalError::InvalidSize { cols: 0, rows: 24 })
));
}
/// Set for the copy of this test binary that
/// [`ctrl_c_stops_a_program_when_lutra_ignores_ctrl_c`] starts.
#[cfg(windows)]
const CTRL_C_CHILD: &str = "LUTRA_TERMINAL_CTRL_C_CHILD";
/// Ctrl+C in the terminal stops a running program even when Lutra was
/// started with `CREATE_NEW_PROCESS_GROUP` (as `lutra` starts it), which
/// makes a process and its children ignore Ctrl+C. Runs
/// [`ctrl_c_child`] in a copy of this test binary started that way.
#[cfg(windows)]
#[test]
fn ctrl_c_stops_a_program_when_lutra_ignores_ctrl_c() {
use std::os::windows::process::CommandExt;
const CREATE_NEW_PROCESS_GROUP: u32 = 0x0000_0200;
let out = std::process::Command::new(std::env::current_exe().unwrap())
.args(["--exact", "ctrl_c_child", "--nocapture", "--test-threads=1"])
.env(CTRL_C_CHILD, "1")
.creation_flags(CREATE_NEW_PROCESS_GROUP)
.output()
.unwrap();
let text =
String::from_utf8_lossy(&out.stdout).into_owned() + &String::from_utf8_lossy(&out.stderr);
assert!(out.status.success(), "{text}");
assert!(text.contains("1 passed"), "{text}");
}
/// The part of [`ctrl_c_stops_a_program_when_lutra_ignores_ctrl_c`] that
/// runs in the copy; does nothing in a normal test run.
#[cfg(windows)]
#[test]
fn ctrl_c_child() {
if std::env::var_os(CTRL_C_CHILD).is_none() {
return;
}
let s = spawn(interactive(), 120);
s.write(b"ping -n 60 127.0.0.1\r").unwrap();
let (out, exit) = drive(&s, |out| out.matches("127.0.0.1").count() >= 3);
assert!(exit.is_none(), "{out:?}");
s.write(b"\x03").unwrap();
s.write(b"echo lutra-after-%OS%\r").unwrap();
let started = Instant::now();
let (out, exit) = drive(&s, |out| out.contains("lutra-after-Windows"));
assert!(exit.is_none(), "{out:?}");
assert!(out.contains("lutra-after-Windows"), "{out:?}");
assert!(started.elapsed() < Duration::from_secs(20), "{out:?}");
}