tests, Makefile: cleaning up
This commit is contained in:
parent
66f809162b
commit
b76ff8fd90
4
Makefile
4
Makefile
@ -57,6 +57,8 @@ dist: all docs
|
||||
install: dist
|
||||
cp -r $(DESTDIR)/* /
|
||||
|
||||
include tests/tests.mk
|
||||
|
||||
.PHONY: test
|
||||
test: all $(TESTS) /tmp/getopt
|
||||
@echo $(TESTS)
|
||||
@ -156,5 +158,3 @@ build/bin/swab: src/swab.rs build rustlibs
|
||||
true: build/bin/true
|
||||
build/bin/true: src/true.c build
|
||||
$(CC) $(CFLAGS) -o $@ src/true.c
|
||||
|
||||
include tests/tests.mk
|
||||
|
@ -27,7 +27,7 @@ extern crate strerror;
|
||||
extern crate sysexits;
|
||||
|
||||
use strerror::StrError;
|
||||
use sysexits::{ EX_DATAERR, EX_IOERR, EX_SOFTWARE };
|
||||
use sysexits::{ EX_DATAERR, EX_IOERR, EX_SOFTWARE, EX_USAGE };
|
||||
|
||||
/* list of SI prefixes */
|
||||
const LIST: [(u32, &str); 10] = [
|
||||
@ -76,6 +76,10 @@ fn convert(input: u128) -> Result<(f64, (u32, &'static str)), String> {
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let argv = args().collect::<Vec<String>>();
|
||||
if let Some(_) = argv.get(1) {
|
||||
eprintln!("Usage: {}", argv[0]);
|
||||
return ExitCode::from(EX_USAGE as u8);
|
||||
}
|
||||
let mut buf = String::new();
|
||||
|
||||
while let Ok(_) = stdin().read_line(&mut buf) {
|
||||
|
@ -14,7 +14,7 @@ fop_help: $(BIN)/fop
|
||||
|
||||
.PHONY: fop_delimiter
|
||||
fop_delimiter: $(BIN)/fop
|
||||
test "$$(printf 'test1 test1 test1\n' | $(BIN)/fop -d' ' 2 sed 's/2/4/g')" \
|
||||
test "$$(printf 'test1 test1 test1\n' | $(BIN)/fop -d' ' 2 sed 's/1/4/g')" \
|
||||
= 'test1 test1 test4'
|
||||
test "$$(printf 'meowsetwoofsetribbit\n' \
|
||||
| $(BIN)/fop -d 'set' 1 sed 's/woof/meow/g')" = 'meowsetmeowsetribbit'
|
||||
|
@ -6,7 +6,7 @@
|
||||
# notice are preserved. This file is offered as-is, without any warranty.
|
||||
|
||||
.PHONY: hru_tests
|
||||
hru_tests: hru_help hru_functionality hru_negative hru_regression
|
||||
hru_tests: hru_help hru_functionality hru_negative hru_regressions
|
||||
|
||||
.PHONY: hru_help
|
||||
hru_help: $(BIN)/hru
|
||||
@ -14,8 +14,8 @@ hru_help: $(BIN)/hru
|
||||
|
||||
.PHONY: hru_functionality
|
||||
hru_functionality: $(BIN)/hru
|
||||
test "$(printf '1234\n' | $(BIN)/hru)" = '1.2 kB'
|
||||
test "$(printf '0\n' | $(BIN)/hru)" = '0 B'
|
||||
test "$$(printf '1234\n' | $(BIN)/hru)" = '1.2 kB'
|
||||
test "$$(printf '0\n' | $(BIN)/hru)" = '0 B'
|
||||
|
||||
.PHONY: hru_negative
|
||||
hru_negative: $(BIN)/hru
|
||||
@ -25,7 +25,8 @@ hru_negative: $(BIN)/hru
|
||||
hru_regressions: $(BIN)/hru
|
||||
n=1; \
|
||||
while true; \
|
||||
do n="$$(($$n * 10))"; \
|
||||
do \
|
||||
printf '%s\n' "$$n" | $(BIN)/hru || break; \
|
||||
n="$$(($$n * 10))"; \
|
||||
done; \
|
||||
printf 'Max float: %s\n' "$$n"
|
||||
|
@ -24,4 +24,4 @@ mm_help: $(BIN)/mm
|
||||
.PHONY: mm_stderr
|
||||
# check if stderr is empty upon specifying -e
|
||||
mm_stderr: $(BIN)/mm
|
||||
! test "$$(printf 'test\n' | $(BIN)/mm -i - -e 2>&1 >/dev/null)" = "test"
|
||||
! test "$$(printf 'test\n' | $(BIN)/mm -e 2>&1 >/dev/null)" = "test"
|
||||
|
Loading…
Reference in New Issue
Block a user