comparison en/examples/run-example @ 136:7b5894fffc37

Don't falsely signal success to make.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon, 05 Mar 2007 20:26:23 -0800
parents c9aad709bd3a
children 9d7dffe74b2c
comparison
equal deleted inserted replaced
135:0707489b90fd 136:7b5894fffc37
121 def run(self): 121 def run(self):
122 ofp = None 122 ofp = None
123 basename = os.path.basename(self.name) 123 basename = os.path.basename(self.name)
124 self.status('running %s ' % basename) 124 self.status('running %s ' % basename)
125 tmpdir = tempfile.mkdtemp(prefix=basename) 125 tmpdir = tempfile.mkdtemp(prefix=basename)
126
127 # remove the marker file that we tell make to use to see if
128 # this run succeeded
129 try:
130 os.unlink(self.name + '.run')
131 except OSError, err:
132 if err.errno != errno.ENOENT:
133 raise
126 134
127 rcfile = os.path.join(tmpdir, '.hgrc') 135 rcfile = os.path.join(tmpdir, '.hgrc')
128 rcfp = open(rcfile, 'w') 136 rcfp = open(rcfile, 'w')
129 print >> rcfp, '[ui]' 137 print >> rcfp, '[ui]'
130 print >> rcfp, "username = Bryan O'Sullivan <bos@serpentine.com>" 138 print >> rcfp, "username = Bryan O'Sullivan <bos@serpentine.com>"
198 ofp.write(hunk) 206 ofp.write(hunk)
199 # then its output 207 # then its output
200 ofp.write(tex_escape(output)) 208 ofp.write(tex_escape(output))
201 ps = newps 209 ps = newps
202 self.status('\n') 210 self.status('\n')
203 open(self.name + '.run', 'w')
204 except: 211 except:
205 print >> sys.stderr, '(killed)' 212 print >> sys.stderr, '(killed)'
206 os.kill(self.pid, signal.SIGKILL) 213 os.kill(self.pid, signal.SIGKILL)
207 pid, rc = os.wait() 214 pid, rc = os.wait()
208 raise 215 raise
219 if rc: 226 if rc:
220 if os.WIFEXITED(rc): 227 if os.WIFEXITED(rc):
221 print >> sys.stderr, '(exit %s)' % os.WEXITSTATUS(rc) 228 print >> sys.stderr, '(exit %s)' % os.WEXITSTATUS(rc)
222 elif os.WIFSIGNALED(rc): 229 elif os.WIFSIGNALED(rc):
223 print >> sys.stderr, '(signal %s)' % os.WTERMSIG(rc) 230 print >> sys.stderr, '(signal %s)' % os.WTERMSIG(rc)
231 else:
232 open(self.name + '.run', 'w')
224 return rc 233 return rc
225 finally: 234 finally:
226 shutil.rmtree(tmpdir) 235 shutil.rmtree(tmpdir)
227 236
228 def main(path='.'): 237 def main(path='.'):