-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrun_all_examples.sh
More file actions
executable file
·54 lines (42 loc) · 976 Bytes
/
run_all_examples.sh
File metadata and controls
executable file
·54 lines (42 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
set -euo pipefail
use_poetry=true
if [[ "${1:-}" == "--no-poetry" ]]; then
use_poetry=false
fi
readonly use_poetry
function check_puzzle_code() {
local puzzle_str="$1"
readonly puzzle_str
if ! echo -e "2\nPiotr" | python3 -c "${puzzle_str}"
then
return 1
fi
if echo -e "3" | python3 -c "${puzzle_str}"
then
return 2
fi
if echo -e "2\nWrong!" | python3 -c "${puzzle_str}"
then
return 3
fi
return 0
}
function check_example() {
local example_file="$1"
printf "Checking \"%s\"\n" "${example_file}"
readonly example_file
local puzzle_str
if ${use_poetry}; then
puzzle_str=$(poetry run python3 "${example_file}")
else
puzzle_str=$(python3 "${example_file}")
fi
readonly puzzle_str
check_puzzle_code "${puzzle_str}"
return 0
}
cd examples/
find . -name "*.py" | while read -r file; do
check_example "${file}"
done