forked from BugSwarm/bugswarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_through.sh
executable file
·62 lines (46 loc) · 1.93 KB
/
run_through.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
#!/usr/bin/env bash
# Get the absolute path to the directory containing this script. Source: https://stackoverflow.com/a/246128.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Include common functions and constants.
source "${SCRIPT_DIR}"/common.sh
USAGE='Usage: bash run_through.sh -r <repo-slug> [-t <threads>] [-c <component-directory>]'
# Extract command line arguments.
OPTS=$(getopt -o c:r:t: --long component-directory:,repo:,threads: -n 'run-through' -- "$@")
while true; do
case "$1" in
# Shift twice for options that take an argument.
-c | --component-directory ) component_directory="$2"; shift; shift ;;
-r | --repo ) repo="$2"; shift; shift ;;
-t | --threads ) threads="$2"; shift; shift ;;
-- ) shift; break ;;
* ) break ;;
esac
done
# Perform checks and set defaults for command line arguments.
if [ -z "${repo}" ]; then
echo ${USAGE}
exit 1
fi
if [[ -z "${threads}" ]]; then
echo 'The number of threads is not specified. Defaulting to 1 thread.'
threads=1
fi
if [[ -z "${component_directory}" ]]; then
component_directory="/home/$(whoami)/bugswarm"
fi
if [[ ${repo} != *"/"* ]]; then
echo 'The repo slug must be in the form <username>/<project> (e.g. google/guice). Exiting.'
exit 1
fi
# The task name is the repo slug after replacing slashes with hypens.
if [ ${repo} ]; then
task_name="$(echo ${repo} | tr / -)"
fi
reproducer_dir="${component_directory}"/reproducer
# Check for existence of the required repositories.
check_repo_exists ${reproducer_dir} 'reproducer'
# Mine pairs from the project.
bash "${SCRIPT_DIR}"/run_mine_project.sh -r ${repo} -t ${threads} -c "${component_directory}"
# Reproduce all pairs mined from the project.
bash "${SCRIPT_DIR}"/run_reproduce_project.sh -r ${repo} -t ${threads} -c "${component_directory}"
print_done_message 'The pipeline completed successfully.'