changeset 75:2bfa2499e971

Make run-example print better error messages when things go wrong.
author Bryan O'Sullivan <bos@serpentine.com>
date Wed, 30 Aug 2006 00:11:17 -0700
parents ec1f144968de
children df88df78288d
files en/examples/run-example
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/en/examples/run-example	Wed Aug 30 00:02:02 2006 -0700
+++ b/en/examples/run-example	Wed Aug 30 00:11:17 2006 -0700
@@ -9,7 +9,6 @@
 import os
 import pty
 import re
-import select
 import shutil
 import signal
 import stat
@@ -169,7 +168,17 @@
     errs = 0
     if args:
         for a in args:
-            if example(a).run():
+            try:
+                st = os.lstat(a)
+            except OSError, err:
+                print >> sys.stderr, '%s: %s' % (a, err.strerror)
+                errs += 1
+                continue
+            if stat.S_ISREG(st.st_mode) and st.st_mode & 0111:
+                if example(a).run():
+                    errs += 1
+            else:
+                print >> sys.stderr, '%s: not a file, or not executable' % a
                 errs += 1
         return errs
     for name in os.listdir(path):