Skip to content

Commit

Permalink
quote underquoted variable expansions
Browse files Browse the repository at this point in the history
This protects against word splitting if the variable contains IFS
characters, and it ensures that an empty variable doesn't become an
elided argument.
  • Loading branch information
rhansen committed Jan 31, 2016
1 parent c100a04 commit 09ef253
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions tools/build_test_env.sh
Expand Up @@ -55,7 +55,7 @@ cleanup() {
docker kill gitlab-test >/dev/null 2>&1
docker rm gitlab-test >/dev/null 2>&1
command -v deactivate >/dev/null 2>&1 && deactivate || true
rm -rf $VENV
rm -rf "$VENV"
}
[ -z "${BUILD_TEST_ENV_AUTO_CLEANUP+set}" ] || {
trap cleanup EXIT
Expand All @@ -68,10 +68,10 @@ docker run --name gitlab-test --detach --publish 8080:80 \
LOGIN='root'
PASSWORD='5iveL!fe'
CONFIG=/tmp/python-gitlab.cfg
GITLAB() { gitlab --config-file $CONFIG "$@"; }
GITLAB() { gitlab --config-file "$CONFIG" "$@"; }
GREEN='\033[0;32m'
NC='\033[0m'
OK() { echo -e ${GREEN}OK${NC}; }
OK() { echo -e "${GREEN}OK${NC}"; }

log "Waiting for gitlab to come online... "
I=0
Expand All @@ -82,7 +82,7 @@ while :; do
curl -s http://localhost:8080/users/sign_in 2>/dev/null \
| grep -q "GitLab Community Edition" && break
let I=I+5
[ $I -eq 120 ] && exit 1
[ "$I" -eq 120 ] && exit 1
done
sleep 5

Expand All @@ -106,8 +106,8 @@ EOF
log "Config file content ($CONFIG):"
log <$CONFIG

$VENV_CMD $VENV
. $VENV/bin/activate
"$VENV_CMD" "$VENV"
. "$VENV"/bin/activate
pip install -rrequirements.txt
pip install -e .

Expand Down
24 changes: 12 additions & 12 deletions tools/functional_tests.sh
Expand Up @@ -14,9 +14,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

setenv_script=$(dirname $0)/build_test_env.sh
setenv_script=$(dirname "$0")/build_test_env.sh
BUILD_TEST_ENV_AUTO_CLEANUP=true
. $setenv_script "$@"
. "$setenv_script" "$@"

set -e

Expand All @@ -27,7 +27,7 @@ GITLAB project list | grep -q test-project1
OK

echo -n "Testing project update... "
GITLAB project update --id $PROJECT_ID --description "My New Description"
GITLAB project update --id "$PROJECT_ID" --description "My New Description"
OK

echo -n "Testing user creation... "
Expand All @@ -44,37 +44,37 @@ GITLAB -v user list | grep -qv config-file
OK

echo -n "Testing adding member to a project... "
GITLAB project-member create --project-id $PROJECT_ID \
--user-id $USER_ID --access-level 40 >/dev/null 2>&1
GITLAB project-member create --project-id "$PROJECT_ID" \
--user-id "$USER_ID" --access-level 40 >/dev/null 2>&1
OK

echo -n "Testing file creation... "
GITLAB project-file create --project-id $PROJECT_ID \
GITLAB project-file create --project-id "$PROJECT_ID" \
--file-path README --branch-name master --content "CONTENT" \
--commit-message "Initial commit" >/dev/null 2>&1
OK

echo -n "Testing issue creation... "
ISSUE_ID=$(GITLAB project-issue create --project-id $PROJECT_ID \
ISSUE_ID=$(GITLAB project-issue create --project-id "$PROJECT_ID" \
--title "my issue" --description "my issue description" \
| grep ^id: | cut -d' ' -f2)
OK

echo -n "Testing note creation... "
GITLAB project-issue-note create --project-id $PROJECT_ID \
--issue-id $ISSUE_ID --body "the body" >/dev/null 2>&1
GITLAB project-issue-note create --project-id "$PROJECT_ID" \
--issue-id "$ISSUE_ID" --body "the body" >/dev/null 2>&1
OK

echo -n "Testing branch creation... "
GITLAB project-branch create --project-id $PROJECT_ID \
GITLAB project-branch create --project-id "$PROJECT_ID" \
--branch-name branch1 --ref master >/dev/null 2>&1
OK

echo -n "Testing branch deletion... "
GITLAB project-branch delete --project-id $PROJECT_ID \
GITLAB project-branch delete --project-id "$PROJECT_ID" \
--name branch1 >/dev/null 2>&1
OK

echo -n "Testing project deletion... "
GITLAB project delete --id $PROJECT_ID
GITLAB project delete --id "$PROJECT_ID"
OK
6 changes: 3 additions & 3 deletions tools/py_functional_tests.sh
Expand Up @@ -14,8 +14,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

setenv_script=$(dirname $0)/build_test_env.sh
setenv_script=$(dirname "$0")/build_test_env.sh
BUILD_TEST_ENV_AUTO_CLEANUP=true
. $setenv_script "$@"
. "$setenv_script" "$@"

python $(dirname $0)/python_test.py
python "$(dirname "$0")"/python_test.py

0 comments on commit 09ef253

Please sign in to comment.