Mercurial > hg
comparison tests/run-tests.py @ 49305:53e9422a9b45
py3: catch FileExistsError instead of checking errno == EEXIST
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Tue, 31 May 2022 21:16:17 +0200 |
parents | 56f98406831b |
children | 2e726c934fcd |
comparison
equal
deleted
inserted
replaced
49304:48f1b314056b | 49305:53e9422a9b45 |
---|---|
1097 self._out = None | 1097 self._out = None |
1098 self._skipped = None | 1098 self._skipped = None |
1099 | 1099 |
1100 try: | 1100 try: |
1101 os.mkdir(self._threadtmp) | 1101 os.mkdir(self._threadtmp) |
1102 except OSError as e: | 1102 except FileExistsError: |
1103 if e.errno != errno.EEXIST: | 1103 pass |
1104 raise | |
1105 | 1104 |
1106 name = self._tmpname | 1105 name = self._tmpname |
1107 self._testtmp = os.path.join(self._threadtmp, name) | 1106 self._testtmp = os.path.join(self._threadtmp, name) |
1108 os.mkdir(self._testtmp) | 1107 os.mkdir(self._testtmp) |
1109 | 1108 |
3275 | 3274 |
3276 if self.options.exceptions: | 3275 if self.options.exceptions: |
3277 exceptionsdir = os.path.join(self._outputdir, b'exceptions') | 3276 exceptionsdir = os.path.join(self._outputdir, b'exceptions') |
3278 try: | 3277 try: |
3279 os.makedirs(exceptionsdir) | 3278 os.makedirs(exceptionsdir) |
3280 except OSError as e: | 3279 except FileExistsError: |
3281 if e.errno != errno.EEXIST: | 3280 pass |
3282 raise | |
3283 | 3281 |
3284 # Remove all existing exception reports. | 3282 # Remove all existing exception reports. |
3285 for f in os.listdir(exceptionsdir): | 3283 for f in os.listdir(exceptionsdir): |
3286 os.unlink(os.path.join(exceptionsdir, f)) | 3284 os.unlink(os.path.join(exceptionsdir, f)) |
3287 | 3285 |
3591 raise | 3589 raise |
3592 if self._findprogram(pyexename) != sysexecutable: | 3590 if self._findprogram(pyexename) != sysexecutable: |
3593 try: | 3591 try: |
3594 os.symlink(sysexecutable, mypython) | 3592 os.symlink(sysexecutable, mypython) |
3595 self._createdfiles.append(mypython) | 3593 self._createdfiles.append(mypython) |
3596 except OSError as err: | 3594 except FileExistsError: |
3597 # child processes may race, which is harmless | 3595 # child processes may race, which is harmless |
3598 if err.errno != errno.EEXIST: | 3596 pass |
3599 raise | |
3600 elif WINDOWS and not os.getenv('MSYSTEM'): | 3597 elif WINDOWS and not os.getenv('MSYSTEM'): |
3601 raise AssertionError('cannot run test on Windows without MSYSTEM') | 3598 raise AssertionError('cannot run test on Windows without MSYSTEM') |
3602 else: | 3599 else: |
3603 # Generate explicit file instead of symlink | 3600 # Generate explicit file instead of symlink |
3604 # | 3601 # |
3704 | 3701 |
3705 # setuptools requires install directories to exist. | 3702 # setuptools requires install directories to exist. |
3706 def makedirs(p): | 3703 def makedirs(p): |
3707 try: | 3704 try: |
3708 os.makedirs(p) | 3705 os.makedirs(p) |
3709 except OSError as e: | 3706 except FileExistsError: |
3710 if e.errno != errno.EEXIST: | 3707 pass |
3711 raise | |
3712 | 3708 |
3713 makedirs(self._pythondir) | 3709 makedirs(self._pythondir) |
3714 makedirs(self._bindir) | 3710 makedirs(self._bindir) |
3715 | 3711 |
3716 vlog("# Running", cmd.decode("utf-8")) | 3712 vlog("# Running", cmd.decode("utf-8")) |
3755 vlog('# Installing coverage rc to %s' % rc) | 3751 vlog('# Installing coverage rc to %s' % rc) |
3756 osenvironb[b'COVERAGE_PROCESS_START'] = rc | 3752 osenvironb[b'COVERAGE_PROCESS_START'] = rc |
3757 covdir = os.path.join(self._installdir, b'..', b'coverage') | 3753 covdir = os.path.join(self._installdir, b'..', b'coverage') |
3758 try: | 3754 try: |
3759 os.mkdir(covdir) | 3755 os.mkdir(covdir) |
3760 except OSError as e: | 3756 except FileExistsError: |
3761 if e.errno != errno.EEXIST: | 3757 pass |
3762 raise | |
3763 | 3758 |
3764 osenvironb[b'COVERAGE_DIR'] = covdir | 3759 osenvironb[b'COVERAGE_DIR'] = covdir |
3765 | 3760 |
3766 def _checkhglib(self, verb): | 3761 def _checkhglib(self, verb): |
3767 """Ensure that the 'mercurial' package imported by python is | 3762 """Ensure that the 'mercurial' package imported by python is |