forked from Chise7/ECE461_Team11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·79 lines (73 loc) · 2.22 KB
/
run
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
# make sure these environment variables are set
if [ -z ${GITHUB_TOKEN} ]; then
echo "ERROR: Missing environment variable \$GITHUB_TOKEN"
exit 1
elif [ -z ${LOG_FILE} ]; then
echo "ERROR: Missing environment variable \$LOG_FILE"
exit 1
elif [ -z ${LOG_LEVEL} ]; then
echo "ERROR: Missing environment variable \$LOG_LEVEL"
exit 1
fi
# make sure these files exist
if [ ! -f "requirements.txt" ]; then
echo "ERROR: Missing requirements.txt"
exit 1
elif [ ! -f "Cargo.toml" ]; then
echo "ERROR: Missing Cargo.toml"
exit 1
elif [ ! -f $LOG_FILE ]; then
touch $LOG_FILE &> /dev/null
fi
# handle command line arguments
if [ $# != 1 ]; then
echo "ERROR: Incorrect usage"
echo "USAGE:"
echo -e "\t./run build"
echo -e "\t./run install"
echo -e "\t./run test"
echo -e "\t./run <URL_FILE>"
exit 1
elif [ $1 == "help" -o $1 == "--help" -o $1 == "-h" ]; then
echo "USAGE:"
echo -e "\t./run build"
echo -e "\t./run install"
echo -e "\t./run test"
echo -e "\t./run <URL_FILE>"
exit 1
elif [ $1 == "install" ]; then
if [ -z ${VIRTUAL_ENV} ]; then
pip install --user --no-warn-script-location -r requirements.txt > temp
echo $(grep -c 'Collecting' temp) dependencies installed...
rm -f temp &> /dev/null
else
pip install --no-warn-script-location -r requirements.txt > temp
echo $(grep -c 'Collecting' temp) dependencies installed...
rm -f temp &> /dev/null
fi
exit 0
elif [ $1 == "build" ]; then
cargo build --release >> $LOG_FILE
exit 0
elif [ $1 == "test" ]; then
cargo build >> $LOG_FILE
make test-py-valid >> $LOG_FILE
passed=$(grep -c "PASSED" ${LOG_FILE})
failed=$(grep -c "FAILED" ${LOG_FILE})
total=$((${passed}+${failed}))
cov_line=$(grep "TOTAL" ${LOG_FILE})
coverage=${cov_line:62:2}
# something for rust
echo "Total: ${total}"
echo "Passed: ${passed}"
echo "Coverage: ${coverage}%"
echo "${passed}/${total} test cases passed. ${coverage}% line coverage achieved."
exit 0
else
if [ ! -f "target/release/ECE461_Team11" ]; then
cargo build --release >> $LOG_FILE
fi
./target/release/ECE461_Team11 $1
exit 0
fi