-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.sh
executable file
·86 lines (76 loc) · 2.2 KB
/
test.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
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
80
81
82
83
84
85
86
#!/usr/bin/env bash
########################
# Function
########################
function executeCommand () {
cmd=$1
echo "$ $cmd" && eval $cmd
}
function confirmTestCase {
msg=$1
id_start=$2
id_end=$3
re='^[0-9]+$'
while :
do
echo -en "${msg}"
read input
if [[ ${input} =~ $re ]] ; then
if ((${id_start} <= ${input})) && ((${input} <= ${id_end})); then
return ${input}
fi
else
echo -e "\nPlease input valid id."
fi
done
}
########################
# Variable
########################
test_cases=(
"tests.test_mdl.TestMusicDL"
"tests.test_mdl.TestMusicDL.test_youtube_playlist_random_generated"
"tests.test_mdl.TestMusicDL.test_youtube_playlist_contains_private"
"tests.test_mdl.TestMusicDL.test_youtube_playlist_contains_deleted"
"tests.test_mdl.TestMusicDL.test_youtube_single"
"tests.test_mdl.TestMusicDL.test_soundcloud_playlist"
"tests.test_mdl.TestMusicDL.test_soundcloud_single"
"tests.test_mdl.TestMusicDL.test_youtube_playlist_mp3"
"tests.test_mdl.TestMusicDL.test_youtube_playlist_flac"
"tests.test_mdl.TestMusicDL.test_soundcloud_playlist_mp3"
"tests.test_mdl.TestMusicDL.test_soundcloud_playlist_flac"
)
test_descriptions=(
"Test all cases."
"Test playlist randomly generated by YouTube."
"Test user playlist contains private video on YouTube."
"Test user playlist contains deleted video on YouTube."
"Test single song on YouTube."
"Test playlist on SoundCloud."
"Test single song on SoundCloud."
"Test flac format on YouTube."
"Test mp3 format on YouTube."
"Test flac format on SoundCloud."
"Test mp3 format on SoundCloud."
)
id_start=0
id_end=$((${#test_cases[@]} - 1))
########################
# Main
########################
# Print test cases
echo -e "\nUnite Test for MusicDownloader\n"
for i in "${!test_cases[@]}"; do
test_case=${test_descriptions[$i]}
test_descriptions=${test_cases[$i]}
printf "%4s %-54s %-60s" "[${i}]" "${test_descriptions[$i]}" "${test_cases[$i]}"
echo
done
# Print input dialog
msg="\nInput id to execute. [${id_start}-${id_end}]: "
confirmTestCase "${msg}" ${id_start} ${id_end}
index_to_execute=$?
# Execute command
echo
executeCommand "python setup.py test --test-suite ${test_cases[$index_to_execute]}\
"