aboutsummaryrefslogtreecommitdiff
path: root/opt/tests/uninclude.sh
blob: 0a5d41eb393b665fe54a35f4abcaa2b160434d34 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
set -eu

find opt/resources/ -name '*.c' | sed 's/^\(.*\)\.c$/cp \1.c \1.copy/g' | sh

# shellcheck disable=2086
find opt/resources/ -name '*.copy' |
	uninclude -E '^#include ' -- $CC $CFLAGS -c

find opt/resources/ -name '*.copy' | while read -r file; do
	if ! cmp -s "$file" "$file".expected; then
		cat <<-EOF
			The unincluded file is different from expected.

			See with:
			  $ diff -U5 $file.expected $file
		EOF
		exit 1
	fi
done

rm -f a.out