Skip to content

Commit

Permalink
Use exit 2 for script failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored Sep 2, 2024
1 parent bbd083b commit 2e0c9f4
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 39 deletions.
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,36 +68,36 @@ clean-everything: clean clean-cache clean-test-cache clean-stored-hashes

# Compresses the cache.
compress-cache:
if [ ! -d cache ]; then echo "cache does not exist"; exit 1; fi
if [ ! -d cache ]; then echo "cache does not exist"; exit 2; fi
if [ -f cache.tar.gz ]; then rm -f cache.tar.gz; fi
tar --exclude="lock" -czf cache.tar.gz cache

# Compresses the cache without logs.
compress-cache-without-logs:
if [ ! -d cache ]; then echo "cache does not exist"; exit 1; fi
if [ ! -d cache ]; then echo "cache does not exist"; exit 2; fi
if [ -f cache_without_logs.tar.gz ]; then rm -f cache_without_logs.tar.gz; fi
tar --exclude="lock" --exclude="logs" -czf cache_without_logs.tar.gz cache

compress-small-cache:
if [ ! -d cache-small ]; then echo "cache-small does not exist"; exit 1; fi
if [ ! -d cache-small ]; then echo "cache-small does not exist"; exit 2; fi
if [ -f cache-small.tar ]; then rm -f cache-small.tar; fi
tar --exclude="lock" -czf cache-small.tar cache-small

# Decompresses the cache.
decompress-cache:
if [ ! -f cache.tar.gz ]; then echo "cache.tar.gz does not exist"; exit 1; fi
if [ -d cache ]; then echo "cache already exists"; exit 1; fi
if [ ! -f cache.tar.gz ]; then echo "cache.tar.gz does not exist"; exit 2; fi
if [ -d cache ]; then echo "cache already exists"; exit 2; fi
tar -xzf cache.tar.gz

# Decompresses the cache without logs.
decompress-cache-without-logs:
if [ ! -f cache_without_logs.tar.gz ]; then echo "cache_without_logs.tar.gz does not exist"; exit 1; fi
if [ -d cache ]; then echo "cache already exists"; exit 1; fi
if [ ! -f cache_without_logs.tar.gz ]; then echo "cache_without_logs.tar.gz does not exist"; exit 2; fi
if [ -d cache ]; then echo "cache already exists"; exit 2; fi
tar -xzf cache_without_logs.tar.gz

decompress-small-cache:
if [ ! -f cache-small.tar ]; then echo "cache-small.tar does not exist"; exit 1; fi
if [ -d cache-small ]; then echo "cache-small already exists"; exit 1; fi
if [ ! -f cache-small.tar ]; then echo "cache-small.tar does not exist"; exit 2; fi
if [ -d cache-small ]; then echo "cache-small already exists"; exit 2; fi
tar -xzf cache-small.tar

# Copy tables and plots to the paper.
Expand Down
10 changes: 5 additions & 5 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CACHE_DIR="${4}"
# backend=$(uname -s)
# if [ "$backend" = "Darwin" ]; then
# echo "Error: MacOS is not supported. Please run the script on a Linux machine. This is due to the use of readarray in certain merge tools."
# exit 1
# exit 2
# fi

comparator_flags=""
Expand Down Expand Up @@ -120,10 +120,10 @@ if [ -f cache_without_logs.tar.gz ] && [ ! -d cache_without_logs ]; then
fi
fi

mvn -v | head -n 1 | cut -c 14-18 | grep -q 3.9. || { echo "Maven 3.9.* is required"; mvn -v; echo "PATH=$PATH"; exit 1; }
if [ -z "${JAVA8_HOME:+isset}" ] ; then echo "JAVA8_HOME is not set"; exit 1; fi
if [ -z "${JAVA11_HOME:+isset}" ] ; then echo "JAVA11_HOME is not set"; exit 1; fi
if [ -z "${JAVA17_HOME:+isset}" ] ; then echo "JAVA17_HOME is not set"; exit 1; fi
mvn -v | head -n 1 | cut -c 14-18 | grep -q 3.9. || { echo "Maven 3.9.* is required"; mvn -v; echo "PATH=$PATH"; exit 2; }
if [ -z "${JAVA8_HOME:+isset}" ] ; then echo "JAVA8_HOME is not set"; exit 2; fi
if [ -z "${JAVA11_HOME:+isset}" ] ; then echo "JAVA11_HOME is not set"; exit 2; fi
if [ -z "${JAVA17_HOME:+isset}" ] ; then echo "JAVA17_HOME is not set"; exit 2; fi

if [ -z "${machine_id:+isset}" ] ; then machine_id=0; fi
if [ -z "${num_machines:+isset}" ] ; then num_machines=1; fi
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/git_hires_merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ branch2=$3
# Print the current PATH
echo "PATH: $PATH"

cd "$clone_dir" || (echo "$0: cannot cd to $clone_dir" ; exit 1)
cd "$clone_dir" || (echo "$0: cannot cd to $clone_dir" ; exit 2)

git checkout "$branch1" --force

Expand Down
6 changes: 3 additions & 3 deletions src/scripts/merge_tools/gitmerge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# <clone_dir> must contain a clone of a repository.
# <git_strategy> is arguments to `git merge`, including -s and possibly -X.
# Merges branch2 into branch1, in <clone_dir>, using merge strategy <git_strategy>.
# Return code is 0 for merge success, 1 for merge failure.
# Return code is 0 for merge success, 1 for merge failure, 2 for script failure.
# For merge failure, also outputs "Conflict" and aborts the merge.

set -o nounset

if [ "$#" -ne 4 ]; then
echo "Usage: $0 CLONE_DIR BRANCH1 BRANCH2 GIT_STRATEGY" >&2
exit 1
exit 2
fi

clone_dir=$1
Expand All @@ -21,7 +21,7 @@ git_strategy=$4

## Perform merge

cd "$clone_dir" || (echo "$0: cannot cd to $clone_dir" ; exit 1)
cd "$clone_dir" || (echo "$0: cannot cd to $clone_dir" ; exit 2)

git checkout "$branch1" --force
git config --local merge.conflictstyle zdiff3
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/gitmerge_resolve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ status=$?

if [ "$status" -ne 0 ]; then
echo "Removing filenames from conflict markers."
cd "$clone_dir" || (echo "$0: cannot cd to $clone_dir" ; exit 1)
cd "$clone_dir" || (echo "$0: cannot cd to $clone_dir" ; exit 2)
readarray -t files < <(grep -l -r '^\(<<<<<<<\||||||||\|>>>>>>>\) .merge_file_')
for file in "${files[@]}" ; do
echo "Removing filenames from conflict markers in $file"
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/merge_tools/intellimerge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# usage: ./intellimerge.sh <clone_dir> <branch-1> <branch-2>
# <clone_dir> must contain a clone of a repository.
# Merges branch2 into branch1, in <clone_dir>.
# Return code is 0 for merge success, 1 for merge failure.
# Return code is 0 for merge success, 1 for merge failure, 2 for script failure.
# For merge failure, also outputs "Conflict" and aborts the merge.

set -o nounset

if [ "$#" -ne 3 ]; then
echo "Usage: $0 CLONE_DIR BRANCH1 BRANCH2" >&2
exit 1
exit 2
fi

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
Expand All @@ -34,7 +34,7 @@ echo "Temp dir: $temp_out_dir"
clone_dir_absolutepath=$(realpath "$clone_dir")

# run intellimerge
cd "$clone_dir" || (echo "$0: cannot cd to $clone_dir" ; exit 1)
cd "$clone_dir" || (echo "$0: cannot cd to $clone_dir" ; exit 2)

java -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 -Djava.io.tmpdir="$temp_intellimerge_dir" -jar "$intellimerge_absolutepath" -r "$clone_dir_absolutepath" -b "$branch1" "$branch2" -o $temp_out_dir

Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/merge_git_then_plumelib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plumelib_strategy=$5 #"--only-adjacent"

echo "$0: Merging $branch1 and $branch2 with git_strategy=$git_strategy and plumelib_strategy=$plumelib_strategy"

cd "$clone_dir" || (echo "$0: cannot cd to $clone_dir" ; exit 1)
cd "$clone_dir" || (echo "$0: cannot cd to $clone_dir" ; exit 2)

git checkout "$branch1" --force

Expand Down
6 changes: 3 additions & 3 deletions src/scripts/merge_tools/spork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# usage: ./spork.sh <clone_dir> <branch-1> <branch-2>
# <clone_dir> must contain a clone of a repository.
# Merges branch2 into branch1, in <clone_dir>.
# Return code is 0 for merge success, 1 for merge failure.
# Return code is 0 for merge success, 1 for merge failure, 2 for script failure.
# For merge failure, also outputs "Conflict" and aborts the merge.

set -o nounset

if [ "$#" -ne 3 ]; then
echo "Usage: $0 CLONE_DIR BRANCH1 BRANCH2" >&2
exit 1
exit 2
fi

# Kill all Java processes that are running for over an hour (to avoid memory leaks).
Expand All @@ -26,7 +26,7 @@ clone_dir=$1
branch1=$2
branch2=$3

cd "$clone_dir" || (echo "$0: cannot cd to $clone_dir" ; exit 1)
cd "$clone_dir" || (echo "$0: cannot cd to $clone_dir" ; exit 2)

# set up spork driver
git config --local merge.spork.name "spork"
Expand Down
16 changes: 8 additions & 8 deletions src/scripts/run_repo_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ find /tmp -maxdepth 1 -user "$(whoami)" -mmin +120 -exec rm -rf {} \;

if [ "$#" -ne 1 ]; then
echo "Usage: $0 REPO_DIR" >&2
exit 1
exit 2
fi
REPO_DIR=$1
CURR_PATH=$(pwd)
cd "$REPO_DIR" || exit 1
cd "$REPO_DIR" || exit 2

if [ -f "gradlew" ] ; then
# Append JaCoCo plugin and task to build.gradle
Expand All @@ -40,12 +40,12 @@ else
exit 1
fi

if [ -z "${JAVA8_HOME:+isset}" ] ; then echo "JAVA8_HOME is not set"; exit 1; fi
if [ ! -d "${JAVA8_HOME}" ] ; then echo "JAVA8_HOME is set to a nonexistent directory: ${JAVA8_HOME}"; exit 1; fi
if [ -z "${JAVA11_HOME:+isset}" ] ; then echo "JAVA11_HOME is not set"; exit 1; fi
if [ ! -d "${JAVA11_HOME}" ] ; then echo "JAVA11_HOME is set to a nonexistent directory: ${JAVA11_HOME}"; exit 1; fi
if [ -z "${JAVA17_HOME:+isset}" ] ; then echo "JAVA17_HOME is not set"; exit 1; fi
if [ ! -d "${JAVA17_HOME}" ] ; then echo "JAVA17_HOME is set to a nonexistent directory: ${JAVA17_HOME}"; exit 1; fi
if [ -z "${JAVA8_HOME:+isset}" ] ; then echo "JAVA8_HOME is not set"; exit 2; fi
if [ ! -d "${JAVA8_HOME}" ] ; then echo "JAVA8_HOME is set to a nonexistent directory: ${JAVA8_HOME}"; exit 2; fi
if [ -z "${JAVA11_HOME:+isset}" ] ; then echo "JAVA11_HOME is not set"; exit 2; fi
if [ ! -d "${JAVA11_HOME}" ] ; then echo "JAVA11_HOME is set to a nonexistent directory: ${JAVA11_HOME}"; exit 2; fi
if [ -z "${JAVA17_HOME:+isset}" ] ; then echo "JAVA17_HOME is not set"; exit 2; fi
if [ ! -d "${JAVA17_HOME}" ] ; then echo "JAVA17_HOME is set to a nonexistent directory: ${JAVA17_HOME}"; exit 2; fi

ORIG_PATH="${PATH}"

Expand Down
2 changes: 1 addition & 1 deletion src/scripts/run_with_timeout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Check if the correct number of arguments was provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <timeout_in_seconds> <command>"
exit 1
exit 2
fi

# Read the timeout and command from arguments
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/utils/run_multiple_machines.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Check arguments
if [ "$#" -ne 3 ]; then
echo "Usage: ./run_multiple_machines.sh <branch> <machine_address_path> <root_path_on_machine>"
exit 1
exit 2
fi

BRANCH="$1"
Expand All @@ -26,7 +26,7 @@ NUM_MACHINES=${#MACHINE_ADDRESSES[@]}
# Check that the number of machines is at least 1
if [ "$NUM_MACHINES" -lt 1 ]; then
echo "Error: number of machines is less than 1"
exit 1
exit 2
fi

# Check that machines are reachable
Expand All @@ -35,7 +35,7 @@ for i in "${!MACHINE_ADDRESSES[@]}"; do
echo "Checking if machine $i with address $MACHINE_ADDRESS is reachable"
if ! ssh -o ConnectTimeout=1 "$MACHINE_ADDRESS" exit >/dev/null 2>&1; then
echo "Error: machine $i with address $MACHINE_ADDRESS is not reachable"
exit 1
exit 2
fi
done
echo "Success: all machines are reachable"
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/utils/run_remotely.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Check arguments
if [ "$#" -ne 5 ]; then
echo "Usage: ./run_remotely.sh <branch> <machine_ssh> <machine_id> <num_machines> <root_path_on_machine>"
exit 1
exit 2
fi

BRANCH=$1
Expand Down

0 comments on commit 2e0c9f4

Please sign in to comment.