tests, Makefile: cleaning up

This commit is contained in:
Emma Tebibyte 2024-08-09 23:50:31 -06:00
parent 66f809162b
commit b76ff8fd90
Signed by untrusted user: emma
GPG Key ID: 06FA419A1698C270
5 changed files with 14 additions and 9 deletions

View File

@ -57,6 +57,8 @@ dist: all docs
install: dist install: dist
cp -r $(DESTDIR)/* / cp -r $(DESTDIR)/* /
include tests/tests.mk
.PHONY: test .PHONY: test
test: all $(TESTS) /tmp/getopt test: all $(TESTS) /tmp/getopt
@echo $(TESTS) @echo $(TESTS)
@ -156,5 +158,3 @@ build/bin/swab: src/swab.rs build rustlibs
true: build/bin/true true: build/bin/true
build/bin/true: src/true.c build build/bin/true: src/true.c build
$(CC) $(CFLAGS) -o $@ src/true.c $(CC) $(CFLAGS) -o $@ src/true.c
include tests/tests.mk

View File

@ -27,7 +27,7 @@ extern crate strerror;
extern crate sysexits; extern crate sysexits;
use strerror::StrError; 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 */ /* list of SI prefixes */
const LIST: [(u32, &str); 10] = [ const LIST: [(u32, &str); 10] = [
@ -76,6 +76,10 @@ fn convert(input: u128) -> Result<(f64, (u32, &'static str)), String> {
fn main() -> ExitCode { fn main() -> ExitCode {
let argv = args().collect::<Vec<String>>(); 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(); let mut buf = String::new();
while let Ok(_) = stdin().read_line(&mut buf) { while let Ok(_) = stdin().read_line(&mut buf) {

View File

@ -14,7 +14,7 @@ fop_help: $(BIN)/fop
.PHONY: fop_delimiter .PHONY: fop_delimiter
fop_delimiter: $(BIN)/fop 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' = 'test1 test1 test4'
test "$$(printf 'meowsetwoofsetribbit\n' \ test "$$(printf 'meowsetwoofsetribbit\n' \
| $(BIN)/fop -d 'set' 1 sed 's/woof/meow/g')" = 'meowsetmeowsetribbit' | $(BIN)/fop -d 'set' 1 sed 's/woof/meow/g')" = 'meowsetmeowsetribbit'

View File

@ -6,7 +6,7 @@
# notice are preserved. This file is offered as-is, without any warranty. # notice are preserved. This file is offered as-is, without any warranty.
.PHONY: hru_tests .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 .PHONY: hru_help
hru_help: $(BIN)/hru hru_help: $(BIN)/hru
@ -14,8 +14,8 @@ hru_help: $(BIN)/hru
.PHONY: hru_functionality .PHONY: hru_functionality
hru_functionality: $(BIN)/hru hru_functionality: $(BIN)/hru
test "$(printf '1234\n' | $(BIN)/hru)" = '1.2 kB' test "$$(printf '1234\n' | $(BIN)/hru)" = '1.2 kB'
test "$(printf '0\n' | $(BIN)/hru)" = '0 B' test "$$(printf '0\n' | $(BIN)/hru)" = '0 B'
.PHONY: hru_negative .PHONY: hru_negative
hru_negative: $(BIN)/hru hru_negative: $(BIN)/hru
@ -25,7 +25,8 @@ hru_negative: $(BIN)/hru
hru_regressions: $(BIN)/hru hru_regressions: $(BIN)/hru
n=1; \ n=1; \
while true; \ while true; \
do n="$$(($$n * 10))"; \ do \
printf '%s\n' "$$n" | $(BIN)/hru || break; \ printf '%s\n' "$$n" | $(BIN)/hru || break; \
n="$$(($$n * 10))"; \
done; \ done; \
printf 'Max float: %s\n' "$$n" printf 'Max float: %s\n' "$$n"

View File

@ -24,4 +24,4 @@ mm_help: $(BIN)/mm
.PHONY: mm_stderr .PHONY: mm_stderr
# check if stderr is empty upon specifying -e # check if stderr is empty upon specifying -e
mm_stderr: $(BIN)/mm 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"