58 lines
1.8 KiB
Makefile
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Copyright (c) 20242025 Emma Tebibyte <emma@tebibyte.media>
# SPDX-License-Identifier: FSFAP
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
# this notice are preserved. This file is offered as-is, without any warranty.
MM_FILE!=mktemp /tmp/mm.XXXXXX
.PHONY: mm_tests
mm_tests: mm_args mm_help mm_stderr mm_remaining mm_remaining_options
.PHONY: mm_none
mm_none: $(BIN)/mm
test "$$(printf 'meow\n' | $(BIN)/mm)" = meow
.PHONY: mm_args
# mm(1) will error if positional arguments are given without -i or -o
mm_args: $(BIN)/mm
! $(BIN)/mm argument
.PHONY: mm_help
mm_help: $(BIN)/mm
! $(BIN)/mm -h
.PHONY: mm_stderr
# check if stderr is empty upon specifying -e
mm_stderr: $(BIN)/mm
test "$$(printf 'test\n' | $(BIN)/mm -e 2>&1 >/dev/null )" = "test"
.PHONY: mm_remaining
# check to make sure remaining arguments are used
mm_remaining: $(BIN)/mm
test "$$($(BIN)/mm -i README COPYING)" = "$$(cat README COPYING)"
$(BIN)/mm -i README -o /tmp/mm_test0 /tmp/mm_test1
diff /tmp/mm_test0 /tmp/mm_test1
.PHONY: mm_remaining_options
# check to make sure mm -i with trailing arguments interprets -o as one
mm_remaining_options:
! $(BIN)/mm -i README COPYING -o - 2>&1 | cut -d: -f2 \
| xargs test " -o" =
.PHONY: mm_append
mm_append:
$(BIN)/mm -i /dev/null -o $(MM_FILE)
printf 'test\nstring\nmulti-line\n' | $(BIN)/mm -o $(MM_FILE)
printf 'new line\n' | $(BIN)/mm -a -o $(MM_FILE)
$(BIN)/mm -i $(MM_FILE) | wc -l | xargs test 4 -eq
.PHONY: mm_no_truncate
mm_no_truncate:
$(BIN)/mm -i /dev/null -o $(MM_FILE)
printf 'test\nstring\nmulti-line\n' | $(BIN)/mm -o $(MM_FILE)
printf 'new line\n' | $(BIN)/mm -t -o $(MM_FILE)
$(BIN)/mm -i $(MM_FILE) | wc -l | xargs test 3 -eq