Skip to content

Commit

Permalink
Accommodate MacOS lack of timeout command
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst committed Feb 5, 2020
1 parent 5f06373 commit 5ac3a66
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion framework/test/test_bug_mining.sh
Expand Up @@ -40,6 +40,11 @@ _check_output() {
rm -f "$actual.sorted" "$expected.sorted"
}

# MacOS does not install the timeout command by default.
if [ "$(uname)" = "Darwin" ] ; then
function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
fi

# Download the remote resource to a local file of the same name, if the
# remote resource is newer. Works around connections that hang. Takes a
# single command-line argument, a URL.
Expand All @@ -48,7 +53,7 @@ download_url() {
if [ "$(uname)" = "Darwin" ] ; then
wget -nv -N "$@"
else
timeout 5m curl -s -S -R -L -O -z "$BASENAME" "$@" || (echo "retrying curl $@" && rm -f "$BASENAME" && curl -R -L -O -z "$BASENAME" "$@")
timeout 300 curl -s -S -R -L -O -z "$BASENAME" "$@" || (echo "retrying curl $@" && rm -f "$BASENAME" && curl -R -L -O -z "$BASENAME" "$@")
fi
}

Expand Down
7 changes: 6 additions & 1 deletion init.sh
Expand Up @@ -40,6 +40,11 @@ mkdir -p "$DIR_LIB_GEN" && mkdir -p "$DIR_LIB_RT" && mkdir -p "$DIR_LIB_GRADLE"
# Utility functions
#

# MacOS does not install the timeout command by default.
if [ "$(uname)" = "Darwin" ] ; then
function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
fi

# Download the remote resource to a local file of the same name, if the
# remote resource is newer. Works around connections that hang. Takes a
# single command-line argument, a URL.
Expand All @@ -48,7 +53,7 @@ download_url() {
if [ "$(uname)" = "Darwin" ] ; then
wget -nv -N "$@"
else
timeout 5m curl -s -S -R -L -O -z "$BASENAME" "$@" || (echo "retrying curl $@" && rm -f "$BASENAME" && curl -R -L -O -z "$BASENAME" "$@")
timeout 300 curl -s -S -R -L -O -z "$BASENAME" "$@" || (echo "retrying curl $@" && rm -f "$BASENAME" && curl -R -L -O -z "$BASENAME" "$@")
fi
}

Expand Down
7 changes: 6 additions & 1 deletion project_repos/get_repos.sh
Expand Up @@ -15,6 +15,11 @@ clean() {
README
}

# MacOS does not install the timeout command by default.
if [ "$(uname)" = "Darwin" ] ; then
function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
fi

# Download the remote resource to a local file of the same name, if the
# remote resource is newer. Works around connections that hang. Takes a
# single command-line argument, a URL.
Expand All @@ -23,7 +28,7 @@ download_url() {
if [ "$(uname)" = "Darwin" ] ; then
wget -nv -N "$@"
else
timeout 5m curl -s -S -R -L -O -z "$BASENAME" "$@" || (echo "retrying curl $@" && rm -f "$BASENAME" && curl -R -L -O -z "$BASENAME" "$@")
timeout 300 curl -s -S -R -L -O -z "$BASENAME" "$@" || (echo "retrying curl $@" && rm -f "$BASENAME" && curl -R -L -O -z "$BASENAME" "$@")
fi
}

Expand Down

0 comments on commit 5ac3a66

Please sign in to comment.