summaryrefslogtreecommitdiff
path: root/tests/header_test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/header_test.sh')
-rw-r--r--tests/header_test.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/header_test.sh b/tests/header_test.sh
new file mode 100644
index 0000000..6636418
--- /dev/null
+++ b/tests/header_test.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+# A host includes term.h and nothing else. The header compiles alone as
+# strict C11 and as C++, with only include/term on the include path.
+set -euo pipefail
+cd "${1:-$(dirname "$0")/..}"
+cc=${CC:-cc}
+cxx=${CXX:-c++}
+
+status=0
+echo '#include "term.h"' | "$cc" -std=c11 -Wall -Wextra -Wpedantic -Werror \
+ -Iinclude/term -x c -fsyntax-only - || { echo "term.h: not valid C11" >&2; status=1; }
+if command -v "$cxx" >/dev/null; then
+ echo '#include "term.h"' | "$cxx" -std=c++17 -Wall -Wextra -Wpedantic -Werror \
+ -Iinclude/term -x c++ -fsyntax-only - || { echo "term.h: not valid C++" >&2; status=1; }
+fi
+exit $status