2023-08-21 08:49:27 +00:00
|
|
|
// This file is part of the uutils coreutils package.
|
|
|
|
//
|
|
|
|
// For the full copyright and license information, please view the LICENSE
|
|
|
|
// file that was distributed with this source code.
|
2022-02-08 03:07:38 +00:00
|
|
|
// spell-checker:ignore (words) autoformat nocheck
|
2021-05-30 05:10:54 +00:00
|
|
|
|
2023-03-20 13:51:19 +00:00
|
|
|
use crate::common::util::TestScenario;
|
2022-02-08 03:07:38 +00:00
|
|
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
|
|
|
|
use std::fs::OpenOptions;
|
2022-01-21 19:22:11 +00:00
|
|
|
#[cfg(unix)]
|
|
|
|
use std::{ffi::OsStr, os::unix::ffi::OsStrExt};
|
|
|
|
#[cfg(windows)]
|
|
|
|
use std::{ffi::OsString, os::windows::ffi::OsStringExt};
|
2017-12-13 21:02:42 +00:00
|
|
|
|
2022-09-10 16:38:14 +00:00
|
|
|
#[test]
|
|
|
|
fn test_invalid_arg() {
|
|
|
|
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
|
|
|
}
|
|
|
|
|
2017-12-13 21:02:42 +00:00
|
|
|
#[test]
|
|
|
|
fn empty_files() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("empty.txt")
|
|
|
|
.arg("empty.txt")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only("");
|
2017-12-13 21:02:42 +00:00
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("empty.txt")
|
|
|
|
.arg("fields_1.txt")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only("");
|
2017-12-13 21:02:42 +00:00
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_1.txt")
|
|
|
|
.arg("empty.txt")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only("");
|
2017-12-13 21:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn empty_intersection() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_1.txt")
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("-2")
|
|
|
|
.arg("2")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only("");
|
2017-12-13 21:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn default_arguments() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_1.txt")
|
|
|
|
.arg("fields_2.txt")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("default.expected");
|
2017-12-13 21:02:42 +00:00
|
|
|
}
|
|
|
|
|
2024-10-06 09:48:08 +00:00
|
|
|
#[test]
|
|
|
|
fn only_whitespace_separators_merge() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("contiguous_separators.txt")
|
|
|
|
.arg("-")
|
|
|
|
.pipe_in(" a ,c ")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only("a ,,,b ,c \n");
|
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("contiguous_separators.txt")
|
|
|
|
.arg("-t")
|
|
|
|
.arg(",")
|
|
|
|
.arg("-")
|
|
|
|
.pipe_in(" a ,c ")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only(" a ,,,b,c \n");
|
|
|
|
}
|
|
|
|
|
2017-12-13 21:02:42 +00:00
|
|
|
#[test]
|
|
|
|
fn different_fields() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("fields_4.txt")
|
|
|
|
.arg("-j")
|
|
|
|
.arg("2")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("different_fields.expected");
|
2017-12-13 21:02:42 +00:00
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("fields_4.txt")
|
|
|
|
.arg("-1")
|
|
|
|
.arg("2")
|
|
|
|
.arg("-2")
|
|
|
|
.arg("2")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("different_fields.expected");
|
2017-12-13 21:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn different_field() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("fields_3.txt")
|
|
|
|
.arg("-2")
|
|
|
|
.arg("2")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("different_field.expected");
|
2017-12-13 21:02:42 +00:00
|
|
|
}
|
|
|
|
|
2022-01-17 04:21:39 +00:00
|
|
|
#[test]
|
|
|
|
fn out_of_bounds_fields() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_1.txt")
|
|
|
|
.arg("fields_4.txt")
|
|
|
|
.arg("-1")
|
|
|
|
.arg("3")
|
|
|
|
.arg("-2")
|
|
|
|
.arg("5")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("out_of_bounds_fields.expected");
|
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_1.txt")
|
|
|
|
.arg("fields_4.txt")
|
|
|
|
.arg("-j")
|
|
|
|
.arg("100000000000000000000") // > usize::MAX for 64 bits
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("out_of_bounds_fields.expected");
|
|
|
|
}
|
|
|
|
|
2017-12-13 21:02:42 +00:00
|
|
|
#[test]
|
|
|
|
fn unpaired_lines() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("fields_3.txt")
|
|
|
|
.arg("-a")
|
|
|
|
.arg("1")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("fields_2.txt");
|
2017-12-13 21:02:42 +00:00
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_3.txt")
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("-1")
|
|
|
|
.arg("2")
|
|
|
|
.arg("-a")
|
|
|
|
.arg("2")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("unpaired_lines.expected");
|
2021-08-13 03:32:29 +00:00
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_3.txt")
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("-1")
|
|
|
|
.arg("2")
|
|
|
|
.arg("-a")
|
|
|
|
.arg("1")
|
|
|
|
.arg("-a")
|
|
|
|
.arg("2")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("unpaired_lines_outer.expected");
|
2017-12-13 21:02:42 +00:00
|
|
|
}
|
|
|
|
|
2018-06-09 09:11:58 +00:00
|
|
|
#[test]
|
|
|
|
fn suppress_joined() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_3.txt")
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("-1")
|
|
|
|
.arg("2")
|
|
|
|
.arg("-v")
|
|
|
|
.arg("2")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("suppress_joined.expected");
|
2021-08-13 03:32:29 +00:00
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_3.txt")
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("-1")
|
|
|
|
.arg("2")
|
|
|
|
.arg("-a")
|
|
|
|
.arg("1")
|
|
|
|
.arg("-v")
|
|
|
|
.arg("2")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("suppress_joined_outer.expected");
|
2018-06-09 09:11:58 +00:00
|
|
|
}
|
|
|
|
|
2017-12-13 21:02:42 +00:00
|
|
|
#[test]
|
|
|
|
fn case_insensitive() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("capitalized.txt")
|
|
|
|
.arg("fields_3.txt")
|
|
|
|
.arg("-i")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("case_insensitive.expected");
|
2017-12-13 21:02:42 +00:00
|
|
|
}
|
2017-12-24 13:22:48 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn semicolon_separated() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("semicolon_fields_1.txt")
|
|
|
|
.arg("semicolon_fields_2.txt")
|
|
|
|
.arg("-t")
|
|
|
|
.arg(";")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("semicolon_separated.expected");
|
2017-12-24 13:22:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn new_line_separated() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("-")
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("-t")
|
|
|
|
.arg("")
|
|
|
|
.pipe_in("1 a\n1 b\n8 h\n")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only("1 a\n8 h\n");
|
2017-12-24 13:22:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-05-30 05:10:54 +00:00
|
|
|
fn tab_multi_character() {
|
2017-12-24 13:22:48 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg("semicolon_fields_1.txt")
|
|
|
|
.arg("semicolon_fields_2.txt")
|
|
|
|
.arg("-t")
|
2024-10-06 09:48:08 +00:00
|
|
|
.arg("ab")
|
2020-04-13 18:36:03 +00:00
|
|
|
.fails()
|
2024-10-06 09:48:08 +00:00
|
|
|
.stderr_is("join: multi-character tab ab\n");
|
2017-12-24 13:22:48 +00:00
|
|
|
}
|
2018-01-06 19:49:07 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn default_format() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_1.txt")
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("-o")
|
|
|
|
.arg("1.1 2.2")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("default.expected");
|
2018-01-06 19:49:07 +00:00
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_1.txt")
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("-o")
|
|
|
|
.arg("0 2.2")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("default.expected");
|
2018-01-06 19:49:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn unpaired_lines_format() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("fields_3.txt")
|
|
|
|
.arg("-a")
|
|
|
|
.arg("2")
|
|
|
|
.arg("-o")
|
|
|
|
.arg("1.2 1.1 2.4 2.3 2.2 0")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("unpaired_lines_format.expected");
|
2018-01-06 19:49:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn autoformat() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("different_lengths.txt")
|
|
|
|
.arg("-o")
|
|
|
|
.arg("auto")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("autoformat.expected");
|
2019-02-07 20:54:48 +00:00
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("-")
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("-o")
|
|
|
|
.arg("auto")
|
|
|
|
.pipe_in("1 x y z\n2 p")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only("1 x y z a\n2 p b\n");
|
2021-08-31 17:25:03 +00:00
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("-")
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("-a")
|
|
|
|
.arg("1")
|
|
|
|
.arg("-o")
|
|
|
|
.arg("auto")
|
|
|
|
.arg("-e")
|
|
|
|
.arg(".")
|
|
|
|
.pipe_in("1 x y z\n2 p\n99 a b\n")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only("1 x y z a\n2 p . . b\n99 a b . .\n");
|
2018-01-06 19:49:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn empty_format() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_1.txt")
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("-o")
|
|
|
|
.arg("")
|
2020-04-13 18:36:03 +00:00
|
|
|
.fails()
|
2023-01-05 20:09:15 +00:00
|
|
|
.stderr_is("join: invalid file number in field spec: ''\n");
|
2018-01-06 19:49:07 +00:00
|
|
|
}
|
2018-01-13 19:44:37 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn empty_key() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_1.txt")
|
|
|
|
.arg("empty.txt")
|
|
|
|
.arg("-j")
|
|
|
|
.arg("2")
|
|
|
|
.arg("-a")
|
|
|
|
.arg("1")
|
|
|
|
.arg("-e")
|
|
|
|
.arg("x")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("empty_key.expected");
|
2018-01-13 19:44:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn missing_format_fields() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("different_lengths.txt")
|
|
|
|
.arg("-o")
|
|
|
|
.arg("0 1.2 2.4")
|
|
|
|
.arg("-e")
|
|
|
|
.arg("x")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("missing_format_fields.expected");
|
2018-01-13 19:44:37 +00:00
|
|
|
}
|
2018-02-11 15:23:12 +00:00
|
|
|
|
2022-02-08 03:07:38 +00:00
|
|
|
#[test]
|
|
|
|
fn nocheck_order() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_1.txt")
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("--nocheck-order")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("default.expected");
|
|
|
|
}
|
|
|
|
|
2018-02-11 15:23:12 +00:00
|
|
|
#[test]
|
|
|
|
fn wrong_line_order() {
|
2022-01-21 02:44:30 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2018-02-11 15:23:12 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("fields_4.txt")
|
2020-04-13 18:36:03 +00:00
|
|
|
.fails()
|
2022-02-08 03:07:38 +00:00
|
|
|
.stdout_contains("7 g f 4 fg")
|
2024-07-18 13:38:10 +00:00
|
|
|
.stderr_is(format!(
|
2023-01-05 20:09:15 +00:00
|
|
|
"{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order\n",
|
2022-02-08 03:07:38 +00:00
|
|
|
ts.bin_path.to_string_lossy(),
|
|
|
|
ts.util_name
|
|
|
|
));
|
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("--check-order")
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.arg("fields_4.txt")
|
|
|
|
.fails()
|
|
|
|
.stdout_does_not_contain("7 g f 4 fg")
|
2024-07-18 13:38:10 +00:00
|
|
|
.stderr_is(format!(
|
2023-01-05 20:09:15 +00:00
|
|
|
"{0}: fields_4.txt:5: is not sorted: 11 g 5 gh\n",
|
2022-02-08 03:07:38 +00:00
|
|
|
ts.util_name
|
|
|
|
));
|
2022-01-22 22:50:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn both_files_wrong_line_order() {
|
|
|
|
let ts = TestScenario::new(util_name!());
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_4.txt")
|
|
|
|
.arg("fields_5.txt")
|
|
|
|
.fails()
|
2022-02-08 03:07:38 +00:00
|
|
|
.stdout_contains("5 e 3 ef")
|
2024-07-18 13:38:10 +00:00
|
|
|
.stderr_is(format!(
|
2023-01-05 20:09:15 +00:00
|
|
|
"{0} {1}: fields_5.txt:4: is not sorted: 3\n{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order\n",
|
2022-01-21 02:44:30 +00:00
|
|
|
ts.bin_path.to_string_lossy(),
|
|
|
|
ts.util_name
|
|
|
|
));
|
2022-02-08 03:07:38 +00:00
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("--check-order")
|
|
|
|
.arg("fields_4.txt")
|
|
|
|
.arg("fields_5.txt")
|
|
|
|
.fails()
|
|
|
|
.stdout_does_not_contain("5 e 3 ef")
|
2024-07-18 13:38:10 +00:00
|
|
|
.stderr_is(format!(
|
2023-01-05 20:09:15 +00:00
|
|
|
"{0}: fields_5.txt:4: is not sorted: 3\n",
|
2022-02-08 03:07:38 +00:00
|
|
|
ts.util_name
|
|
|
|
));
|
2018-02-11 15:23:12 +00:00
|
|
|
}
|
2018-04-11 19:55:44 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn headers() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("header_1.txt")
|
|
|
|
.arg("header_2.txt")
|
|
|
|
.arg("--header")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("header.expected");
|
2018-04-11 19:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn headers_autoformat() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("header_1.txt")
|
|
|
|
.arg("header_2.txt")
|
|
|
|
.arg("--header")
|
|
|
|
.arg("-o")
|
|
|
|
.arg("auto")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("header_autoformat.expected");
|
2018-04-11 19:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn single_file_with_header() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("capitalized.txt")
|
|
|
|
.arg("empty.txt")
|
|
|
|
.arg("--header")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_is("A 1\n");
|
2018-04-11 19:55:44 +00:00
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("empty.txt")
|
|
|
|
.arg("capitalized.txt")
|
|
|
|
.arg("--header")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_is("A 1\n");
|
2018-04-11 19:55:44 +00:00
|
|
|
}
|
2022-01-09 00:23:02 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn non_line_feeds() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("non-line_feeds_1.txt")
|
|
|
|
.arg("non-line_feeds_2.txt")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("non-line_feeds.expected");
|
|
|
|
}
|
2022-01-09 02:28:29 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn non_unicode() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("non-unicode_1.bin")
|
|
|
|
.arg("non-unicode_2.bin")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("non-unicode.expected");
|
2022-01-21 19:22:11 +00:00
|
|
|
|
|
|
|
#[cfg(unix)]
|
|
|
|
{
|
2024-10-06 09:48:08 +00:00
|
|
|
let non_utf8_byte: u8 = 167;
|
2022-01-21 19:22:11 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg("-t")
|
2024-10-06 09:48:08 +00:00
|
|
|
.arg(OsStr::from_bytes(&[non_utf8_byte]))
|
2022-01-21 19:22:11 +00:00
|
|
|
.arg("non-unicode_1.bin")
|
|
|
|
.arg("non-unicode_2.bin")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("non-unicode_sep.expected");
|
2024-10-06 09:48:08 +00:00
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("-t")
|
|
|
|
.arg(OsStr::from_bytes(&[non_utf8_byte, non_utf8_byte]))
|
|
|
|
.arg("non-unicode_1.bin")
|
|
|
|
.arg("non-unicode_2.bin")
|
|
|
|
.fails()
|
|
|
|
.stderr_is("join: non-UTF-8 multi-byte tab\n");
|
2022-01-21 19:22:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(windows)]
|
|
|
|
{
|
|
|
|
let invalid_utf16: OsString = OsStringExt::from_wide(&[0xD800]);
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("-t")
|
|
|
|
.arg(&invalid_utf16)
|
|
|
|
.arg("non-unicode_1.bin")
|
|
|
|
.arg("non-unicode_2.bin")
|
|
|
|
.fails()
|
|
|
|
.stderr_is(
|
2023-01-05 20:09:15 +00:00
|
|
|
"join: unprintable field separators are only supported on unix-like platforms\n",
|
2022-01-21 19:22:11 +00:00
|
|
|
);
|
|
|
|
}
|
2022-01-09 02:28:29 +00:00
|
|
|
}
|
2022-01-06 04:26:12 +00:00
|
|
|
|
2024-10-06 09:48:08 +00:00
|
|
|
#[test]
|
|
|
|
fn multibyte_sep() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("-t§")
|
|
|
|
.arg("multibyte_sep_1.txt")
|
|
|
|
.arg("multibyte_sep_2.txt")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("multibyte_sep.expected");
|
|
|
|
}
|
|
|
|
|
2022-01-06 07:20:01 +00:00
|
|
|
#[test]
|
|
|
|
fn null_field_separators() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("-t")
|
|
|
|
.arg("\\0")
|
|
|
|
.arg("non-unicode_1.bin")
|
|
|
|
.arg("non-unicode_2.bin")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("null-sep.expected");
|
|
|
|
}
|
2022-01-17 11:59:52 +00:00
|
|
|
|
2022-01-06 04:26:12 +00:00
|
|
|
#[test]
|
|
|
|
fn null_line_endings() {
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("-z")
|
|
|
|
.arg("non-unicode_1.bin")
|
|
|
|
.arg("non-unicode_2.bin")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("z.expected");
|
|
|
|
}
|
2022-02-08 03:07:38 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
|
|
|
|
fn test_full() {
|
|
|
|
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
|
|
|
|
new_ucmd!()
|
|
|
|
.arg("fields_1.txt")
|
|
|
|
.arg("fields_2.txt")
|
|
|
|
.set_stdout(dev_full)
|
|
|
|
.fails()
|
|
|
|
.stderr_contains("No space left on device");
|
|
|
|
}
|