Skip to content

Commit eb6bfce

Browse files
authored
Merge pull request #8551 from sylvestre/emoji-2
add more emoji tests
2 parents 303a211 + 3ed1f47 commit eb6bfce

File tree

9 files changed

+146
-0
lines changed

9 files changed

+146
-0
lines changed

tests/by-util/test_basename.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,21 @@ fn test_suffix_implies_multiple() {
278278
.succeeds()
279279
.stdout_is("foo\no\n");
280280
}
281+
282+
#[test]
283+
fn test_emoji_handling() {
284+
new_ucmd!()
285+
.arg("/path/to/🦀.txt")
286+
.succeeds()
287+
.stdout_only("🦀.txt\n");
288+
289+
new_ucmd!()
290+
.arg("/🌍/path/to/🚀.exe")
291+
.succeeds()
292+
.stdout_only("🚀.exe\n");
293+
294+
new_ucmd!()
295+
.args(&["/path/to/file🎯.emoji", ".emoji"])
296+
.succeeds()
297+
.stdout_only("file🎯\n");
298+
}

tests/by-util/test_comm.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,3 +594,19 @@ fn test_comm_arg_error() {
594594
.code_is(1)
595595
.stderr_is("error: the following required arguments were not provided:\n <FILE2>\n\nUsage: comm [OPTION]... FILE1 FILE2\n\nFor more information, try '--help'.\n");
596596
}
597+
598+
#[test]
599+
fn comm_emoji_sorted_inputs() {
600+
let scene = TestScenario::new(util_name!());
601+
let at = &scene.fixtures;
602+
603+
at.write("file1", "💐\n🦀\n");
604+
at.write("file2", "🦀\n🪽\n");
605+
606+
scene
607+
.ucmd()
608+
.args(&["file1", "file2"])
609+
.env("LC_ALL", "C.UTF-8")
610+
.succeeds()
611+
.stdout_only("💐\n\t\t🦀\n\t🪽\n");
612+
}

tests/by-util/test_dirname.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,21 @@ fn test_dirname_non_utf8_paths() {
8484
assert!(!output.is_empty());
8585
assert!(output.contains("test_"));
8686
}
87+
88+
#[test]
89+
fn test_emoji_handling() {
90+
new_ucmd!()
91+
.arg("/🌍/path/to/🦀.txt")
92+
.succeeds()
93+
.stdout_is("/🌍/path/to\n");
94+
95+
new_ucmd!()
96+
.arg("/🎉/path/to/🚀/")
97+
.succeeds()
98+
.stdout_is("/🎉/path/to\n");
99+
100+
new_ucmd!()
101+
.args(&["-z", "/🌟/emoji/path/🦋.file"])
102+
.succeeds()
103+
.stdout_is("/🌟/emoji/path\u{0}");
104+
}

tests/by-util/test_echo.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,3 +785,21 @@ fn test_escape_sequence_ctrl_c() {
785785
.success()
786786
.stdout_only("show");
787787
}
788+
789+
#[test]
790+
fn test_emoji_output() {
791+
new_ucmd!()
792+
.arg("Hello 🌍 World 🚀")
793+
.succeeds()
794+
.stdout_only("Hello 🌍 World 🚀\n");
795+
796+
new_ucmd!()
797+
.args(&["-n", "Status: 🎯 Complete"])
798+
.succeeds()
799+
.stdout_only("Status: 🎯 Complete");
800+
801+
new_ucmd!()
802+
.args(&["🦀", "loves", "🚀", "and", "🌟"])
803+
.succeeds()
804+
.stdout_only("🦀 loves 🚀 and 🌟\n");
805+
}

tests/by-util/test_env.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,17 @@ fn test_simulation_of_terminal_pty_pipes_into_data_and_sends_eot_automatically()
17551755
std::assert_eq!(String::from_utf8_lossy(out.stderr()), "");
17561756
}
17571757

1758+
#[test]
1759+
#[cfg(not(windows))]
1760+
fn test_emoji_env_vars() {
1761+
new_ucmd!()
1762+
.arg("🎯_VAR=Hello 🌍")
1763+
.arg("printenv")
1764+
.arg("🎯_VAR")
1765+
.succeeds()
1766+
.stdout_contains("Hello 🌍");
1767+
}
1768+
17581769
#[cfg(unix)]
17591770
#[test]
17601771
fn test_simulation_of_terminal_pty_write_in_data_and_sends_eot_automatically() {

tests/by-util/test_expr.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ fn test_simple_arithmetic() {
5858
.args(&["4", "/", "2"])
5959
.succeeds()
6060
.stdout_only("2\n");
61+
62+
new_ucmd!()
63+
.args(&["4", "=", "2"])
64+
.fails_with_code(1)
65+
.stdout_only("0\n");
66+
67+
new_ucmd!()
68+
.args(&["4", "=", "4"])
69+
.succeeds()
70+
.stdout_only("1\n");
6171
}
6272

6373
#[test]
@@ -1927,3 +1937,32 @@ mod gnu_expr_multibyte {
19271937
}
19281938
}
19291939
}
1940+
1941+
#[test]
1942+
fn test_emoji_operations() {
1943+
new_ucmd!()
1944+
.args(&["🚀", "=", "🚀"])
1945+
.succeeds()
1946+
.stdout_only("1\n");
1947+
1948+
new_ucmd!()
1949+
.args(&["🚀", "!=", "🚀"])
1950+
.fails()
1951+
.stdout_only("0\n");
1952+
1953+
new_ucmd!()
1954+
.args(&["🚀", "=", "🧨"])
1955+
.fails()
1956+
.stdout_only("0\n");
1957+
1958+
new_ucmd!()
1959+
.args(&["length", "🦀🚀🎯"])
1960+
.env("LC_ALL", "fr_FR.UTF-8")
1961+
.succeeds()
1962+
.stdout_only("3\n");
1963+
1964+
new_ucmd!()
1965+
.args(&["🌍", "!=", "🌎"])
1966+
.succeeds()
1967+
.stdout_only("1\n");
1968+
}

tests/by-util/test_fmt.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,3 +388,12 @@ fn test_fmt_non_utf8_paths() {
388388

389389
ucmd.arg(&filename).succeeds();
390390
}
391+
392+
#[test]
393+
fn fmt_reflow_unicode() {
394+
new_ucmd!()
395+
.args(&["-w", "4"])
396+
.pipe_in("漢字漢字 💐 日本語の文字\n")
397+
.succeeds()
398+
.stdout_is("漢字漢字\n💐\n日本語の文字\n");
399+
}

tests/by-util/test_printf.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,3 +1453,11 @@ fn non_utf_8_input() {
14531453
.fails()
14541454
.stderr_contains("expected a numeric value");
14551455
}
1456+
1457+
#[test]
1458+
fn test_emoji_formatting() {
1459+
new_ucmd!()
1460+
.args(&["Status: %s 🎯 Count: %d\n", "Success 🚀", "42"])
1461+
.succeeds()
1462+
.stdout_only("Status: Success 🚀 🎯 Count: 42\n");
1463+
}

tests/by-util/test_tail.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4946,3 +4946,12 @@ fn test_dev_zero() {
49464946
.succeeds()
49474947
.stdout_only("\0");
49484948
}
4949+
4950+
#[test]
4951+
fn tail_n_lines_with_emoji() {
4952+
new_ucmd!()
4953+
.args(&["-n", "1"])
4954+
.pipe_in("a\n💐\n")
4955+
.succeeds()
4956+
.stdout_only("💐\n");
4957+
}

0 commit comments

Comments
 (0)