tests/run-tests.py
changeset 21512 265d94cae168
parent 21511 3ec3e81a4110
child 21513 acfd19f3e79c
equal deleted inserted replaced
21511:3ec3e81a4110 21512:265d94cae168
   337 
   337 
   338     # Status code reserved for skipped tests (used by hghave).
   338     # Status code reserved for skipped tests (used by hghave).
   339     SKIPPED_STATUS = 80
   339     SKIPPED_STATUS = 80
   340 
   340 
   341     def __init__(self, options, path, count, tmpdir, abort, keeptmpdir=False,
   341     def __init__(self, options, path, count, tmpdir, abort, keeptmpdir=False,
   342                  debug=False, nodiff=False, diffviewer=None):
   342                  debug=False, nodiff=False, diffviewer=None,
       
   343                  interactive=False):
   343         """Create a test from parameters.
   344         """Create a test from parameters.
   344 
   345 
   345         options are parsed command line options that control test execution.
   346         options are parsed command line options that control test execution.
   346 
   347 
   347         path is the full path to the file defining the test.
   348         path is the full path to the file defining the test.
   361 
   362 
   362         nodiff will suppress the printing of a diff when output changes.
   363         nodiff will suppress the printing of a diff when output changes.
   363 
   364 
   364         diffviewer is the program that should be used to display diffs. Only
   365         diffviewer is the program that should be used to display diffs. Only
   365         used when output changes.
   366         used when output changes.
       
   367 
       
   368         interactive controls whether the test will run interactively.
   366         """
   369         """
   367 
   370 
   368         self.path = path
   371         self.path = path
   369         self.name = os.path.basename(path)
   372         self.name = os.path.basename(path)
   370         self._testdir = os.path.dirname(path)
   373         self._testdir = os.path.dirname(path)
   376         self._abort = abort
   379         self._abort = abort
   377         self._keeptmpdir = keeptmpdir
   380         self._keeptmpdir = keeptmpdir
   378         self._debug = debug
   381         self._debug = debug
   379         self._nodiff = nodiff
   382         self._nodiff = nodiff
   380         self._diffviewer = diffviewer
   383         self._diffviewer = diffviewer
       
   384         self._interactive = interactive
   381         self._daemonpids = []
   385         self._daemonpids = []
   382 
   386 
   383         self._finished = None
   387         self._finished = None
   384         self._ret = None
   388         self._ret = None
   385         self._out = None
   389         self._out = None
   643     def fail(self, msg, ret):
   647     def fail(self, msg, ret):
   644         warned = ret is False
   648         warned = ret is False
   645         if not self._nodiff:
   649         if not self._nodiff:
   646             log("\n%s: %s %s" % (warned and 'Warning' or 'ERROR', self.name,
   650             log("\n%s: %s %s" % (warned and 'Warning' or 'ERROR', self.name,
   647                                  msg))
   651                                  msg))
   648         if (not ret and self._options.interactive and
   652         if (not ret and self._interactive and
   649             os.path.exists(self.errpath)):
   653             os.path.exists(self.errpath)):
   650             iolock.acquire()
   654             iolock.acquire()
   651             print 'Accept this change? [n] ',
   655             print 'Accept this change? [n] ',
   652             answer = sys.stdin.readline().strip()
   656             answer = sys.stdin.readline().strip()
   653             iolock.release()
   657             iolock.release()
  1501 
  1505 
  1502         return testcls(self.options, refpath, count, tmpdir, self.abort,
  1506         return testcls(self.options, refpath, count, tmpdir, self.abort,
  1503                        keeptmpdir=self.options.keep_tmpdir,
  1507                        keeptmpdir=self.options.keep_tmpdir,
  1504                        debug=self.options.debug,
  1508                        debug=self.options.debug,
  1505                        nodiff = self.options.nodiff,
  1509                        nodiff = self.options.nodiff,
  1506                        diffviewer=self.options.view)
  1510                        diffviewer=self.options.view,
       
  1511                        interactive=self.options.interactive)
  1507 
  1512 
  1508     def _cleanup(self):
  1513     def _cleanup(self):
  1509         """Clean up state from this test invocation."""
  1514         """Clean up state from this test invocation."""
  1510 
  1515 
  1511         if self.options.keep_tmpdir:
  1516         if self.options.keep_tmpdir: