-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·53 lines (40 loc) · 972 Bytes
/
run.sh
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
#!/bin/bash
set -euo pipefail
show_help () {
echo
echo "Run Project Euler solutions"
echo "==========================="
echo
echo "To run a problem: ./$(basename $0) 123"
echo "To run tests: ./$(basename $0) tests"
echo
}
if [[ $# -ne 1 ]]; then
show_help
exit 1
fi
DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SRC=src/solutions
BIN=bin
FILES=files
NUM=$1
if [[ $NUM = "tests" ]]; then
make tests
echo "Running c++ tests..."
for test in $(ls $BIN/test_*); do
./$test
done
echo "Running python tests..."
pytest
elif [[ -a $SRC/p$NUM.cxx ]]; then
make $BIN/p$NUM
echo "Running c++ solution #${NUM}..."
time $BIN/p$NUM
elif [[ -a $SRC/p$NUM.py ]]; then
echo "Running python solution #${NUM}..."
time FILES_DIR="$DIR/$FILES" python "$SRC/__main__.py" $NUM
else
>&2 echo "Error: No solution found for '${NUM}'."
show_help
exit 1
fi