Mercurial > public > mercurial-scm > hg
comparison tests/run-tests.py @ 25034:af6e6a0781d7
run-tests: use bytes explicitly for tmpdir and hgrc construction
We now get slightly further on Python 3. Python 2.6 still works.
author | Augie Fackler <augie@google.com> |
---|---|
date | Sat, 11 Apr 2015 18:26:58 -0400 |
parents | 2bdd9e442bcc |
children | 1203ca7005fa |
comparison
equal
deleted
inserted
replaced
25033:2bdd9e442bcc | 25034:af6e6a0781d7 |
---|---|
428 py3kwarnings enables Py3k warnings. | 428 py3kwarnings enables Py3k warnings. |
429 | 429 |
430 shell is the shell to execute tests in. | 430 shell is the shell to execute tests in. |
431 """ | 431 """ |
432 | 432 |
433 self.path = path | 433 self.path = path.encode('utf-8') |
434 self.name = os.path.basename(path) | 434 self.name = os.path.basename(path) |
435 self._testdir = os.path.dirname(path) | 435 self._testdir = os.path.dirname(path) |
436 self.errpath = os.path.join(self._testdir, '%s.err' % self.name) | 436 self.errpath = os.path.join(self._testdir, '%s.err' % self.name) |
437 | 437 |
438 self._threadtmp = tmpdir | 438 self._threadtmp = tmpdir.encode('utf-8') |
439 self._keeptmpdir = keeptmpdir | 439 self._keeptmpdir = keeptmpdir |
440 self._debug = debug | 440 self._debug = debug |
441 self._timeout = timeout | 441 self._timeout = timeout |
442 self._startport = startport | 442 self._startport = startport |
443 self._extraconfigopts = extraconfigopts or [] | 443 self._extraconfigopts = extraconfigopts or [] |
687 env['TESTTMP'] = self._testtmp | 687 env['TESTTMP'] = self._testtmp |
688 env['HOME'] = self._testtmp | 688 env['HOME'] = self._testtmp |
689 env["HGPORT"] = str(self._startport) | 689 env["HGPORT"] = str(self._startport) |
690 env["HGPORT1"] = str(self._startport + 1) | 690 env["HGPORT1"] = str(self._startport + 1) |
691 env["HGPORT2"] = str(self._startport + 2) | 691 env["HGPORT2"] = str(self._startport + 2) |
692 env["HGRCPATH"] = os.path.join(self._threadtmp, '.hgrc') | 692 env["HGRCPATH"] = os.path.join(self._threadtmp, b'.hgrc') |
693 env["DAEMON_PIDS"] = os.path.join(self._threadtmp, 'daemon.pids') | 693 env["DAEMON_PIDS"] = os.path.join(self._threadtmp, b'daemon.pids') |
694 env["HGEDITOR"] = ('"' + sys.executable + '"' | 694 env["HGEDITOR"] = ('"' + sys.executable + '"' |
695 + ' -c "import sys; sys.exit(0)"') | 695 + ' -c "import sys; sys.exit(0)"') |
696 env["HGMERGE"] = "internal:merge" | 696 env["HGMERGE"] = "internal:merge" |
697 env["HGUSER"] = "test" | 697 env["HGUSER"] = "test" |
698 env["HGENCODING"] = "ascii" | 698 env["HGENCODING"] = "ascii" |
719 return env | 719 return env |
720 | 720 |
721 def _createhgrc(self, path): | 721 def _createhgrc(self, path): |
722 """Create an hgrc file for this test.""" | 722 """Create an hgrc file for this test.""" |
723 hgrc = open(path, 'wb') | 723 hgrc = open(path, 'wb') |
724 hgrc.write('[ui]\n') | 724 hgrc.write(b'[ui]\n') |
725 hgrc.write('slash = True\n') | 725 hgrc.write(b'slash = True\n') |
726 hgrc.write('interactive = False\n') | 726 hgrc.write(b'interactive = False\n') |
727 hgrc.write('mergemarkers = detailed\n') | 727 hgrc.write(b'mergemarkers = detailed\n') |
728 hgrc.write('promptecho = True\n') | 728 hgrc.write(b'promptecho = True\n') |
729 hgrc.write('[defaults]\n') | 729 hgrc.write(b'[defaults]\n') |
730 hgrc.write('backout = -d "0 0"\n') | 730 hgrc.write(b'backout = -d "0 0"\n') |
731 hgrc.write('commit = -d "0 0"\n') | 731 hgrc.write(b'commit = -d "0 0"\n') |
732 hgrc.write('shelve = --date "0 0"\n') | 732 hgrc.write(b'shelve = --date "0 0"\n') |
733 hgrc.write('tag = -d "0 0"\n') | 733 hgrc.write(b'tag = -d "0 0"\n') |
734 hgrc.write('[devel]\n') | 734 hgrc.write(b'[devel]\n') |
735 hgrc.write('all = true\n') | 735 hgrc.write(b'all = true\n') |
736 hgrc.write('[largefiles]\n') | 736 hgrc.write(b'[largefiles]\n') |
737 hgrc.write('usercache = %s\n' % | 737 hgrc.write(b'usercache = %s\n' % |
738 (os.path.join(self._testtmp, '.cache/largefiles'))) | 738 (os.path.join(self._testtmp, b'.cache/largefiles'))) |
739 | 739 |
740 for opt in self._extraconfigopts: | 740 for opt in self._extraconfigopts: |
741 section, key = opt.split('.', 1) | 741 section, key = opt.split('.', 1) |
742 assert '=' in key, ('extra config opt %s must ' | 742 assert '=' in key, ('extra config opt %s must ' |
743 'have an = for assignment' % opt) | 743 'have an = for assignment' % opt) |
744 hgrc.write('[%s]\n%s\n' % (section, key)) | 744 hgrc.write(b'[%s]\n%s\n' % (section, key)) |
745 hgrc.close() | 745 hgrc.close() |
746 | 746 |
747 def fail(self, msg): | 747 def fail(self, msg): |
748 # unittest differentiates between errored and failed. | 748 # unittest differentiates between errored and failed. |
749 # Failed is denoted by AssertionError (by default at least). | 749 # Failed is denoted by AssertionError (by default at least). |