2
0
Fork 0
mirror of https://github.com/uutils/coreutils synced 2024-12-14 07:12:44 +00:00

tests(ls): Test default quoting style on TTY output

This commit is contained in:
Dorian Péron 2024-05-14 00:43:30 +02:00
parent 23d5235e7c
commit 0209c90b4e

View file

@ -2686,16 +2686,24 @@ fn test_ls_quoting_style() {
{
at.touch("one\ntwo");
at.touch("one\\two");
// Default is literal, when stdout is not a TTY.
// Otherwise, it is shell-escape
// Default is literal, when stdout is not a TTY...
scene
.ucmd()
.arg("--hide-control-chars")
.arg("one\ntwo")
.succeeds()
.stdout_only("one?two\n");
// TODO: TTY-expected output, find a way to check this as well
// .stdout_only("'one'$'\\n''two'\n");
// ... Otherwise, it is shell-escape
#[cfg(unix)]
scene
.ucmd()
.arg("--hide-control-chars")
.arg("one\ntwo")
.terminal_simulation(true)
.succeeds()
.stdout_only("'one'$'\\n''two'\r\n");
for (arg, correct) in [
("--quoting-style=literal", "one?two"),
@ -2786,13 +2794,21 @@ fn test_ls_quoting_style() {
}
}
// No-TTY
scene
.ucmd()
.arg("one two")
.succeeds()
.stdout_only("one two\n");
// TODO: TTY-expected output
// .stdout_only("'one two'\n");
// TTY
#[cfg(unix)]
scene
.ucmd()
.arg("one two")
.terminal_simulation(true)
.succeeds()
.stdout_only("'one two'\r\n");
for (arg, correct) in [
("--quoting-style=literal", "one two"),
@ -2914,14 +2930,24 @@ fn test_ls_quoting_and_color() {
let at = &scene.fixtures;
at.touch("one two");
// No-TTY
scene
.ucmd()
.arg("--color")
.arg("one two")
.succeeds()
.stdout_only("one two\n");
// TODO: TTY-expected output
// .stdout_only("'one two'\n");
// TTY
#[cfg(unix)]
scene
.ucmd()
.arg("--color")
.arg("one two")
.terminal_simulation(true)
.succeeds()
.stdout_only("'one two'\r\n");
}
#[test]