Compare commits
No commits in common. "fe80bfc2feb745265cffadca86cc26d62735d0a8" and "dea9ea660e0bd494aa0389ba3c31b269fa6eb8c2" have entirely different histories.
fe80bfc2fe
...
dea9ea660e
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1 @@
|
|||||||
a.out
|
a.out
|
||||||
main
|
|
||||||
debug
|
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
image: ${CI_REGISTRY}/ict/images/alpine/ci:latest
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
apk add build-base bash
|
|
||||||
|
|
||||||
validate_code:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- chmod +x ./test/main.sh
|
|
||||||
- ./test/main.sh
|
|
82
test/main.sh
82
test/main.sh
@ -1,82 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
CC_COMMAND='g++ -Wall -Wextra -Werror -pedantic -D__PROGTEST__'
|
|
||||||
|
|
||||||
RED="\e[31m"
|
|
||||||
GREEN="\e[32m"
|
|
||||||
YELLOW="\e[33m"
|
|
||||||
RESET="\e[0m"
|
|
||||||
|
|
||||||
EXIT_STATUS=0
|
|
||||||
|
|
||||||
_log() {
|
|
||||||
# 0 => Okay / Green
|
|
||||||
# 1 => Warn / Yellow
|
|
||||||
# 2 => Fail / Red
|
|
||||||
local log_level="$1"
|
|
||||||
local log_message="$2"
|
|
||||||
|
|
||||||
local log_color=""
|
|
||||||
local log_level_name=""
|
|
||||||
case "$log_level" in
|
|
||||||
0)
|
|
||||||
log_color="$GREEN"
|
|
||||||
log_level_name="OKAY"
|
|
||||||
;;
|
|
||||||
1)
|
|
||||||
log_color="$YELLOW"
|
|
||||||
log_level_name="WARN"
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
log_color="$RED"
|
|
||||||
log_level_name="FAIL"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
printf "[${log_color}${log_level_name}${RESET}] %s\n" "$log_message"
|
|
||||||
}
|
|
||||||
|
|
||||||
for dir in homework-* exercise-*; do
|
|
||||||
if ! cd "$dir" > /dev/null; then
|
|
||||||
_log 2 "Couldn't cd into $dir"
|
|
||||||
cd ..
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -f ./main.c ]]; then
|
|
||||||
_log 1 "No main.c file in $dir"
|
|
||||||
cd ..
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! eval "$CC_COMMAND main.c"; then
|
|
||||||
_log 2 "Failed to compile code in $dir"
|
|
||||||
cd ..
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
failed_inputs=0
|
|
||||||
for input in test_data/*_in.txt; do
|
|
||||||
|
|
||||||
input_file=${input//*\/}
|
|
||||||
test_case_number=${input_file%%_in.txt}
|
|
||||||
|
|
||||||
command_output="$(diff <(./a.out < "test_data/${test_case_number}_in.txt") "test_data/${test_case_number}_out.txt")"
|
|
||||||
|
|
||||||
if [[ ! "$?" ]]; then
|
|
||||||
EXIT_STATUS=1
|
|
||||||
((failed_inputs++))
|
|
||||||
_log 2 "$dir (#$test_case_number)"
|
|
||||||
echo "$command_output"
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
if ((failed_inputs == 0)); then
|
|
||||||
_log 0 "$dir"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd .. > /dev/null
|
|
||||||
done
|
|
||||||
|
|
||||||
exit $EXIT_STATUS
|
|
Loading…
x
Reference in New Issue
Block a user