tests/run-tests.py
changeset 32980 8dc62c97a665
parent 32943 750c3b1bb8a3
child 32981 02bca6dc5f41
equal deleted inserted replaced
32979:66117dae87f9 32980:8dc62c97a665
   631         self._out = None
   631         self._out = None
   632         self._skipped = None
   632         self._skipped = None
   633         self._testtmp = None
   633         self._testtmp = None
   634         self._chgsockdir = None
   634         self._chgsockdir = None
   635 
   635 
       
   636         self._refout = self.readrefout()
       
   637 
       
   638     def readrefout(self):
       
   639         """read reference output"""
   636         # If we're not in --debug mode and reference output file exists,
   640         # If we're not in --debug mode and reference output file exists,
   637         # check test output against it.
   641         # check test output against it.
   638         if debug:
   642         if self._debug:
   639             self._refout = None # to match "out is None"
   643             return None # to match "out is None"
   640         elif os.path.exists(self.refpath):
   644         elif os.path.exists(self.refpath):
   641             f = open(self.refpath, 'rb')
   645             with open(self.refpath, 'rb') as f:
   642             self._refout = f.read().splitlines(True)
   646                 return f.read().splitlines(True)
   643             f.close()
       
   644         else:
   647         else:
   645             self._refout = []
   648             return []
   646 
   649 
   647     # needed to get base class __repr__ running
   650     # needed to get base class __repr__ running
   648     @property
   651     @property
   649     def _testMethodName(self):
   652     def _testMethodName(self):
   650         return self.name
   653         return self.name
  1586                             self.stream.write(line)
  1589                             self.stream.write(line)
  1587                             self.stream.flush()
  1590                             self.stream.flush()
  1588 
  1591 
  1589             # handle interactive prompt without releasing iolock
  1592             # handle interactive prompt without releasing iolock
  1590             if self._options.interactive:
  1593             if self._options.interactive:
  1591                 self.stream.write('Accept this change? [n] ')
  1594                 if test.readrefout() != expected:
  1592                 answer = sys.stdin.readline().strip()
  1595                     self.stream.write(
  1593                 if answer.lower() in ('y', 'yes'):
  1596                         'Reference output has changed (run again to prompt '
  1594                     if test.name.endswith('.t'):
  1597                         'changes)')
  1595                         rename(test.errpath, test.path)
  1598                 else:
  1596                     else:
  1599                     self.stream.write('Accept this change? [n] ')
  1597                         rename(test.errpath, '%s.out' % test.path)
  1600                     answer = sys.stdin.readline().strip()
  1598                     accepted = True
  1601                     if answer.lower() in ('y', 'yes'):
       
  1602                         if test.name.endswith('.t'):
       
  1603                             rename(test.errpath, test.path)
       
  1604                         else:
       
  1605                             rename(test.errpath, '%s.out' % test.path)
       
  1606                         accepted = True
  1599             if not accepted:
  1607             if not accepted:
  1600                 self.faildata[test.name] = b''.join(lines)
  1608                 self.faildata[test.name] = b''.join(lines)
  1601 
  1609 
  1602         return accepted
  1610         return accepted
  1603 
  1611