test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / py-compile-destdir.sh
old mode 100755 (executable)
new mode 100644 (file)
index 4d303d5..becd8ac
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2011-2012 Free Software Foundation, Inc.
+# Copyright (C) 2011-2013 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
 # Test the '--destdir' option of the 'py-compile' script,
 
 required=python
-. ./defs || exit 1
+. test-init.sh
 
 cp "$am_scriptdir/py-compile" . \
   || fatal_ "failed to fetch auxiliary script py-compile"
@@ -31,13 +31,17 @@ echo 'def foo (): return "foo"' > $destdir/foo.py
 echo 'def bar (): return "bar"' > $destdir/sub/bar.py
 
 ./py-compile --destdir $destdir foo.py sub/bar.py
-ls -l $destdir $destdir/sub # For debugging.
-ls . sub | grep '\.py[co]$' && exit 1
-test -f $destdir/foo.pyc
-test -f $destdir/foo.pyo
-test -f $destdir/sub/bar.pyc
-test -f $destdir/sub/bar.pyo
-strings $destdir/*.py[co] $destdir/sub/*.py[co] || : # For debugging.
-$FGREP $destdir $destdir/*.py[co] $destdir/sub/*.py[co] && exit 1
+
+find $destdir # For debugging.
+st=0
+for x in c o; do
+  for b in foo sub/bar; do
+    f=$(pyc_location -p "$destdir/$b.py$x")
+    test -f "$f"
+    strings "$f" || : # For debugging.
+    $FGREP $destdir $f && { echo BAD: $f; st=1; }
+  done
+done
+exit $st
 
 :