summaryrefslogtreecommitdiff
path: root/tests/t0053-interface-cleanup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/t0053-interface-cleanup.sh')
-rwxr-xr-xtests/t0053-interface-cleanup.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/t0053-interface-cleanup.sh b/tests/t0053-interface-cleanup.sh
new file mode 100755
index 0000000..80d5410
--- /dev/null
+++ b/tests/t0053-interface-cleanup.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+set -eu
+base="${TMPDIR-/tmp}/mcpu-cpp-interface-cleanup-$$"
+mkdir -p "$base/wrapper" "$base/after"
+trap 'rm -rf "$base"' EXIT HUP INT TERM
+
+# --version identifies the independent MCPU languages preprocessor.
+"$MCPU_CPP" --version > "$base/version"
+printf '%s\n' 'mcpu-cpp 1.0.2' 'MCPU languages preprocessor' > "$base/version.expected"
+cmp "$base/version.expected" "$base/version"
+
+# --help contains the current public interface, including --object-suffix,
+# and puts the stdin/stdout notes after the option list.
+"$MCPU_CPP" --help > "$base/help"
+grep '^mcpu-cpp 1\.0\.2$' "$base/help" >/dev/null
+grep '^MCPU languages preprocessor$' "$base/help" >/dev/null
+grep '^ --object-suffix SFX set object suffix used for dependency targets$' "$base/help" >/dev/null
+help_version_line=$(grep -n '^ --version ' "$base/help" | cut -d: -f1)
+input_note_line=$(grep -n "^If input is omitted or '-', read standard input\.$" "$base/help" | cut -d: -f1)
+test "$input_note_line" -gt "$help_version_line"
+
+grep "^If output is omitted or '-', write standard output\.$" "$base/help" >/dev/null
+
+# --object-suffix requires an argument and changes the default dependency target.
+cat > "$base/object.c" <<'SRC'
+int x;
+SRC
+if "$MCPU_CPP" --no-config --object-suffix > /dev/null 2> "$base/object.err"; then
+ echo '--object-suffix unexpectedly accepted without an argument' >&2
+ exit 1
+fi
+grep "argument missing after '--object-suffix'" "$base/object.err" >/dev/null
+"$MCPU_CPP" --no-config --object-suffix .obj -M "$base/object.c" > "$base/object.d"
+grep '^object\.obj:' "$base/object.d" >/dev/null