lotabout.skim/tests/ansi.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

67 lines
1.9 KiB
Rust

#[allow(dead_code)]
#[macro_use]
mod common;
#[cfg(unix)]
use common::tmux::Keys::*;
#[cfg(unix)]
sk_test!(test_ansi_flag_enabled, @cmd "echo -e 'plain\\n\\x1b[31mred\\x1b[0m\\n\\x1b[32mgreen\\x1b[0m'", &["--ansi", "--color", "current_match_bg:1,current_bg:2"], {
@capture[0] starts_with(">");
@lines |l| (l.len() >= 3 && l.iter().any(|line| line.contains("plain")));
@keys Key('d');
@capture[2] starts_with("> red");
@capture_colored[*] contains("mre\u{1b}");
@keys Enter;
@output[*] trim().eq("red");
});
#[cfg(unix)]
sk_test!(test_ansi_flag_disabled, @cmd "echo -e 'plain\\n\\x1b[31mred\\x1b[0m\\n\\x1b[32mgreen\\x1b[0m'", &[], {
@capture[0] starts_with(">");
@capture[*] contains("plain");
@keys Str("red");
@capture[2] eq("> ?[31mred?[0m");
@keys Enter;
});
#[cfg(unix)]
sk_test!(test_ansi_matching_on_stripped_text, @cmd "echo -e '\\x1b[32mgreen\\x1b[0m text\\n\\x1b[31mred\\x1b[0m text\\nplain text'", &["--ansi"], {
@capture[0] starts_with(">");
@lines |l| (l.len() >= 3 && l.iter().any(|line| line.contains("plain")));
@keys Str("text");
// Tiebreak will reorder items
@capture[2] contains("red text");
@capture[3] contains("green text");
@capture[4] contains("plain text");
@keys Ctrl(&Key('u')), Str("green");
@capture[2] contains("green");
@lines |l| (l.len() == 3);
});
#[cfg(unix)]
sk_test!(test_ansi_flag_no_strip, @cmd "echo -e 'plain\\n\\x1b[31mred\\x1b[0m\\n\\x1b[32mgreen\\x1b[0m'", &["--ansi", "--no-strip-ansi", "--color", "current_match_bg:1,current_bg:2"], {
@capture[0] starts_with(">");
@lines |l| (l.len() >= 3 && l.iter().any(|line| line.contains("plain")));
@keys Key('d');
@capture[2] starts_with("> red");
@capture_colored[*] contains("mre\u{1b}");
@keys Enter;
@output[*] contains("mred\u{1b}");
});
insta_test!(test_prompt_ansi, ["a"], &["--prompt", "\x1b[1;34mprompt\x1b[0m nocol"], {
@snap;
});