diff options
author | EuAndreh <eu@euandre.org> | 2023-04-22 16:05:09 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-04-22 16:06:05 -0300 |
commit | 59396c99089ab67a748465f67c62280e50e791b4 (patch) | |
tree | 54f2acd6c9e12100aaa645fb95a82808cf204935 /opt | |
parent | etc/sh/rc: Also exclude vendor/ from tree(1) by default (diff) | |
download | dotfiles-59396c99089ab67a748465f67c62280e50e791b4.tar.gz dotfiles-59396c99089ab67a748465f67c62280e50e791b4.tar.xz |
bin/uninclude: Add new utility, with simple tests
Diffstat (limited to 'opt')
-rw-r--r-- | opt/resources/can-remove-stdbool.c | 12 | ||||
-rw-r--r-- | opt/resources/can-remove-stdbool.c.expected | 9 | ||||
-rw-r--r-- | opt/resources/nothing-can-be-removed.c | 7 | ||||
-rw-r--r-- | opt/resources/nothing-can-be-removed.c.expected | 7 | ||||
-rwxr-xr-x | opt/tests/uninclude.sh | 23 |
5 files changed, 58 insertions, 0 deletions
diff --git a/opt/resources/can-remove-stdbool.c b/opt/resources/can-remove-stdbool.c new file mode 100644 index 0000000..98338de --- /dev/null +++ b/opt/resources/can-remove-stdbool.c @@ -0,0 +1,12 @@ +#include <stdbool.h> + +#include <stdio.h> +#include <stdbool.h> + +#include <stdio.h> + +int +main(void) { + printf("Nothing to be removed.\n"); + return 0; +} diff --git a/opt/resources/can-remove-stdbool.c.expected b/opt/resources/can-remove-stdbool.c.expected new file mode 100644 index 0000000..f3da0d3 --- /dev/null +++ b/opt/resources/can-remove-stdbool.c.expected @@ -0,0 +1,9 @@ + + +#include <stdio.h> + +int +main(void) { + printf("Nothing to be removed.\n"); + return 0; +} diff --git a/opt/resources/nothing-can-be-removed.c b/opt/resources/nothing-can-be-removed.c new file mode 100644 index 0000000..773852f --- /dev/null +++ b/opt/resources/nothing-can-be-removed.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int +main(void) { + printf("Nothing to be removed.\n"); + return 0; +} diff --git a/opt/resources/nothing-can-be-removed.c.expected b/opt/resources/nothing-can-be-removed.c.expected new file mode 100644 index 0000000..773852f --- /dev/null +++ b/opt/resources/nothing-can-be-removed.c.expected @@ -0,0 +1,7 @@ +#include <stdio.h> + +int +main(void) { + printf("Nothing to be removed.\n"); + return 0; +} diff --git a/opt/tests/uninclude.sh b/opt/tests/uninclude.sh new file mode 100755 index 0000000..bb11f05 --- /dev/null +++ b/opt/tests/uninclude.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +git restore opt/resources/ + +# shellcheck disable=2086 +find opt/resources/ -name '*.c' | + sh ~/.usr/bin/uninclude -E '^#include ' -- cc $CFLAGS + +find opt/resources/ -name '*.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 + else + git restore "$file" + fi +done + +rm -f a.out |