From fb587f11febc1951f42f5643b1532823675c2acf Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Wed, 13 Sep 2017 22:58:52 +0200 Subject: Switch to code-cov --- manage.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'manage.sh') diff --git a/manage.sh b/manage.sh index 319a14f2a..e3929c917 100755 --- a/manage.sh +++ b/manage.sh @@ -73,9 +73,9 @@ unit_tests() { py_test_coverage() { echo '[!] Running python test coverage' - PYTHONPATH=`pwd` python -m nose2 -C --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit" - coverage report - coverage html + PYTHONPATH=`pwd` python -m nose2 -C --log-capture --with-coverage --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit" \ + && coverage report \ + && coverage html } robot_tests() { -- cgit v1.2.3 From 2790402060c37aa5bb1e0f371e17225bd51bf5e1 Mon Sep 17 00:00:00 2001 From: Thirnearez Date: Fri, 6 Oct 2017 18:43:15 +0000 Subject: fix a shell typo that generated a bogus file --- manage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manage.sh') diff --git a/manage.sh b/manage.sh index e3929c917..e5e39f51a 100755 --- a/manage.sh +++ b/manage.sh @@ -22,7 +22,7 @@ install_geckodriver() { echo '[!] Checking geckodriver' # TODO : check the current geckodriver version set -e - geckodriver -V 2>1 > /dev/null || NOTFOUND=1 + geckodriver -V > /dev/null 2>&1 || NOTFOUND=1 set +e if [ -z $NOTFOUND ]; then return -- cgit v1.2.3 From 076cfe25d778201081972a6848f9173115b530f4 Mon Sep 17 00:00:00 2001 From: Thirnearez Date: Fri, 6 Oct 2017 18:24:21 +0000 Subject: handle input carefully in shell scripts - prevent whitespace-splitting of variable expansions - prevent interpretation of values as flags/options (mostly) --- manage.sh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'manage.sh') diff --git a/manage.sh b/manage.sh index e5e39f51a..3de273e84 100755 --- a/manage.sh +++ b/manage.sh @@ -1,11 +1,11 @@ #!/bin/sh -BASE_DIR=$(dirname "`readlink -f "$0"`") -PYTHONPATH=$BASE_DIR +BASE_DIR="$(dirname -- "`readlink -f -- "$0"`")" +PYTHONPATH="$BASE_DIR" SEARX_DIR="$BASE_DIR/searx" -ACTION=$1 +ACTION="$1" -cd "$BASE_DIR" +cd -- "$BASE_DIR" update_packages() { pip install --upgrade pip @@ -24,12 +24,12 @@ install_geckodriver() { set -e geckodriver -V > /dev/null 2>&1 || NOTFOUND=1 set +e - if [ -z $NOTFOUND ]; then + if [ -z "$NOTFOUND" ]; then return fi GECKODRIVER_VERSION="v0.18.0" - PLATFORM=`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"` - case $PLATFORM in + PLATFORM="`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`" + case "$PLATFORM" in "linux 32bit" | "linux2 32bit") ARCH="linux32";; "linux 64bit" | "linux2 64bit") ARCH="linux64";; "windows 32 bit") ARCH="win32";; @@ -47,15 +47,15 @@ install_geckodriver() { fi else GECKODRIVER_DIR="$1" - mkdir -p "$GECKODRIVER_DIR" + mkdir -p -- "$GECKODRIVER_DIR" fi echo "Installing $GECKODRIVER_DIR/geckodriver from\n $GECKODRIVER_URL" - FILE=`mktemp` - wget "$GECKODRIVER_URL" -qO $FILE && tar xz -C "$GECKODRIVER_DIR" -f $FILE geckodriver - rm $FILE - chmod 777 "$GECKODRIVER_DIR/geckodriver" + FILE="`mktemp`" + wget -qO "$FILE" -- "$GECKODRIVER_URL" && tar xz -C "$GECKODRIVER_DIR" -f "$FILE" geckodriver + rm -- "$FILE" + chmod 777 -- "$GECKODRIVER_DIR/geckodriver" } pep8_check() { @@ -73,14 +73,14 @@ unit_tests() { py_test_coverage() { echo '[!] Running python test coverage' - PYTHONPATH=`pwd` python -m nose2 -C --log-capture --with-coverage --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit" \ + PYTHONPATH="`pwd`" python -m nose2 -C --log-capture --with-coverage --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit" \ && coverage report \ && coverage html } robot_tests() { echo '[!] Running robot tests' - PYTHONPATH=`pwd` python "$SEARX_DIR/testing.py" robot + PYTHONPATH="`pwd`" python "$SEARX_DIR/testing.py" robot } tests() { @@ -113,11 +113,11 @@ styles() { npm_packages() { echo '[!] install NPM packages for oscar theme' - cd $BASE_DIR/searx/static/themes/oscar + cd -- "$BASE_DIR/searx/static/themes/oscar" npm install echo '[!] install NPM packages for simple theme' - cd $BASE_DIR/searx/static/themes/simple + cd -- "$BASE_DIR/searx/static/themes/simple" npm install } @@ -133,7 +133,7 @@ locales() { } help() { - [ -z "$1" ] || printf "Error: $1\n" + [ -z "$1" ] || printf 'Error: %s\n' "$1" echo "Searx manage.sh help Commands @@ -156,4 +156,4 @@ Commands [ "$(command -V "$ACTION" | grep ' function$')" = "" ] \ && help "action not found" \ - || $ACTION "$2" + || "$ACTION" "$2" -- cgit v1.2.3 From 9224b3c3f04d0757466a4ff6a6e1280ce630c9ff Mon Sep 17 00:00:00 2001 From: Thirnearez Date: Fri, 6 Oct 2017 18:31:19 +0000 Subject: adjust whitespace in shell scripts --- manage.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'manage.sh') diff --git a/manage.sh b/manage.sh index 3de273e84..d5b385195 100755 --- a/manage.sh +++ b/manage.sh @@ -25,33 +25,33 @@ install_geckodriver() { geckodriver -V > /dev/null 2>&1 || NOTFOUND=1 set +e if [ -z "$NOTFOUND" ]; then - return + return fi GECKODRIVER_VERSION="v0.18.0" PLATFORM="`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`" case "$PLATFORM" in - "linux 32bit" | "linux2 32bit") ARCH="linux32";; - "linux 64bit" | "linux2 64bit") ARCH="linux64";; - "windows 32 bit") ARCH="win32";; - "windows 64 bit") ARCH="win64";; - "mac 64bit") ARCH="macos";; + "linux 32bit" | "linux2 32bit") ARCH="linux32";; + "linux 64bit" | "linux2 64bit") ARCH="linux64";; + "windows 32 bit") ARCH="win32";; + "windows 64 bit") ARCH="win64";; + "mac 64bit") ARCH="macos";; esac GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-$ARCH.tar.gz"; if [ -z "$1" ]; then - if [ -z "$VIRTUAL_ENV" ]; then - echo "geckodriver can't be installed because VIRTUAL_ENV is not set, you should download it from\n $GECKODRIVER_URL" - exit - else - GECKODRIVER_DIR="$VIRTUAL_ENV/bin" - fi + if [ -z "$VIRTUAL_ENV" ]; then + echo "geckodriver can't be installed because VIRTUAL_ENV is not set, you should download it from\n $GECKODRIVER_URL" + exit + else + GECKODRIVER_DIR="$VIRTUAL_ENV/bin" + fi else - GECKODRIVER_DIR="$1" - mkdir -p -- "$GECKODRIVER_DIR" + GECKODRIVER_DIR="$1" + mkdir -p -- "$GECKODRIVER_DIR" fi echo "Installing $GECKODRIVER_DIR/geckodriver from\n $GECKODRIVER_URL" - + FILE="`mktemp`" wget -qO "$FILE" -- "$GECKODRIVER_URL" && tar xz -C "$GECKODRIVER_DIR" -f "$FILE" geckodriver rm -- "$FILE" @@ -116,7 +116,7 @@ npm_packages() { cd -- "$BASE_DIR/searx/static/themes/oscar" npm install - echo '[!] install NPM packages for simple theme' + echo '[!] install NPM packages for simple theme' cd -- "$BASE_DIR/searx/static/themes/simple" npm install } @@ -124,7 +124,7 @@ npm_packages() { grunt_build() { echo '[!] Grunt build : oscar theme' grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js" - echo '[!] Grunt build : simple theme' + echo '[!] Grunt build : simple theme' grunt --gruntfile "$SEARX_DIR/static/themes/simple/gruntfile.js" } -- cgit v1.2.3