1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

Add initial test for tsort.

This commit is contained in:
Joseph Crail 2015-05-09 23:38:48 -04:00
parent 1f67aaaf8c
commit 82dbd02c03
4 changed files with 66 additions and 0 deletions

View file

@ -179,6 +179,7 @@ TEST_PROGS := \
tr \
true \
truncate \
tsort \
unexpand
TEST ?= $(TEST_PROGS)

17
test/fixtures/tsort/call_graph.expected vendored Normal file
View file

@ -0,0 +1,17 @@
main
parse_options
tail_file
tail_forever
tail
recheck
write_header
tail_lines
tail_bytes
pretty_name
start_lines
file_lines
pipe_lines
xlseek
start_bytes
pipe_bytes
dump_remainder

22
test/fixtures/tsort/call_graph.txt vendored Normal file
View file

@ -0,0 +1,22 @@
main parse_options
main tail_file
main tail_forever
tail_file pretty_name
tail_file write_header
tail_file tail
tail_forever recheck
tail_forever pretty_name
tail_forever write_header
tail_forever dump_remainder
tail tail_lines
tail tail_bytes
tail_lines start_lines
tail_lines dump_remainder
tail_lines file_lines
tail_lines pipe_lines
tail_bytes xlseek
tail_bytes start_bytes
tail_bytes dump_remainder
tail_bytes pipe_bytes
file_lines dump_remainder
recheck pretty_name

26
test/tsort.rs Normal file
View file

@ -0,0 +1,26 @@
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::process::Command;
static PROGNAME: &'static str = "./tsort";
fn get_file_contents(name: &str) -> Vec<u8> {
let mut f = File::open(Path::new(name)).unwrap();
let mut contents: Vec<u8> = vec!();
let _ = f.read_to_end(&mut contents);
contents
}
#[test]
fn test_sort_call_graph() {
let input = "call_graph.txt";
let output = "call_graph.expected";
let po = Command::new(PROGNAME)
.arg(input)
.output()
.unwrap_or_else(|err| panic!("{}", err));
assert_eq!(String::from_utf8(po.stdout).unwrap(), String::from_utf8(get_file_contents(output)).unwrap());
}