Commits

Bryan O'Sullivan committed d374685

Handle a few more common regexps. Clean up on exit nicely.

  • Participants
  • Parent commits 9d7dffe

Comments (0)

Files changed (1)

en/examples/run-example

             r'^(?:---|\+\+\+) .*', # diff header with dates
             r'^date:.*', # date
             r'^diff -r.*', # "diff -r" is followed by hash
+            r'^# Date \d+ \d+', # hg patch header
+            r'^# Node ID [0-9a-f]{40}', # hg patch header
+            r'^# Parent  [0-9a-f]{40}', # hg patch header
             ]
 
+        err = False
+
         try:
             try:
                 # eat first prompt string from shell
                             assert os.sep not in out
                             if ofp is not None:
                                 ofp.close()
-                                self.rename_output(ofp_basename, ignore)
+                                err = self.rename_output(ofp_basename, ignore)
                             if out:
                                 ofp_basename = '%s.%s' % (self.name, out)
                                 ofp = open(ofp_basename + '.tmp', 'w')
             else:
                 try:
                     ps, output = self.sendreceive('exit\n')
-                    if ofp:
+                    if ofp is not None:
                         ofp.write(output)
+                        ofp.close()
+                        err = self.rename_output(ofp_basename, ignore)
                     os.close(self.cfd)
                 except IOError:
                     pass
                         print >> sys.stderr, '(signal %s)' % os.WTERMSIG(rc)
                 else:
                     open(self.name + '.run', 'w')
-                return rc
+                return rc or err
         finally:
             shutil.rmtree(tmpdir)
 
         else:
             print >> sys.stderr, '\nOutput of %s has changed!' % base
             os.system('diff -u %s %s 1>&2' % (oldname, errname))
+            return True
 
 def main(path='.'):
     opts, args = getopt.getopt(sys.argv[1:], 'v', ['verbose'])