comparison tests/run-tests.py @ 47826:83235fb50e1c stable

run-tests: introduce a --pyoxidized option This options make it possible to use the pyoxidizer version to run the tests. This is a first basic version that is windows only. The test needs a working python, with Mercurial installed. However the pyoxidizer product is "self contains" without a "usable" Python. There have been discussion to have a fully functional `hg admin::python` command providing a fully functional python interpreter, but nothing is of the sort is ready yet. In In the meantime we use an hybrid approach, similar to what we do for testing `rhg`. We install a full "normal" Mercurial, but also the pyxodizer product as the official `hg binary`. That way, we use the pyoxidizer version or everything, but test that needs to run python have it available, with a fully functional Mercurial package. This first version is pretty basic (Windows only, no --local, not --with-pyoxidized), but it runs, various bug that we will have to fix. Differential Revision: https://phab.mercurial-scm.org/D11277
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 10 Aug 2021 12:56:32 +0200
parents 036b9b3cc79a
children 94158c541c74
comparison
equal deleted inserted replaced
47825:f6879956a386 47826:83235fb50e1c
592 hgconf.add_argument( 592 hgconf.add_argument(
593 "--rhg", 593 "--rhg",
594 action="store_true", 594 action="store_true",
595 help="install and use rhg Rust implementation in place of hg", 595 help="install and use rhg Rust implementation in place of hg",
596 ) 596 )
597 hgconf.add_argument(
598 "--pyoxidized",
599 action="store_true",
600 help="build the hg binary using pyoxidizer",
601 )
597 hgconf.add_argument("--compiler", help="compiler to build with") 602 hgconf.add_argument("--compiler", help="compiler to build with")
598 hgconf.add_argument( 603 hgconf.add_argument(
599 '--extra-config-opt', 604 '--extra-config-opt',
600 action="append", 605 action="append",
601 default=[], 606 default=[],
729 if options.local: 734 if options.local:
730 if options.with_hg or options.with_rhg or options.with_chg: 735 if options.with_hg or options.with_rhg or options.with_chg:
731 parser.error( 736 parser.error(
732 '--local cannot be used with --with-hg or --with-rhg or --with-chg' 737 '--local cannot be used with --with-hg or --with-rhg or --with-chg'
733 ) 738 )
739 if options.pyoxidized:
740 parser.error('--pyoxidized does not work with --local (yet)')
734 testdir = os.path.dirname(_sys2bytes(canonpath(sys.argv[0]))) 741 testdir = os.path.dirname(_sys2bytes(canonpath(sys.argv[0])))
735 reporootdir = os.path.dirname(testdir) 742 reporootdir = os.path.dirname(testdir)
736 pathandattrs = [(b'hg', 'with_hg')] 743 pathandattrs = [(b'hg', 'with_hg')]
737 if options.chg: 744 if options.chg:
738 pathandattrs.append((b'contrib/chg/chg', 'with_chg')) 745 pathandattrs.append((b'contrib/chg/chg', 'with_chg'))
762 769
763 if (options.chg or options.with_chg) and WINDOWS: 770 if (options.chg or options.with_chg) and WINDOWS:
764 parser.error('chg does not work on %s' % os.name) 771 parser.error('chg does not work on %s' % os.name)
765 if (options.rhg or options.with_rhg) and WINDOWS: 772 if (options.rhg or options.with_rhg) and WINDOWS:
766 parser.error('rhg does not work on %s' % os.name) 773 parser.error('rhg does not work on %s' % os.name)
774 if options.pyoxidized and not WINDOWS:
775 parser.error('--pyoxidized is currently Windows only')
767 if options.with_chg: 776 if options.with_chg:
768 options.chg = False # no installation to temporary location 777 options.chg = False # no installation to temporary location
769 options.with_chg = canonpath(_sys2bytes(options.with_chg)) 778 options.with_chg = canonpath(_sys2bytes(options.with_chg))
770 if not ( 779 if not (
771 os.path.isfile(options.with_chg) 780 os.path.isfile(options.with_chg)
3221 self._hgcommand = b'rhg' 3230 self._hgcommand = b'rhg'
3222 elif self.options.with_rhg: 3231 elif self.options.with_rhg:
3223 rhgbindir = os.path.dirname(os.path.realpath(self.options.with_rhg)) 3232 rhgbindir = os.path.dirname(os.path.realpath(self.options.with_rhg))
3224 self._hgcommand = os.path.basename(self.options.with_rhg) 3233 self._hgcommand = os.path.basename(self.options.with_rhg)
3225 3234
3235 if self.options.pyoxidized:
3236 testdir = os.path.dirname(_sys2bytes(canonpath(sys.argv[0])))
3237 reporootdir = os.path.dirname(testdir)
3238 # XXX we should ideally install stuff instead of using the local build
3239 bin_path = (
3240 b'build/pyoxidizer/x86_64-pc-windows-msvc/release/app/hg.exe'
3241 )
3242 full_path = os.path.join(reporootdir, bin_path)
3243 self._hgcommand = full_path
3244
3226 osenvironb[b"BINDIR"] = self._bindir 3245 osenvironb[b"BINDIR"] = self._bindir
3227 osenvironb[b"PYTHON"] = PYTHON 3246 osenvironb[b"PYTHON"] = PYTHON
3228 3247
3229 fileb = _sys2bytes(__file__) 3248 fileb = _sys2bytes(__file__)
3230 runtestdir = os.path.abspath(os.path.dirname(fileb)) 3249 runtestdir = os.path.abspath(os.path.dirname(fileb))
3461 assert self._installdir 3480 assert self._installdir
3462 self._installchg() 3481 self._installchg()
3463 if self.options.rhg: 3482 if self.options.rhg:
3464 assert self._installdir 3483 assert self._installdir
3465 self._installrhg() 3484 self._installrhg()
3485 elif self.options.pyoxidized:
3486 self._build_pyoxidized()
3466 self._use_correct_mercurial() 3487 self._use_correct_mercurial()
3467 3488
3468 log( 3489 log(
3469 'running %d tests using %d parallel processes' 3490 'running %d tests using %d parallel processes'
3470 % (num_tests, jobs) 3491 % (num_tests, jobs)
3873 sys.stdout.buffer.write(out) 3894 sys.stdout.buffer.write(out)
3874 else: 3895 else:
3875 sys.stdout.write(out) 3896 sys.stdout.write(out)
3876 sys.exit(1) 3897 sys.exit(1)
3877 3898
3899 def _build_pyoxidized(self):
3900 """build a pyoxidized version of mercurial into the test environment
3901
3902 Ideally this function would be `install_pyoxidier` and would both build
3903 and install pyoxidier. However we are starting small to get pyoxidizer
3904 build binary to testing quickly.
3905 """
3906 vlog('# build a pyoxidized version of Mercurial')
3907 assert os.path.dirname(self._bindir) == self._installdir
3908 assert self._hgroot, 'must be called after _installhg()'
3909 cmd = b'"%(make)s" pyoxidizer' % {
3910 b'make': b'make',
3911 }
3912 cwd = self._hgroot
3913 vlog("# Running", cmd)
3914 proc = subprocess.Popen(
3915 _bytes2sys(cmd),
3916 shell=True,
3917 cwd=_bytes2sys(cwd),
3918 stdin=subprocess.PIPE,
3919 stdout=subprocess.PIPE,
3920 stderr=subprocess.STDOUT,
3921 )
3922 out, _err = proc.communicate()
3923 if proc.returncode != 0:
3924 if PYTHON3:
3925 sys.stdout.buffer.write(out)
3926 else:
3927 sys.stdout.write(out)
3928 sys.exit(1)
3929
3878 def _outputcoverage(self): 3930 def _outputcoverage(self):
3879 """Produce code coverage output.""" 3931 """Produce code coverage output."""
3880 import coverage 3932 import coverage
3881 3933
3882 coverage = coverage.coverage 3934 coverage = coverage.coverage