Skip to content

Commit 51a52a1

Browse files
[RS] checker calculates score
1 parent 52bb73d commit 51a52a1

File tree

2 files changed

+53
-13
lines changed

2 files changed

+53
-13
lines changed

method-rs/check.sh

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,84 @@ YELLOW="\033[1;33m"
66
RESET="\033[0m"
77

88

9-
tasks=($(ls -1 ../tests/input | sed -E 's/task([0-9]+).*/\1/' | sort -n))
9+
tasks=( 1 2 3 4 5 6 7 8 9 10)
10+
points=(1 2 2 2 2 2 2 2 2 2)
11+
is_passed_task=(1 1 1 1 1 1 1 1 1 1)
1012

1113

1214

13-
for task in "${tasks[@]}"
15+
num_points=0
16+
17+
for (( i = 0; i < 10; ++i))
1418
do
15-
echo "................................TASK $task............................"
19+
idx_task=${tasks[$i]}
20+
test_points=${points[$i]}
21+
22+
23+
echo "................................TASK $idx_task................................."
1624

17-
tests=($(ls -1 ../tests/input/task$task | sed -E 's/\.in$//' | sort -n))
25+
tests=($(ls -1 ../tests/input/task$idx_task | sed -E 's/\.in$//' | sort -n))
1826

19-
for test in "${tests[@]}"
27+
for idx_test in "${tests[@]}"
2028
do
21-
echo -n "Test $test......................................................"
29+
echo -n "Test $idx_test......................................................"
2230

2331
# Run specific test case with `cargo`:
24-
cargo test test_task$task::case_$((test+1)) -- --exact > /dev/null 2>&1
32+
cargo test test_task$idx_task::case_$((idx_test+1)) -- --exact > /dev/null 2>&1
2533

2634
if [[ $? -ne 0 ]]
2735
then
28-
echo -e "${RED}FAILED${RESET}"
36+
echo -e "${RED}FAILED${RESET} 0/${test_points}p"
37+
is_passed_task[$i]=0
2938
else
30-
echo -e "${GREEN}passed${RESET}"
39+
num_points=$((num_points+test_points))
40+
echo -e "${GREEN}passed${RESET} ${test_points}/${test_points}p"
3141
fi
3242
done
3343
done
3444

3545

36-
echo "..............................CODING STYLE............................."
3746

47+
echo "................MORE points for solving tasks 7,8,9,10................."
48+
if [[ is_passed_task[6] -eq 1 && is_passed_task[7] -eq 1 && is_passed_task[8] -eq 1 && is_passed_task[9] -eq 1 ]]
49+
then
50+
num_points=$((num_points+10))
51+
echo -e "${GREEN}passed${RESET} 10/10p"
52+
else
53+
echo -e "${RED}FAIL${RESET} 0/10p"
54+
fi
55+
56+
57+
echo "..............................TASK README.............................."
58+
echo -n "Test README..............................................."
59+
60+
if [[ -f README || -f README.md ]]
61+
then
62+
num_points=$((num_points+10))
63+
echo -e "${GREEN}passed${RESET} 10/10p"
64+
else
65+
echo -e "${RED}FAILED${RESET} 0/10p"
66+
echo -e "\t[Suggestion] write a ${YELLOW}README.md${RESET} to describe your solution"
67+
fi
68+
69+
echo "..............................CODING STYLE............................."
3870
cargo fmt -- --check 2>&1 | tee coding_style.txt
3971
echo -n "Test Coding Style..........................................."
4072

4173

4274
if [[ $(cat coding_style.txt | wc -l ) -gt 0 ]]
4375
then
44-
echo -n "-20p "
45-
echo -e "${RED}FAILED${RESET}"
76+
num_points=$((num_points-20))
77+
echo -e "${RED}FAILED${RESET} -20p"
4678
echo -e "\t[Suggestion] run: ${YELLOW}cargo fmt${RESET}"
4779
else
4880
echo -e "${GREEN}passed${RESET}"
4981
fi
82+
83+
84+
if [[ $num_points -lt 0 ]]
85+
then
86+
num_points=0
87+
fi
88+
89+
echo "Total score: $num_points/100p"

method-rs/coding_style.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ Diff in /home/bogdan/Documents/Facultate/Blocks-in-3D/method-rs/src/libchunk/chu
635635
(B+ _height: &mut usize,
636636
(B+ _depth: &mut usize,
637637
(B ) {
638-
todo!("task 8");
638+
// TODO
639639
}
640640
Diff in /home/bogdan/Documents/Facultate/Blocks-in-3D/method-rs/src/libchunk/chunk_transform.rs:31:
641641
+

0 commit comments

Comments
 (0)