tests: add a PATH-sanity-check to help-version
authorJim Meyering <meyering@redhat.com>
Wed, 7 Apr 2010 09:47:28 +0000 (11:47 +0200)
committerJim Meyering <meyering@redhat.com>
Wed, 7 Apr 2010 09:47:28 +0000 (11:47 +0200)
* tests/misc/help-version: Sync from gzip's version.
* tests/check.mk (TESTS_ENVIRONMENT): Export VERSION, as required
for new help-version test.

tests/check.mk
tests/misc/help-version

index d3b08e0..df0c924 100644 (file)
@@ -69,6 +69,7 @@ TESTS_ENVIRONMENT =                           \
     fi;                                                \
   };                                           \
   export                                       \
+  VERSION='$(VERSION)'                         \
   LOCALE_FR='$(LOCALE_FR)'                     \
   LOCALE_FR_UTF8='$(LOCALE_FR_UTF8)'           \
   abs_top_builddir='$(abs_top_builddir)'       \
index 976d18a..ea16516 100755 (executable)
@@ -58,7 +58,20 @@ expected_failure_status_egrep=2
 expected_failure_status_fgrep=2
 
 test "$built_programs" \
-  || { echo "$this_test: no programs built!?!" 1>&2; Exit 1; }
+  || fail_ "built_programs not specified!?!"
+
+test "$VERSION" \
+  || fail_ "set envvar VERSION; it is required for a PATH sanity-check"
+
+# Extract version from --version output of the first program
+for i in $built_programs; do
+  v=$(env $i --version | sed -n '1s/.* //p;q')
+  break
+done
+
+# Ensure that it matches $VERSION.
+test "x$v" = "x$VERSION" \
+  || fail_ "--version-\$VERSION mismatch"
 
 for lang in C fr da; do
   for i in $built_programs; do