python tests: support PEP-3147 installation layout
[platform/upstream/automake.git] / t / py-compile-basedir.sh
index 1504f55..75b45f7 100755 (executable)
@@ -17,7 +17,7 @@
 # Test the '--basedir' option of the 'py-compile' script,
 
 required=python
-. ./defs || Exit 1
+. ./defs || exit 1
 
 # We'll need to create files in '..', so we need one more subdirectory
 # level in order not to clutter up the top-level tests directory.
@@ -28,23 +28,27 @@ cp "$am_scriptdir/py-compile" . \
   || fatal_ "failed to fetch auxiliary script py-compile"
 
 f=__init__
-for d in foo foo/bar "`pwd`/foo" . .. ../foo ''; do
+for d in foo foo/bar "$(pwd)/foo" . .. ../foo ''; do
   if test -z "$d"; then
     d2=.
   else
     d2=$d
   fi
-  ../install-sh -d "$d2" "$d2/sub" || Exit 99
+  ../install-sh -d "$d2" "$d2/sub" || exit 99
   : > "$d2/$f.py"
   : > "$d2/sub/$f.py"
   ./py-compile --basedir "$d" "$f.py" "sub/$f.py"
-  ls -l "$d2" "$d2/sub" # For debugging.
-  test -f "$d2/$f.pyc"
-  test -f "$d2/$f.pyo"
-  test -f "$d2/sub/$f.pyc"
-  test -f "$d2/sub/$f.pyo"
-  rm -f "$d2/$f.pyc" "$d2/$f.pyo" "$d2/sub/$f.pyc" "$d2/sub/$f.pyo"
-  find . | grep '\.py[co]$' && Exit 1
+  find "$d2" # For debugging.
+  py_installed "$d2/$f.pyc"
+  py_installed "$d2/$f.pyo"
+  py_installed "$d2/sub/$f.pyc"
+  py_installed "$d2/sub/$f.pyo"
+  files=$(find "$d2" | grep '\.py[co]$')
+  test $(echo "$files" | wc -l) -eq 4
+  case $d2 in
+    .|..) rm -f $files;;
+       *) rm -rf "$d2";;
+  esac
 done
 
 :