mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
add cat support for unix domain sockets
- adds conditional supports for unix domain sockets - adds unix domain socket test - adds Results to functions, removing unwraps - uutils `cat` used to panic on broken stdout pipes (e.g. `cat /dev/zero | head -c1`). this is fixed in this PR - updated to exit 0 on success, and 1 if an error occurs. - adds docstrings - adds an error log on printing a directory - adds categorization of other filetypes for extensible differentiation of behaviors - adds OutputOptions struct to replace params for extensibility - adds correct status code on exit
This commit is contained in:
parent
62d5a6bbc8
commit
133934f7cf
5 changed files with 374 additions and 109 deletions
|
@ -1,5 +1,8 @@
|
|||
use common::util::*;
|
||||
#[cfg(unix)]
|
||||
extern crate unix_socket;
|
||||
extern crate tempdir;
|
||||
|
||||
use common::util::*;
|
||||
|
||||
#[test]
|
||||
fn test_output_multi_files_print_all_chars() {
|
||||
|
@ -113,7 +116,7 @@ fn test_non_blank_overrides_number() {
|
|||
.pipe_in("\na\nb\n\n\nc")
|
||||
.succeeds()
|
||||
.stdout_only("\n 1\ta\n 2\tb\n\n\n 3\tc");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -126,3 +129,30 @@ fn test_squeeze_blank_before_numbering() {
|
|||
.stdout_only(" 1\ta\n 2\t\n 3\tb");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
#[cfg(foo)]
|
||||
fn test_domain_socket() {
|
||||
use std::thread;
|
||||
use self::unix_socket::UnixListener;
|
||||
use self::tempdir::TempDir;
|
||||
use std::io::prelude::*;
|
||||
|
||||
let dir = TempDir::new("unix_socket").expect("failed to create dir");
|
||||
let socket_path = dir.path().join("sock");
|
||||
let listener = UnixListener::bind(&socket_path).expect("failed to create socket");
|
||||
|
||||
let thread = thread::spawn(move || {
|
||||
let mut stream = listener.accept().expect("failed to accept connection").0;
|
||||
stream.write_all(b"a\tb").expect("failed to write test data");
|
||||
});
|
||||
|
||||
new_ucmd!()
|
||||
.args(&[socket_path])
|
||||
.succeeds()
|
||||
.stdout_only("a\tb");
|
||||
|
||||
thread.join().unwrap();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue