lotabout.skim/tests/history.rs
LoricAndre 9d12e9d420
feat: windows support (#1010)
* wip: windows support

* feat: windows support

* feat: add windows target to CI

* chore: generate completions & manpage

* Update src/util.rs

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* chore: cleanup & doc

* chore: generate completions & manpage

* chore: generate dist

* fix: reduplicate default test

* chore: regate tmux

* chore: remove useless test-utils feature

* fix(windows): ignore dirs in default_command

* docs: update shell docs for windows

* chore: generate completions & manpage

* chore(justfile): do not ignore failed tests

* fix: upload correct junit after profile change

* fix: always execute exit commands

* fix: windows-specific ctrl-c handling

* chore: misc docs & other updates

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* chore: generate completions & manpage

* chore: include license in MSI installer

---------

Co-authored-by: Skim bot <skim-bot@skim-rs.github.io>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Your Name <you@example.com>
2026-03-29 21:46:42 +00:00

97 lines
2.2 KiB
Rust

#![cfg(unix)]
#[allow(dead_code)]
mod common;
use common::tmux::Keys::*;
use common::tmux::TmuxController;
use std::fs::File;
use std::io::Read;
use std::io::Result;
use std::io::Write;
use std::path::Path;
#[test]
fn query_history() -> Result<()> {
let mut tmux = TmuxController::new()?;
let histfile = tmux.tempfile()?;
File::create(&histfile)?.write_all(b"a\nb\nc")?;
tmux.start_sk(Some("echo -e -n 'a\\nb\\nc'"), &["--history", &histfile])?;
tmux.until(|l| l[0].starts_with(">"))?;
tmux.send_keys(&[Ctrl(&Key('p'))])?;
tmux.until(|l| l[0].trim() == "> c")?;
tmux.send_keys(&[Ctrl(&Key('p'))])?;
tmux.until(|l| l[0].trim() == "> b")?;
tmux.send_keys(&[Ctrl(&Key('p'))])?;
tmux.until(|l| l[0].trim() == "> a")?;
tmux.send_keys(&[Ctrl(&Key('n'))])?;
tmux.until(|l| l[0].trim() == "> b")?;
tmux.send_keys(&[Key('n')])?;
tmux.until(|l| l[0].trim() == "> bn")?;
tmux.send_keys(&[Enter])?;
tmux.until(|_| {
let mut buf = String::new();
File::open(Path::new(&histfile))
.unwrap()
.read_to_string(&mut buf)
.unwrap();
println!("{}", buf);
buf == "a\nb\nc\nbn"
})?;
Ok(())
}
#[test]
fn cmd_history() -> Result<()> {
let mut tmux = TmuxController::new()?;
let histfile = tmux.tempfile()?;
File::create(&histfile)?.write_all(b"a\nb\nc")?;
tmux.start_sk(
Some("echo -e -n 'a\\nb\\nc'"),
&["-i", "-c", "'echo {}'", "--cmd-history", &histfile],
)?;
tmux.until(|l| l[0].starts_with("c>"))?;
tmux.send_keys(&[Ctrl(&Key('p'))])?;
tmux.until(|l| l[0].trim() == "c> c")?;
tmux.send_keys(&[Ctrl(&Key('p'))])?;
tmux.until(|l| l[0].trim() == "c> b")?;
tmux.send_keys(&[Ctrl(&Key('p'))])?;
tmux.until(|l| l[0].trim() == "c> a")?;
tmux.send_keys(&[Ctrl(&Key('n'))])?;
tmux.until(|l| l[0].trim() == "c> b")?;
tmux.send_keys(&[Key('n')])?;
tmux.until(|l| l[0].trim() == "c> bn")?;
tmux.send_keys(&[Enter])?;
tmux.until(|_| {
let mut buf = String::new();
File::open(Path::new(&histfile))
.unwrap()
.read_to_string(&mut buf)
.unwrap();
println!("{}", buf);
buf == "a\nb\nc\nbn"
})?;
Ok(())
}