340 |
340 |
341 def __init__(self, options, path, tmpdir, abort, keeptmpdir=False, |
341 def __init__(self, options, path, tmpdir, abort, keeptmpdir=False, |
342 debug=False, nodiff=False, diffviewer=None, |
342 debug=False, nodiff=False, diffviewer=None, |
343 interactive=False, timeout=defaults['timeout'], |
343 interactive=False, timeout=defaults['timeout'], |
344 startport=defaults['port'], extraconfigopts=None, |
344 startport=defaults['port'], extraconfigopts=None, |
345 py3kwarnings=False): |
345 py3kwarnings=False, shell=None): |
346 """Create a test from parameters. |
346 """Create a test from parameters. |
347 |
347 |
348 options are parsed command line options that control test execution. |
348 options are parsed command line options that control test execution. |
349 |
349 |
350 path is the full path to the file defining the test. |
350 path is the full path to the file defining the test. |
378 extraconfigopts is an iterable of extra hgrc config options. Values |
378 extraconfigopts is an iterable of extra hgrc config options. Values |
379 must have the form "key=value" (something understood by hgrc). Values |
379 must have the form "key=value" (something understood by hgrc). Values |
380 of the form "foo.key=value" will result in "[foo] key=value". |
380 of the form "foo.key=value" will result in "[foo] key=value". |
381 |
381 |
382 py3kwarnings enables Py3k warnings. |
382 py3kwarnings enables Py3k warnings. |
|
383 |
|
384 shell is the shell to execute tests in. |
383 """ |
385 """ |
384 |
386 |
385 self.path = path |
387 self.path = path |
386 self.name = os.path.basename(path) |
388 self.name = os.path.basename(path) |
387 self._testdir = os.path.dirname(path) |
389 self._testdir = os.path.dirname(path) |
397 self._interactive = interactive |
399 self._interactive = interactive |
398 self._timeout = timeout |
400 self._timeout = timeout |
399 self._startport = startport |
401 self._startport = startport |
400 self._extraconfigopts = extraconfigopts or [] |
402 self._extraconfigopts = extraconfigopts or [] |
401 self._py3kwarnings = py3kwarnings |
403 self._py3kwarnings = py3kwarnings |
|
404 self._shell = shell |
402 self._daemonpids = [] |
405 self._daemonpids = [] |
403 |
406 |
404 self._finished = None |
407 self._finished = None |
405 self._ret = None |
408 self._ret = None |
406 self._out = None |
409 self._out = None |
728 f = open(fname, 'w') |
731 f = open(fname, 'w') |
729 for l in script: |
732 for l in script: |
730 f.write(l) |
733 f.write(l) |
731 f.close() |
734 f.close() |
732 |
735 |
733 cmd = '%s "%s"' % (self._options.shell, fname) |
736 cmd = '%s "%s"' % (self._shell, fname) |
734 vlog("# Running", cmd) |
737 vlog("# Running", cmd) |
735 |
738 |
736 exitcode, output = run(cmd, self._testtmp, replacements, env, |
739 exitcode, output = run(cmd, self._testtmp, replacements, env, |
737 self._abort, debug=self._debug, |
740 self._abort, debug=self._debug, |
738 timeout=self._timeout) |
741 timeout=self._timeout) |
745 |
748 |
746 def _hghave(self, reqs): |
749 def _hghave(self, reqs): |
747 # TODO do something smarter when all other uses of hghave are gone. |
750 # TODO do something smarter when all other uses of hghave are gone. |
748 tdir = self._testdir.replace('\\', '/') |
751 tdir = self._testdir.replace('\\', '/') |
749 proc = Popen4('%s -c "%s/hghave %s"' % |
752 proc = Popen4('%s -c "%s/hghave %s"' % |
750 (self._options.shell, tdir, ' '.join(reqs)), |
753 (self._shell, tdir, ' '.join(reqs)), |
751 self._testtmp, 0) |
754 self._testtmp, 0) |
752 stdout, stderr = proc.communicate() |
755 stdout, stderr = proc.communicate() |
753 ret = proc.wait() |
756 ret = proc.wait() |
754 if wifexited(ret): |
757 if wifexited(ret): |
755 ret = os.WEXITSTATUS(ret) |
758 ret = os.WEXITSTATUS(ret) |
1525 diffviewer=self.options.view, |
1528 diffviewer=self.options.view, |
1526 interactive=self.options.interactive, |
1529 interactive=self.options.interactive, |
1527 timeout=self.options.timeout, |
1530 timeout=self.options.timeout, |
1528 startport=self.options.port + count * 3, |
1531 startport=self.options.port + count * 3, |
1529 extraconfigopts=self.options.extra_config_opt, |
1532 extraconfigopts=self.options.extra_config_opt, |
1530 py3kwarnings=self.options.py3k_warnings) |
1533 py3kwarnings=self.options.py3k_warnings, |
|
1534 shell=self.options.shell) |
1531 |
1535 |
1532 def _cleanup(self): |
1536 def _cleanup(self): |
1533 """Clean up state from this test invocation.""" |
1537 """Clean up state from this test invocation.""" |
1534 |
1538 |
1535 if self.options.keep_tmpdir: |
1539 if self.options.keep_tmpdir: |