comparison tests/run-tests.py @ 47498:9d929f9cb9b4

run-tests: avoid an early return To fix the "python3 pointing to python2" we will also need to create a "python" pointer. So we will need to create multiple pointer. So we need to stop using early return. We replace the early return with a loop and a continue, since the next changeset will introduce that loop anyway. Differential Revision: https://phab.mercurial-scm.org/D10942
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 02 Jul 2021 22:58:04 +0200
parents 50829b9149b0
children 23f5ed6dbcb1
comparison
equal deleted inserted replaced
47497:50829b9149b0 47498:9d929f9cb9b4
3538 # Administrator rights. 3538 # Administrator rights.
3539 if getattr(os, 'symlink', None) and os.name != 'nt': 3539 if getattr(os, 'symlink', None) and os.name != 'nt':
3540 msg = "# Making python executable in test path a symlink to '%s'" 3540 msg = "# Making python executable in test path a symlink to '%s'"
3541 msg %= sysexecutable 3541 msg %= sysexecutable
3542 vlog(msg) 3542 vlog(msg)
3543 mypython = os.path.join(self._tmpbindir, pyexename) 3543 for pyexename in [pyexename]:
3544 try: 3544 mypython = os.path.join(self._tmpbindir, pyexename)
3545 if os.readlink(mypython) == sysexecutable:
3546 return
3547 os.unlink(mypython)
3548 except OSError as err:
3549 if err.errno != errno.ENOENT:
3550 raise
3551 if self._findprogram(pyexename) != sysexecutable:
3552 try: 3545 try:
3553 os.symlink(sysexecutable, mypython) 3546 if os.readlink(mypython) == sysexecutable:
3554 self._createdfiles.append(mypython) 3547 continue
3548 os.unlink(mypython)
3555 except OSError as err: 3549 except OSError as err:
3556 # child processes may race, which is harmless 3550 if err.errno != errno.ENOENT:
3557 if err.errno != errno.EEXIST:
3558 raise 3551 raise
3552 if self._findprogram(pyexename) != sysexecutable:
3553 try:
3554 os.symlink(sysexecutable, mypython)
3555 self._createdfiles.append(mypython)
3556 except OSError as err:
3557 # child processes may race, which is harmless
3558 if err.errno != errno.EEXIST:
3559 raise
3559 else: 3560 else:
3560 # Windows doesn't have `python3.exe`, and MSYS cannot understand the 3561 # Windows doesn't have `python3.exe`, and MSYS cannot understand the
3561 # reparse point with that name provided by Microsoft. Create a 3562 # reparse point with that name provided by Microsoft. Create a
3562 # simple script on PATH with that name that delegates to the py3 3563 # simple script on PATH with that name that delegates to the py3
3563 # launcher so the shebang lines work. 3564 # launcher so the shebang lines work.