[PATCH 1/3] Use a single script to run the glade tests.
David Shea
dshea at redhat.com
Mon Feb 17 18:52:04 UTC 2014
All of the glade/run_*.sh do pretty much the same thing; we don't need
four copies of it. Modified the pw_visibility and validity checks to
accept and ignore the translation arguments and added a script to run
all the glade checks on all the glade files.
This change means that the tests won't run (potentially) in parallel,
but that shouldn't make a huge difference.
---
tests/Makefile.am | 12 +++------
tests/glade/accelerators/run_check_accelerators.sh | 23 -----------------
tests/glade/markup/run_check_markup.sh | 21 ---------------
tests/glade/pw_visibility/check_pw_visibility.py | 17 +++++++++---
.../glade/pw_visibility/run_check_pw_visibility.sh | 6 -----
tests/glade/run_glade_tests.sh | 30 ++++++++++++++++++++++
tests/glade/validity/check_glade_validity.py | 15 ++++++++++-
tests/glade/validity/run_check_glade_validity.sh | 10 --------
8 files changed, 60 insertions(+), 74 deletions(-)
delete mode 100755 tests/glade/accelerators/run_check_accelerators.sh
delete mode 100755 tests/glade/markup/run_check_markup.sh
delete mode 100755 tests/glade/pw_visibility/run_check_pw_visibility.sh
create mode 100755 tests/glade/run_glade_tests.sh
delete mode 100755 tests/glade/validity/run_check_glade_validity.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 81bf461..544c059 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -37,14 +37,11 @@ dist_check_DATA = pylint/pylint-false-positives
# Test scripts need to be listed both here and in TESTS
dist_check_SCRIPTS = glade/accelerators/check_accelerators.py \
- glade/accelerators/run_check_accelerators.sh \
glade/pw_visibility/check_pw_visibility.py \
- glade/pw_visibility/run_check_pw_visibility.sh \
glade/validity/check_glade_validity.py \
- glade/validity/run_check_glade_validity.sh \
- $(srcdir)/lib/*.py \
glade/markup/check_markup.py \
- glade/markup/run_check_markup.sh \
+ glade/run_glade_tests.sh \
+ $(srcdir)/lib/*.py \
nosetests.sh \
pylint/intl.py \
pylint/preconf.py \
@@ -65,10 +62,7 @@ TESTS = nosetests.sh \
gettext/gettext_warnings.sh \
gettext/gettext_potfiles.py \
storage/run_storage_tests.py \
- glade/accelerators/run_check_accelerators.sh \
- glade/pw_visibility/run_check_pw_visibility.sh \
- glade/validity/run_check_glade_validity.sh \
- glade/markup/run_check_markup.sh
+ glade/run_glade_tests.sh
clean-local:
-rm -rf pylint/.pylint.d
diff --git a/tests/glade/accelerators/run_check_accelerators.sh b/tests/glade/accelerators/run_check_accelerators.sh
deleted file mode 100755
index 846a73f..0000000
--- a/tests/glade/accelerators/run_check_accelerators.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-: "${top_srcdir:=$(dirname "$0")/../../..}"
-. "${top_srcdir}/tests/testenv.sh"
-srcdir="${top_srcdir}/tests/glade/accelerators"
-
-# If --translate was specified but not --podir, add --podir
-i=0
-translate_set=0
-podir_set=0
-for arg in "$@" ; do
- if [ "$arg" = "--translate" -o "$arg" = "-t" ]; then
- translate_set=1
- elif [ "$arg" = "--podir" -o "$arg" = "-p" ]; then
- podir_set=1
- fi
-done
-
-if [ "$translate_set" -eq 1 -a "$podir_set" -eq 0 ]; then
- set -- "$@" --podir "${top_srcdir}/po"
-fi
-
-find "${top_srcdir}" -name '*.glade' -exec "${srcdir}/check_accelerators.py" "$@" {} +
diff --git a/tests/glade/markup/run_check_markup.sh b/tests/glade/markup/run_check_markup.sh
deleted file mode 100755
index 7448dc1..0000000
--- a/tests/glade/markup/run_check_markup.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-: "${top_srcdir:=$(dirname "$0")/../../..}"
-. "${top_srcdir}/tests/testenv.sh"
-srcdir="${top_srcdir}/tests/glade/markup"
-
-translate_set=0
-podir_set=0
-for arg in "$@" ; do
- if [ "$arg" = "--translate" -o "$arg" = "-t" ]; then
- translate_set=1
- elif [ "$arg" = "--podir" -o "$arg" = "-p" ]; then
- podir_set=1
- fi
-done
-
-if [ "$translate_set" -eq 1 -a "$podir_set" -eq 0 ]; then
- set -- "$@" --podir "${top_srcdir}/po"
-fi
-
-find "${top_srcdir}/pyanaconda" -name '*.glade' -exec "${srcdir}/check_markup.py" "$@" {} +
diff --git a/tests/glade/pw_visibility/check_pw_visibility.py b/tests/glade/pw_visibility/check_pw_visibility.py
index 57b2a90..33fea2c 100755
--- a/tests/glade/pw_visibility/check_pw_visibility.py
+++ b/tests/glade/pw_visibility/check_pw_visibility.py
@@ -24,6 +24,7 @@ have the visibility set to False.
"""
+import argparse
import sys
try:
@@ -70,12 +71,20 @@ def check_glade_file(glade_file_path):
return succ
if __name__ == "__main__":
- if len(sys.argv) < 2:
- print "Need to specify .glade files to check"
- sys.exit(1)
+ parser = argparse.ArgumentParser("Check that password entries have visibility set to False")
+
+ # Ignore translation arguments
+ parser.add_argument("-t", "--translate", action='store_true',
+ help=argparse.SUPPRESS)
+ parser.add_argument("-p", "--podir", action='store', type=str,
+ metavar='PODIR', help=argparse.SUPPRESS, default='./po')
+
+ parser.add_argument("glade_files", nargs="+", metavar="GLADE-FILE",
+ help='The glade file to check')
+ args = parser.parse_args(args=sys.argv[1:])
success = True
- for file_path in sys.argv[1:]:
+ for file_path in args.glade_files:
success = success and check_glade_file(file_path)
sys.exit(0 if success else 1)
diff --git a/tests/glade/pw_visibility/run_check_pw_visibility.sh b/tests/glade/pw_visibility/run_check_pw_visibility.sh
deleted file mode 100755
index 3b58830..0000000
--- a/tests/glade/pw_visibility/run_check_pw_visibility.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-: "${top_srcdir:=$(dirname "$0")/../..}"
-srcdir="${top_srcdir}/tests/glade/pw_visibility"
-
-find "${top_srcdir}/pyanaconda" -name '*.glade' -exec "${srcdir}/check_pw_visibility.py" "$@" {} +
diff --git a/tests/glade/run_glade_tests.sh b/tests/glade/run_glade_tests.sh
new file mode 100755
index 0000000..6f34484
--- /dev/null
+++ b/tests/glade/run_glade_tests.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+: "${top_srcdir:=$(dirname "$0")/../..}"
+. "${top_srcdir}/tests/testenv.sh"
+srcdir="${top_srcdir}/tests/glade"
+
+# If --translated was specified but not --podir, add --podir
+translate_set=0
+podir_set=0
+for arg in "$@" ; do
+ if [ "$arg" = "--translate" -o "$arg" = "-t" ]; then
+ translate_set=1
+ elif echo "$arg" | grep -q '^--podir\(=.*\)\?$' || [ "$arg" = "-p" ]; then
+ podir_set=1
+ fi
+done
+
+if [ "$translate_set" -eq 1 -a "$podir_set" -eq 0 ]; then
+ set -- "$@" --podir "${top_srcdir}/po"
+fi
+
+status=0
+for check in ${srcdir}/*/check_*.py ; do
+ find "${top_srcdir}" -name '*.glade' | xargs "${check}" "$@"
+ if [ "$?" -ne 0 ]; then
+ status=1
+ fi
+done
+
+exit $status
diff --git a/tests/glade/validity/check_glade_validity.py b/tests/glade/validity/check_glade_validity.py
index 9f3695d..9a2c179 100755
--- a/tests/glade/validity/check_glade_validity.py
+++ b/tests/glade/validity/check_glade_validity.py
@@ -18,6 +18,7 @@
# Author: David Shea <dshea at redhat.com>
import sys
+import argparse
from collections import Counter
@@ -67,7 +68,19 @@ def main(argv):
success = False
if __name__ == "__main__":
- main(sys.argv[1:])
+ parser = argparse.ArgumentParser("Check glade file validity")
+
+ # Ignore translation arguments
+ parser.add_argument("-t", "--translate", action='store_true',
+ help=argparse.SUPPRESS)
+ parser.add_argument("-p", "--podir", action='store', type=str,
+ metavar='PODIR', help=argparse.SUPPRESS, default='./po')
+
+ parser.add_argument("glade_files", nargs="+", metavar="GLADE-FILE",
+ help='The glade file to check')
+ args = parser.parse_args(args=sys.argv[1:])
+
+ main(args.glade_files)
if success:
sys.exit(0)
diff --git a/tests/glade/validity/run_check_glade_validity.sh b/tests/glade/validity/run_check_glade_validity.sh
deleted file mode 100755
index a6e6fe1..0000000
--- a/tests/glade/validity/run_check_glade_validity.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-if [ -z "$top_srcdir" ]; then
- top_srcdir="$(dirname "$0")/../../.."
- . "${top_srcdir}/tests/testenv.sh"
-fi
-
-srcdir="${top_srcdir}/tests/glade/validity"
-
-find "${top_srcdir}" -name '*.glade' -exec "${srcdir}/check_glade_validity.py" "$@" {} +
--
1.8.5.3
More information about the anaconda-patches
mailing list