summaryrefslogtreecommitdiff
path: root/tests/header_test.sh
blob: 6636418ed7d3fa4e79ba14c181f1ae25428e3e48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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