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

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

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

find opt/resources/ -name '*.copy.c' | 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 -- *.o