remove trash + improve

This commit is contained in:
Roman Volovoy
2026-06-15 13:41:51 +02:00
parent c84c868441
commit db047fc9c2

72
aliases
View File

@@ -2,11 +2,6 @@ cc-clean(){
rm -rf ./**/*.out 2>/dev/null rm -rf ./**/*.out 2>/dev/null
} }
cc-delete-tests(){
rm -rf ./**/*.test.c
}
cc-run(){ cc-run(){
local file local file
if [ -z "$1" ]; then if [ -z "$1" ]; then
@@ -24,71 +19,8 @@ cc-run(){
norminette "${file}" -R CheckForbiddenSourceHeader norminette "${file}" -R CheckForbiddenSourceHeader
fi fi
cc -std=c99 "${file}" -o "${file}.out" -Wall -Wextra -Werror -fsanitize=address && \ cc "${file}" -o "${file}.out" -Wall -Wextra -Werror -g3 -fsanitize=address $@ && \
"./${file}.out" "$@" "./${file}.out"
cc-clean cc-clean
} }
cc-run-test-inline(){
local file
if [ -z "$1" ]; then
echo "Usage: cc-run <file> [args...]" >&2
return 1
fi
cc-clean
file="$1"
shift
if command -v norminette &>/dev/null
then
norminette "${file}"
fi
cc -std=c99 "${file}" -o "${file}.out" -Wall -Wextra -Werror -DTEST=please && \
"./${file}.out" "$@"
cc-clean
}
cc-test(){
local file
if [ -z "$1" ]; then
echo "Usage: cc-run <file> [args...]" >&2
return 1
fi
cc-clean
file="$1"
shift
# remove trailing .c if present
base="${file%.*}"
if command -v norminette &>/dev/null; then
norminette "${base}.c"
fi
# compile base.test.c -> base.test.out and run it
cc -std=c99 "${base}.test.c" -o "${base}.test.out" -Wall -Wextra -Werror &&
"./${base}.test.out" "$@"
cc-clean
}
cc-test-all() {
# find .c files, exclude those ending with .test.c
find . -type f -name '*.c' ! -name '*.test.c' -print0 |
while IFS= read -r -d '' file; do
echo -e "----------$file: TESTING-------------\n"
cc-test "$file" || {
echo -e "\n----------$file: DONE (NOT OK)-------"
# echo "cc-test failed for $file" >&2
return 1
}
echo -e "\n----------$file: DONE (OK)-----------"
done
}