Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
update Travis to build on Trusty for code layout (#10048)
* update Travis to build on Trusty for code layout

* fix shellcheck replace ! -z by -n

* shellcheck: fix  -n doesn't work with unquoted arguments

* more shellcheck fixes

* use bash instead of posix
  • Loading branch information
3nids committed May 21, 2019
1 parent 1f0fbd1 commit 8b7489e
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .docker/qgis_resources/test_runner/qgis_setup.sh
Expand Up @@ -38,7 +38,7 @@ printf "[qgis]\n" >> $CONF_MASTER_FILE
SHOW_TIPS=$(qgis --help 2>&1 | head -2 | grep 'QGIS - ' | perl -npe 'chomp; s/QGIS - (\d+)\.(\d+).*/showTips\1\2=false/')
printf "%s\n\n" "$SHOW_TIPS" >> $CONF_MASTER_FILE

if [ -n "$PLUGIN_NAME" ]; then
if [[ -n "$PLUGIN_NAME" ]]; then
# Enable plugin
printf '[PythonPlugins]\n' >> $CONF_MASTER_FILE
printf "%s=true\n\n" "$PLUGIN_NAME" >> $CONF_MASTER_FILE
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -48,14 +48,15 @@ matrix:
# CODE LAYOUT
##########################################################
- os: linux
dist: xenial
name: code layout 👗
if: type != cron
env:
- TRAVIS_CONFIG=code_layout
addons:
apt:
sources:
- sourceline: 'ppa:jonathonf/backports' # silversearcher-ag backport
- sourceline: 'ppa:sergey-dryabzhinsky/packages' # doxygen
packages:
- doxygen
- graphviz
Expand Down
6 changes: 3 additions & 3 deletions scripts/qgis_srs.sh
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
###########################################################################
# qgis_srs.sh
# ---------------------
Expand Down Expand Up @@ -199,7 +199,7 @@ for i in $(awk 'NR>1' ${gdal_share}/pcs.csv | cut -d, -f1); do

raw=$(epsg_tr.py -proj4 $i 2>&1 | tr "\n" " " | sed 's/ <> $//' | grep -v "^ERROR 6: ")

if [ -n "$raw" ]; then
if [[ -n "$raw" ]]; then

no=$((no + 1))
name=$(echo $raw | sed 's/^# //' | grep -o "^.\{1,\} <[[:digit:]]\{1,\}>" | sed 's/ <[[:digit:]]\{1,\}>//' | sed "s/'/''/g")
Expand All @@ -222,7 +222,7 @@ for i in $(awk 'NR>1' ${gdal_share}/gcs.csv | cut -d, -f1); do

raw=$(epsg_tr.py -proj4 $i 2>&1 | tr "\n" " " | sed 's/ <> $//' | grep -v "^ERROR 6: ")

if [ -n "$raw" ]; then
if [[ -n "$raw" ]]; then

no=$((no + 1))
name=$(echo $raw | sed 's/^# //' | grep -o "^.\{1,\} <[[:digit:]]\{1,\}>" | sed 's/ <[[:digit:]]\{1,\}>//' | sed "s/'/''/g")
Expand Down
10 changes: 7 additions & 3 deletions scripts/sip_include.sh
Expand Up @@ -31,7 +31,11 @@ if [[ "$OSTYPE" =~ darwin* ]]; then
GP=g
fi

modules=(core gui analysis server)
if [[ -n $1 ]]; then
modules=("$1")
else
modules=(core gui analysis server)
fi
sources=(HDRS MOC_HDRS SRCS)

for module in "${modules[@]}"; do
Expand Down Expand Up @@ -62,7 +66,7 @@ for module in "${modules[@]}"; do
sip=$(${GP}sed -r 's/(.*)\.h$/\1.sip/' <<< ${header})
if_cond=$(grep -x -E '^(#define +)?SIP_IF_MODULE\((.*)\)$' src/${module}/${header} | \
${GP}sed -r -e 's/(#define +)?SIP_IF_MODULE\((.*)\)/%If (\2)/')
if [[ ! -z $if_cond ]]; then
if [[ -n $if_cond ]]; then
echo "$if_cond" >> $file
fi
if [[ "$sip" == [0-9]* ]]; then
Expand All @@ -71,7 +75,7 @@ for module in "${modules[@]}"; do
sip="./$sip"
fi
echo "%Include auto_generated/$sip" >> $file
if [[ ! -z $if_cond ]]; then
if [[ -n $if_cond ]]; then
echo "%End" >> $file
fi
fi
Expand Down
8 changes: 4 additions & 4 deletions scripts/spell_check/check_spelling.sh
Expand Up @@ -85,7 +85,7 @@ declare -A GLOBREP_IGNORE=()
ERRORFOUND=NO

for I in $(seq -f '%02g' 0 $((SPLIT-1)) ) ; do
( [[ "$INTERACTIVE" =~ YES ]] || [[ "$TRAVIS" =~ true ]] ) && printf "Progress: %d/%d\r" $(( I + 1 )) $SPLIT
{ [[ "$INTERACTIVE" =~ YES ]] || [[ "$TRAVIS" =~ true ]]; } && printf "Progress: %d/%d\r" $(( I + 1 )) $SPLIT
SPELLFILE=spelling$I~
${GP}sed -i '/^#/d' $SPELLFILE

Expand Down Expand Up @@ -136,10 +136,10 @@ for I in $(seq -f '%02g' 0 $((SPLIT-1)) ) ; do
RUN_IGNORECASE=OFF
RUN_CASEMATCH=OFF

if [[ ! -z "${IGNORECASE}" ]]; then
if [[ -n "${IGNORECASE}" ]]; then
RUN_IGNORECASE=ON
fi
if [[ ! -z "${CASEMATCH}" ]]; then
if [[ -n "${CASEMATCH}" ]]; then
RUN_CASEMATCH=ON
fi

Expand Down Expand Up @@ -336,7 +336,7 @@ for I in $(seq -f '%02g' 0 $((SPLIT-1)) ) ; do

done

( [[ "$INTERACTIVE" =~ YES ]] || [[ "$TRAVIS" =~ true ]] ) && echo
{ [[ "$INTERACTIVE" =~ YES ]] || [[ "$TRAVIS" =~ true ]]; } && echo

if [[ "$ERRORFOUND" =~ YES ]]; then
echo -e "\x1B[1msome errors have been found.\x1B[0m" >&2
Expand Down
6 changes: 3 additions & 3 deletions scripts/spell_check/spell_test.sh
Expand Up @@ -5,12 +5,12 @@ set -e
echo "Spell check"
cd $(git rev-parse --show-toplevel)

if [[ ! -z $TRAVIS_PULL_REQUEST_BRANCH ]]; then
if [[ -n $TRAVIS_PULL_REQUEST_BRANCH ]]; then
# if on a PR, just analyze the changed files
echo "TRAVIS PR BRANCH: $TRAVIS_PULL_REQUEST_BRANCH"
FILES=$(git diff --diff-filter=AM --name-only $(git merge-base HEAD ${TRAVIS_BRANCH}) | tr '\n' ' ' )
export PATH=${HOME}/osgeo4travis/bin:${PATH}
elif [[ ! -z $TRAVIS_COMMIT_RANGE ]]; then
elif [[ -n $TRAVIS_COMMIT_RANGE ]]; then
echo "TRAVIS COMMIT RANGE: $TRAVIS_COMMIT_RANGE"
FILES=$(git diff --diff-filter=AM --name-only ${TRAVIS_COMMIT_RANGE/.../..} | tr '\n' ' ' )
export PATH=${HOME}/osgeo4travis/bin:${PATH}
Expand All @@ -19,7 +19,7 @@ else
FILES=""
fi

if [[ ! -z $FILES ]]; then
if [[ -n $FILES ]]; then
DIR=$(git rev-parse --show-toplevel)/scripts/spell_check
${DIR}/check_spelling.sh -r $FILES
fi
2 changes: 1 addition & 1 deletion scripts/spell_check/test.sh
Expand Up @@ -85,7 +85,7 @@ ${DIR}/check_spelling.sh -r -l spelling_error.log~ spelling_error.dat~
${GP}sort -u -o spelling_error.log~ spelling_error.log~
DIFF=$(diff spelling_error.log~ spelling_error.expected~)

if [[ ! -z $DIFF ]]; then
if [[ -n $DIFF ]]; then
echo "SPELLING TEST FAILED" >&2
else
echo "TEST OK"
Expand Down
4 changes: 2 additions & 2 deletions scripts/verify-indentation.sh
Expand Up @@ -19,11 +19,11 @@ ASTYLEDIFF=/tmp/astyle.diff
true > $ASTYLEDIFF


if [[ ! -z $TRAVIS_PULL_REQUEST_BRANCH ]]; then
if [[ -n $TRAVIS_PULL_REQUEST_BRANCH ]]; then
# if on a PR, just analyze the changed files
echo "TRAVIS PR BRANCH: $TRAVIS_PULL_REQUEST_BRANCH"
FILES=$(git diff --diff-filter=AM --name-only $(git merge-base HEAD ${TRAVIS_BRANCH}) | tr '\n' ' ' )
elif [[ ! -z $TRAVIS_COMMIT_RANGE ]]; then
elif [[ -n $TRAVIS_COMMIT_RANGE ]]; then
echo "TRAVIS COMMIT RANGE: $TRAVIS_COMMIT_RANGE"
FILES=$(git diff --diff-filter=AM --name-only ${TRAVIS_COMMIT_RANGE/.../..} | tr '\n' ' ' )
fi
Expand Down
6 changes: 3 additions & 3 deletions tests/code_layout/test_doxygen_layout.sh
Expand Up @@ -3,14 +3,14 @@

# check that returns are placed before note and since
output=$(unbuffer ag --noaffinity --file-search-regex '\.h$' --multiline '\\(note|since)[^\n]+(\n\s*\* [^\n]+)*\n\s*\* \\return' ${TRAVIS_BUILD_DIR} | tee /dev/stderr)
if [[ ! -z $output ]]; then
if [[ -n $output ]]; then
echo -e "\n\x1B[31m*** Docstring computation: \\\return(s) should be placed before \\\note and \\since\x1B[0m"
exit 1
fi

# check that \since and \deprecated are placed at the end of the command block
output=$(unbuffer ag --noaffinity --file-search-regex '\.h$' --multiline '(\\(deprecated|since)[^\n]+\n)+\s*\*[^\/](?!\s*\\(deprecated|since))' ${TRAVIS_BUILD_DIR} | tee /dev/stderr)
if [[ ! -z $output ]]; then
if [[ -n $output ]]; then
echo -e "\n\x1B[31m*** Docstring computation: \\\deprecated and \\\since should be placed at the end of command blocks\x1B[0m"
echo -e "To fix it, you may want to run (multiple times) at the top level directory:"
echo 'sed -i -r '"'"'$!N;s/^(\s*\*\s+\\(deprecated|since)[^\n]+)\n(\s*\*([^\/].*|$))/\3\n\1/;P;D'"'"' $(ag -c --noaffinity --file-search-regex '"'"'\.h$'"'"' --multiline '"'"'(\\(deprecated|since)[^\n]+\n)+\s*\*[^\/]'"'"' . | cut -d: -f1)'
Expand All @@ -21,7 +21,7 @@ fi

# code snippets command
output=$(unbuffer ag --noaffinity --file-search-regex '\.h$' --multiline '~~~\{\.\w+\}' ${TRAVIS_BUILD_DIR} | tee /dev/stderr)
if [[ ! -z $output ]]; then
if [[ -n $output ]]; then
echo -e "\n\x1B[31m*** Docstring computation: code snippets should use \\\code{.xx} rather than ~~~{.xx} \x1B[0m"
exit 1
fi
Expand Up @@ -19,15 +19,15 @@ PROCESS="mapserv"
LABEL="org.qgis.test-${PROCESS}"
USAGE="${0} {stop|status} or {start|restart spawn_bin fcgi_socket fcgi_bin qgis_server_temp_dir}"

if [ ! -z $2 ]; then
if [[ -n $2 ]]; then
SPAWN_BIN=$2
if [ ! -z $3 ]; then
if [[ -n $3 ]]; then
FCGI_SOCKET=$3
fi
if [ ! -z $4 ]; then
if [[ -n $4 ]]; then
FCGI_BIN=$4
fi
if [ ! -z $5 ]; then
if [[ -n $5 ]]; then
QGIS_SERVER_TEMP_DIR=$5
fi
fi
Expand Down
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
###########################################################################
# lighttpd_debian.sh
# ---------------------
Expand Down Expand Up @@ -26,7 +26,7 @@ SCRIPTNAME=$NAME

export QGIS_SERVER_TEMP_DIR=$3

if [ ! -z $4 ]; then
if [[ -n $4 ]]; then
DAEMON_OPTS="-f ${4}"
fi

Expand Down
Expand Up @@ -19,12 +19,12 @@ PROCESS="lighttpd"
LABEL="org.qgis.test-${PROCESS}"
USAGE="${0} {stop|status} or {start|restart lighttpd-path lighttpd_conf qgis_server_temp_dir}"

if [ ! -z $2 ]; then
if [[ -n $2 ]]; then
LIGHTTPD_BIN=$2
if [ ! -z $3 ]; then
if [[ -n $3 ]]; then
LIGHTTPD_CONF_PATH=$3
fi
if [ ! -z $4 ]; then
if [[ -n $4 ]]; then
QGIS_SERVER_TEMP_DIR=$4
fi
fi
Expand Down

0 comments on commit 8b7489e

Please sign in to comment.