Skip to content

Commit

Permalink
Use grouping, not subshell
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst committed Sep 15, 2024
1 parent ccaa7a2 commit 7e46c73
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion framework/projects/Mockito/chooseDepedencyVersion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# $1 = workDir
# $2 = D4J_HOME

cd "$1" || (echo "cannot cd to workdir $1" && exit 1)
cd "$1" || { echo "cannot cd to workdir $1" && exit 2; }
./gradlew dependencies >> tmpDepend.txt
if grep -q buddy tmpDepend.txt; then
version=$(grep buddy tmpDepend.txt | head -1 | cut -d: -f 3)
Expand Down
4 changes: 2 additions & 2 deletions framework/test/test_bug_mining.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

set -e

HERE="$(cd "$(dirname "$0")" && pwd)" || (echo "cannot cd to $(dirname "$0")" && exit 1)
HERE="$(cd "$(dirname "$0")" && pwd)" || { echo "cannot cd to $(dirname "$0")" && exit 2; }

# Import helper subroutines and variables, and init Defects4J
source "$HERE/test.include" || exit 1
Expand Down Expand Up @@ -282,7 +282,7 @@ test_analyze_project() {
local commit_db_file="$work_dir/framework/projects/$project_id/$BUGS_CSV_ACTIVE"
local rev_v2; rev_v2=$(grep "^$bug_id," "$commit_db_file" | cut -f3 -d',')
local failing_tests="framework/projects/$project_id/failing_tests/$rev_v2"
if [ -e $RESOURCES_OUTPUT_DIR/$failing_tests ]; then
if [ -e "$RESOURCES_OUTPUT_DIR/$failing_tests" ]; then
[ -s "$work_dir/$failing_tests" ] || die "No failing test cases has been reported"

# Same number of failing tests
Expand Down
2 changes: 1 addition & 1 deletion framework/test/test_cp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
################################################################################

HERE="$(cd "$(dirname "$0")" && pwd)" || (echo "cannot cd to $(dirname "$0")" && exit 1)
HERE="$(cd "$(dirname "$0")" && pwd)" || { echo "cannot cd to $(dirname "$0")" && exit 2; }

# Import helper subroutines and variables, and init Defects4J
source "$HERE/test.include" || exit 1
Expand Down
2 changes: 1 addition & 1 deletion framework/test/test_d4j_query.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
################################################################################

HERE="$(cd "$(dirname "$0")" && pwd)" || (echo "cannot cd to $(dirname "$0")" && exit 1)
HERE="$(cd "$(dirname "$0")" && pwd)" || { echo "cannot cd to $(dirname "$0")" && exit 2; }

# Import helper subroutines and variables, and init Defects4J
source "$HERE/test.include" || exit 1
Expand Down
8 changes: 4 additions & 4 deletions framework/test/test_export_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
################################################################################

HERE="$(cd "$(dirname "$0")" && pwd)" || (echo "cannot cd to $(dirname "$0")" && exit 1)
HERE="$(cd "$(dirname "$0")" && pwd)" || { echo "cannot cd to $(dirname "$0")" && exit 2; }

# Import helper subroutines and variables, and init Defects4J
source "$HERE/test.include" || exit 1
Expand All @@ -25,12 +25,12 @@ _run_export_command() {
local exp_cmp="$2"
local exp_out=""

pushd "$work_dir" > /dev/null 2>&1 || (echo "Cannot pushd to $work_dir" && exit 1)
pushd "$work_dir" > /dev/null 2>&1 || { echo "Cannot pushd to $work_dir" && exit 2; }
if ! defects4j export -p "$exp_cmp" ; then
popd > /dev/null 2>&1 || (echo "Cannot popd" && exit 1)
popd > /dev/null 2>&1 || { echo "Cannot popd" && exit 2; }
return 1
fi
popd > /dev/null 2>&1 || (echo "Cannot popd" && exit 1)
popd > /dev/null 2>&1 || { echo "Cannot popd" && exit 2; }

echo "$exp_out"
return 0
Expand Down
8 changes: 4 additions & 4 deletions framework/test/test_fix_test_suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
################################################################################

HERE="$(cd "$(dirname "$0")" && pwd)" || (echo "cannot cd to $(dirname "$0")" && exit 1)
HERE="$(cd "$(dirname "$0")" && pwd)" || { echo "cannot cd to $(dirname "$0")" && exit 2; }

# Import helper subroutines and variables, and init Defects4J
source "$HERE/test.include" || exit 1
Expand Down Expand Up @@ -62,12 +62,12 @@ _create_tar_bz2_file() {
local suites_dir="$4"

# Create a .tar.bz2 file with all test suites
pushd . > /dev/null 2>&1 || (echo "cannot pushd ." && exit 1)
cd "$HERE/resources/input" || (echo "cannot cd to $HERE/resources/input" && exit 1)
pushd . > /dev/null 2>&1 || { echo "cannot pushd ." && exit 2; }
cd "$HERE/resources/input" || { echo "cannot cd to $HERE/resources/input" && exit 2; }
tar_bz2_file="$suites_dir/$pid-$bid-test.0.tar.bz2"
# shellcheck disable=SC2086 # $input_files contains multiple files
tar -jcvf "$tar_bz2_file" $input_files || return 1
popd > /dev/null 2>&1 || (echo "cannot popd" && exit 1)
popd > /dev/null 2>&1 || { echo "cannot popd" && exit 2; }

return 0
}
Expand Down
2 changes: 1 addition & 1 deletion framework/test/test_gen_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
################################################################################

HERE="$(cd "$(dirname "$0")" && pwd)" || (echo "cannot cd to $(dirname "$0")" && exit 1)
HERE="$(cd "$(dirname "$0")" && pwd)" || { echo "cannot cd to $(dirname "$0")" && exit 2; }

# Import helper subroutines and variables, and init Defects4J
source "$HERE/test.include" || exit 1
Expand Down
2 changes: 1 addition & 1 deletion framework/test/test_monitor_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
################################################################################

HERE="$(cd "$(dirname "$0")" && pwd)" || (echo "cannot cd to $(dirname "$0")" && exit 1)
HERE="$(cd "$(dirname "$0")" && pwd)" || { echo "cannot cd to $(dirname "$0")" && exit 2; }

# Import helper subroutines and variables, and init Defects4J
source "$HERE/test.include" || exit 1
Expand Down
2 changes: 1 addition & 1 deletion framework/test/test_mutation_analysis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# TODO: There is some code duplication in this test script, which we can avoid
# by extracting the mutation analysis workflow into a parameterized function.

HERE="$(cd "$(dirname "$0")" && pwd)" || (echo "cannot cd to $(dirname "$0")" && exit 1)
HERE="$(cd "$(dirname "$0")" && pwd)" || { echo "cannot cd to $(dirname "$0")" && exit 2; }

# Import helper subroutines and variables, and init Defects4J
source "$HERE/test.include" || exit 1
Expand Down
2 changes: 1 addition & 1 deletion framework/test/test_sanity_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
################################################################################

HERE="$(cd "$(dirname "$0")" && pwd)" || (echo "cannot cd to $(dirname "$0")" && exit 1)
HERE="$(cd "$(dirname "$0")" && pwd)" || { echo "cannot cd to $(dirname "$0")" && exit 2; }

# Import helper subroutines and variables, and init Defects4J
source "$HERE/test.include" || exit 1
Expand Down
4 changes: 2 additions & 2 deletions framework/test/test_style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

TOPLEVEL="$(git rev-parse --show-toplevel)"

cd "$TOPLEVEL" || (echo "Cannot cd to $TOPLEVEL" && exit 1)
cd "$TOPLEVEL" || { echo "Cannot cd to $TOPLEVEL" && exit 2; }

# Check style of Perl scripts
find . \( -name '*.pm' -o -name '*.pl' \) -print0 | xargs -0 -n1 perl -Mstrict -Mdiagnostics -cw
grep -l --exclude-dir=project_repos --exclude=\*.pm --exclude=\*.pl --exclude=\*.sh --exclude=template -r "=pod" . | while IFS= read -r file ; do
grep -l --exclude-dir=project_repos --exclude=\*.pm --exclude=\*.pl --exclude=\*.sh --exclude=\*~ --exclude=template -r "=pod" . | while IFS= read -r file ; do
perl -Mstrict -Mdiagnostics -cw "$file"
done
# Don't run perlcritic yet.
Expand Down
4 changes: 2 additions & 2 deletions framework/test/test_tutorial.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
################################################################################

HERE="$(cd "$(dirname "$0")" && pwd)" || (echo "cannot cd to $(dirname "$0")" && exit 1)
HERE="$(cd "$(dirname "$0")" && pwd)" || { echo "cannot cd to $(dirname "$0")" && exit 2; }

# Import helper subroutines and variables, and init Defects4J
source "$HERE/test.include" || exit 1
Expand All @@ -31,7 +31,7 @@ defects4j checkout -p $pid -v $vid -w "$work_dir" || die "checkout program versi
grep -q "pid=$pid" "$work_dir"/.defects4j.config || die "verify pid in config file"
grep -q "vid=$vid" "$work_dir"/.defects4j.config || die "verify vid in config file"

cd "$work_dir" || (echo "cannot cd to $work_dir" && exit 1)
cd "$work_dir" || { echo "cannot cd to $work_dir" && exit 2; }

# Compile buggy version
defects4j compile || die "compile program version $pid-$vid"
Expand Down
2 changes: 1 addition & 1 deletion framework/test/test_verify_bugs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
################################################################################

HERE="$(cd "$(dirname "$0")" && pwd)" || (echo "cannot cd to $(dirname "$0")" && exit 1)
HERE="$(cd "$(dirname "$0")" && pwd)" || { echo "cannot cd to $(dirname "$0")" && exit 2; }

# Import helper subroutines and variables, and init Defects4J
source "$HERE/test.include" || exit 1
Expand Down

0 comments on commit 7e46c73

Please sign in to comment.