hgbook

changeset 160:745ff473c8c4

Catch more errors.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon Mar 26 21:25:34 2007 -0700 (2007-03-26)
parents 7355af913937
children 7f07aca44938
files en/examples/run-example
line diff
     1.1 --- a/en/examples/run-example	Thu Mar 22 23:03:11 2007 -0700
     1.2 +++ b/en/examples/run-example	Mon Mar 26 21:25:34 2007 -0700
     1.3 @@ -211,7 +211,7 @@
     1.4                              assert os.sep not in out
     1.5                              if ofp is not None:
     1.6                                  ofp.close()
     1.7 -                                err = self.rename_output(ofp_basename, ignore)
     1.8 +                                err |= self.rename_output(ofp_basename, ignore)
     1.9                              if out:
    1.10                                  ofp_basename = '%s.%s' % (self.name, out)
    1.11                                  ofp = open(ofp_basename + '.tmp', 'w')
    1.12 @@ -247,20 +247,21 @@
    1.13                      if ofp is not None:
    1.14                          ofp.write(output)
    1.15                          ofp.close()
    1.16 -                        err = self.rename_output(ofp_basename, ignore)
    1.17 +                        err |= self.rename_output(ofp_basename, ignore)
    1.18                      os.close(self.cfd)
    1.19                  except IOError:
    1.20                      pass
    1.21                  os.kill(self.pid, signal.SIGTERM)
    1.22                  pid, rc = os.wait()
    1.23 -                if rc:
    1.24 +                err = err or rc
    1.25 +                if err:
    1.26                      if os.WIFEXITED(rc):
    1.27                          print >> sys.stderr, '(exit %s)' % os.WEXITSTATUS(rc)
    1.28                      elif os.WIFSIGNALED(rc):
    1.29                          print >> sys.stderr, '(signal %s)' % os.WTERMSIG(rc)
    1.30                  else:
    1.31                      open(self.name + '.run', 'w')
    1.32 -                return rc or err
    1.33 +                return err
    1.34          finally:
    1.35              shutil.rmtree(tmpdir)
    1.36  
    1.37 @@ -292,9 +293,10 @@
    1.38              if err.errno != errno.ENOENT:
    1.39                  raise
    1.40              os.rename(errname, oldname)
    1.41 -            return
    1.42 +            return False
    1.43          if matchfp(oldfp, errfp):
    1.44              os.unlink(errname)
    1.45 +            return False
    1.46          else:
    1.47              print >> sys.stderr, '\nOutput of %s has changed!' % base
    1.48              os.system('diff -u %s %s 1>&2' % (oldname, errname))