remove trash + improve
This commit is contained in:
72
aliases
72
aliases
@@ -2,11 +2,6 @@ cc-clean(){
|
||||
rm -rf ./**/*.out 2>/dev/null
|
||||
}
|
||||
|
||||
cc-delete-tests(){
|
||||
rm -rf ./**/*.test.c
|
||||
}
|
||||
|
||||
|
||||
cc-run(){
|
||||
local file
|
||||
if [ -z "$1" ]; then
|
||||
@@ -24,71 +19,8 @@ cc-run(){
|
||||
norminette "${file}" -R CheckForbiddenSourceHeader
|
||||
fi
|
||||
|
||||
cc -std=c99 "${file}" -o "${file}.out" -Wall -Wextra -Werror -fsanitize=address && \
|
||||
"./${file}.out" "$@"
|
||||
cc "${file}" -o "${file}.out" -Wall -Wextra -Werror -g3 -fsanitize=address $@ && \
|
||||
"./${file}.out"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user