##// END OF EJS Templates
run-tests: do not prompt changes (-i) if a race condition is detected...
Jun Wu -
r32980:8dc62c97 default
parent child Browse files
Show More
@@ -633,16 +633,19 b' class Test(unittest.TestCase):'
633 633 self._testtmp = None
634 634 self._chgsockdir = None
635 635
636 self._refout = self.readrefout()
637
638 def readrefout(self):
639 """read reference output"""
636 640 # If we're not in --debug mode and reference output file exists,
637 641 # check test output against it.
638 if debug:
639 self._refout = None # to match "out is None"
642 if self._debug:
643 return None # to match "out is None"
640 644 elif os.path.exists(self.refpath):
641 f = open(self.refpath, 'rb')
642 self._refout = f.read().splitlines(True)
643 f.close()
645 with open(self.refpath, 'rb') as f:
646 return f.read().splitlines(True)
644 647 else:
645 self._refout = []
648 return []
646 649
647 650 # needed to get base class __repr__ running
648 651 @property
@@ -1588,14 +1591,19 b' class TestResult(unittest._TextTestResul'
1588 1591
1589 1592 # handle interactive prompt without releasing iolock
1590 1593 if self._options.interactive:
1591 self.stream.write('Accept this change? [n] ')
1592 answer = sys.stdin.readline().strip()
1593 if answer.lower() in ('y', 'yes'):
1594 if test.name.endswith('.t'):
1595 rename(test.errpath, test.path)
1596 else:
1597 rename(test.errpath, '%s.out' % test.path)
1598 accepted = True
1594 if test.readrefout() != expected:
1595 self.stream.write(
1596 'Reference output has changed (run again to prompt '
1597 'changes)')
1598 else:
1599 self.stream.write('Accept this change? [n] ')
1600 answer = sys.stdin.readline().strip()
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 1607 if not accepted:
1600 1608 self.faildata[test.name] = b''.join(lines)
1601 1609
@@ -641,6 +641,33 b' Accept the fix'
641 641 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
642 642 saved backup bundle to $TESTTMP/*.hg (glob)<
643 643
644 Race condition - test file was modified when test is running
645
646 $ TESTRACEDIR=`pwd`
647 $ export TESTRACEDIR
648 $ cat > test-race.t <<EOF
649 > $ echo 1
650 > $ echo "# a new line" >> $TESTRACEDIR/test-race.t
651 > EOF
652
653 $ rt -i test-race.t
654
655 --- $TESTTMP/test-race.t
656 +++ $TESTTMP/test-race.t.err
657 @@ -1,2 +1,3 @@
658 $ echo 1
659 + 1
660 $ echo "# a new line" >> $TESTTMP/test-race.t
661 Reference output has changed (run again to prompt changes)
662 ERROR: test-race.t output changed
663 !
664 Failed test-race.t: output changed
665 # Ran 1 tests, 0 skipped, 1 failed.
666 python hash seed: * (glob)
667 [1]
668
669 $ rm test-race.t
670
644 671 (reinstall)
645 672 $ mv backup test-failure.t
646 673
General Comments 0
You need to be logged in to leave comments. Login now