From a01eb723447630184ee77b222663775ec5ed0b8e Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Mon, 1 Jun 2020 18:18:19 +0100
Subject: [PATCH] tests: Adjust QA checks for per-directory meson.build

Now that G_TEST_SRCDIR is what Autotools would call
"${top_srcdir}/tests/", we need to look one level up for the root of
the source tree.

Fixes: 09925ab2 "build: Split into subdirectories"
Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 tests/mypy.sh        | 13 ++++++-------
 tests/pycodestyle.sh | 13 ++++++-------
 tests/pyflakes.sh    | 13 ++++++-------
 tests/shellcheck.sh  | 15 +++++++--------
 4 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/tests/mypy.sh b/tests/mypy.sh
index af0cb055a..76d73b27a 100755
--- a/tests/mypy.sh
+++ b/tests/mypy.sh
@@ -28,20 +28,19 @@ set -u
 
 if [ -z "${G_TEST_SRCDIR-}" ]; then
     me="$(readlink -f "$0")"
-    srcdir="${me%/*}"
-    G_TEST_SRCDIR="${srcdir%/*}"
+    G_TEST_SRCDIR="${me%/*}"
 fi
 
-cd "$G_TEST_SRCDIR"
+cd "$G_TEST_SRCDIR/.."
 
 export MYPYPATH="${PYTHONPATH:="$(pwd)"}"
 
 i=0
 for script in \
-    "${G_TEST_SRCDIR}"/*.py \
-    "${G_TEST_SRCDIR}"/pressure-vessel-test-ui \
-    "${G_TEST_SRCDIR}"/sysroot/*.py \
-    "${G_TEST_SRCDIR}"/tests/*.py \
+    ./*.py \
+    ./pressure-vessel-test-ui \
+    ./sysroot/*.py \
+    ./tests/*.py \
 ; do
     i=$((i + 1))
     if [ "x${MYPY:="$(command -v mypy || echo false)"}" = xfalse ]; then
diff --git a/tests/pycodestyle.sh b/tests/pycodestyle.sh
index cd33d6bf4..2e3b6146c 100755
--- a/tests/pycodestyle.sh
+++ b/tests/pycodestyle.sh
@@ -28,11 +28,10 @@ set -u
 
 if [ -z "${G_TEST_SRCDIR-}" ]; then
     me="$(readlink -f "$0")"
-    srcdir="${me%/*}"
-    G_TEST_SRCDIR="${srcdir%/*}"
+    G_TEST_SRCDIR="${me%/*}"
 fi
 
-cd "$G_TEST_SRCDIR"
+cd "$G_TEST_SRCDIR/.."
 
 if [ "x${PYCODESTYLE:=pycodestyle}" = xfalse ] || \
         [ -z "$(command -v "$PYCODESTYLE")" ]; then
@@ -48,10 +47,10 @@ echo "1..1"
 
 if "${PYCODESTYLE}" \
     --ignore=E402,W503 \
-    "$G_TEST_SRCDIR"/*.py \
-    "${G_TEST_SRCDIR}"/pressure-vessel-test-ui \
-    "${G_TEST_SRCDIR}"/sysroot/*.py \
-    "${G_TEST_SRCDIR}"/tests/*.py \
+    ./*.py \
+    ./pressure-vessel-test-ui \
+    ./sysroot/*.py \
+    ./tests/*.py \
     >&2; then
     echo "ok 1 - $PYCODESTYLE reported no issues"
 else
diff --git a/tests/pyflakes.sh b/tests/pyflakes.sh
index 8da6f8dd7..5511bfa24 100755
--- a/tests/pyflakes.sh
+++ b/tests/pyflakes.sh
@@ -28,20 +28,19 @@ set -u
 
 if [ -z "${G_TEST_SRCDIR-}" ]; then
     me="$(readlink -f "$0")"
-    srcdir="${me%/*}"
-    G_TEST_SRCDIR="${srcdir%/*}"
+    G_TEST_SRCDIR="${me%/*}"
 fi
 
-cd "$G_TEST_SRCDIR"
+cd "$G_TEST_SRCDIR/.."
 
 if [ "x${PYFLAKES:=pyflakes3}" = xfalse ] || \
         [ -z "$(command -v "$PYFLAKES")" ]; then
     echo "1..0 # SKIP pyflakes3 not found"
 elif "${PYFLAKES}" \
-    "${G_TEST_SRCDIR}"/*.py \
-    "${G_TEST_SRCDIR}"/pressure-vessel-test-ui \
-    "${G_TEST_SRCDIR}"/sysroot/*.py \
-    "${G_TEST_SRCDIR}"/tests/*.py \
+    ./*.py \
+    ./pressure-vessel-test-ui \
+    ./sysroot/*.py \
+    ./tests/*.py \
     >&2; then
     echo "1..1"
     echo "ok 1 - $PYFLAKES reported no issues"
diff --git a/tests/shellcheck.sh b/tests/shellcheck.sh
index 85dbaff91..f952e5127 100755
--- a/tests/shellcheck.sh
+++ b/tests/shellcheck.sh
@@ -28,19 +28,18 @@ fi
 
 if [ -z "${G_TEST_SRCDIR-}" ]; then
     me="$(readlink -f "$0")"
-    srcdir="${me%/*}"
-    G_TEST_SRCDIR="${srcdir%/*}"
+    G_TEST_SRCDIR="${me%/*}"
 fi
 
-cd "$G_TEST_SRCDIR"
+cd "$G_TEST_SRCDIR/.."
 
 n=0
 for shell_script in \
-        pressure-vessel-unruntime \
-        pressure-vessel-unruntime-scout \
-        pressure-vessel-unruntime-test-ui \
-        pressure-vessel-locale-gen \
-        tests/*.sh \
+        ./pressure-vessel-unruntime \
+        ./pressure-vessel-unruntime-scout \
+        ./pressure-vessel-unruntime-test-ui \
+        ./pressure-vessel-locale-gen \
+        ./tests/*.sh \
         ; do
     n=$((n + 1))
 
-- 
GitLab