Add a checkbashisms tox profile 30/95430/5
authorGuillaume Lambert <guillaume.lambert@orange.com>
Tue, 9 Mar 2021 14:23:20 +0000 (15:23 +0100)
committerGuillaume Lambert <guillaume.lambert@orange.com>
Wed, 10 Mar 2021 08:44:26 +0000 (08:44 +0000)
to identify potential bashisms in tests scripts
and ensure compatibility with dash, MAC OS X and BSD shells.

https://wiki.ubuntu.com/DashAsBinSh
https://mywiki.wooledge.org/Bashism

Signed-off-by: Guillaume Lambert <guillaume.lambert@orange.com>
Change-Id: I32acb2721f828bbfb283089aad5dbd446b662cd2

tox.ini

diff --git a/tox.ini b/tox.ini
index bcc41929d4e79ae82eb3b00925cac2aadcbcf243..8c52932a8c56da18106d6f68bc12354646ba8d9c 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -3,6 +3,7 @@ minversion = 1.6
 envlist = py3
     docs
     docs-linkcheck
+    checkbashisms
 skipsdist = true
 setupdir = tests/
 
@@ -18,7 +19,7 @@ whitelist_externals = sh
 changedir={toxinidir}/tests
 commands =
 #install maven and JDK11 on the Gate since they are not there by default
-  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c "if [ ! `which mvn` ]; then ./installMavenCentOS.sh  ; fi"
+  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c "command mvn >/dev/null || ./installMavenCentOS.sh"
 #install honeynode 1.2.1 simulators
   {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end}: - sh -c "./install_honeynode.sh 1.2.1"
 #patch OLM constant to speed up tests, unnecessary for PCE
@@ -76,6 +77,16 @@ basepython = python3
 deps = -rdocs/requirements.txt
 commands = sphinx-build -b linkcheck -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/linkcheck
 
+[testenv:checkbashisms]
+deps =
+whitelist_externals = sh
+                      checkbashisms
+                      sudo
+                      find
+commands =
+    sh -c 'command checkbashisms>/dev/null || sudo yum install devscripts-minimal || (echo "checkbashisms command not found - please install it (e.g. sudo apt-get install devscripts | yum install devscripts-minimal )" >&2 && exit 1)'
+    find . -not -path '*/\.*' -name *.sh -exec checkbashisms -f  \{\} +
+
 [testenv:spelling]
 basepython = python3
 deps =