# HG changeset patch # User Pierre-Yves David # Date 1628592992 -7200 # Node ID 83235fb50e1c85c5c29ab63df7cbe040a7629c56 # Parent f6879956a3863fe3452d05371a61ea4d01d958bc 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 diff -r f6879956a386 -r 83235fb50e1c tests/run-tests.py --- a/tests/run-tests.py Tue Aug 10 11:45:43 2021 +0200 +++ b/tests/run-tests.py Tue Aug 10 12:56:32 2021 +0200 @@ -594,6 +594,11 @@ action="store_true", help="install and use rhg Rust implementation in place of hg", ) + hgconf.add_argument( + "--pyoxidized", + action="store_true", + help="build the hg binary using pyoxidizer", + ) hgconf.add_argument("--compiler", help="compiler to build with") hgconf.add_argument( '--extra-config-opt', @@ -731,6 +736,8 @@ parser.error( '--local cannot be used with --with-hg or --with-rhg or --with-chg' ) + if options.pyoxidized: + parser.error('--pyoxidized does not work with --local (yet)') testdir = os.path.dirname(_sys2bytes(canonpath(sys.argv[0]))) reporootdir = os.path.dirname(testdir) pathandattrs = [(b'hg', 'with_hg')] @@ -764,6 +771,8 @@ parser.error('chg does not work on %s' % os.name) if (options.rhg or options.with_rhg) and WINDOWS: parser.error('rhg does not work on %s' % os.name) + if options.pyoxidized and not WINDOWS: + parser.error('--pyoxidized is currently Windows only') if options.with_chg: options.chg = False # no installation to temporary location options.with_chg = canonpath(_sys2bytes(options.with_chg)) @@ -3223,6 +3232,16 @@ rhgbindir = os.path.dirname(os.path.realpath(self.options.with_rhg)) self._hgcommand = os.path.basename(self.options.with_rhg) + if self.options.pyoxidized: + testdir = os.path.dirname(_sys2bytes(canonpath(sys.argv[0]))) + reporootdir = os.path.dirname(testdir) + # XXX we should ideally install stuff instead of using the local build + bin_path = ( + b'build/pyoxidizer/x86_64-pc-windows-msvc/release/app/hg.exe' + ) + full_path = os.path.join(reporootdir, bin_path) + self._hgcommand = full_path + osenvironb[b"BINDIR"] = self._bindir osenvironb[b"PYTHON"] = PYTHON @@ -3463,6 +3482,8 @@ if self.options.rhg: assert self._installdir self._installrhg() + elif self.options.pyoxidized: + self._build_pyoxidized() self._use_correct_mercurial() log( @@ -3875,6 +3896,37 @@ sys.stdout.write(out) sys.exit(1) + def _build_pyoxidized(self): + """build a pyoxidized version of mercurial into the test environment + + Ideally this function would be `install_pyoxidier` and would both build + and install pyoxidier. However we are starting small to get pyoxidizer + build binary to testing quickly. + """ + vlog('# build a pyoxidized version of Mercurial') + assert os.path.dirname(self._bindir) == self._installdir + assert self._hgroot, 'must be called after _installhg()' + cmd = b'"%(make)s" pyoxidizer' % { + b'make': b'make', + } + cwd = self._hgroot + vlog("# Running", cmd) + proc = subprocess.Popen( + _bytes2sys(cmd), + shell=True, + cwd=_bytes2sys(cwd), + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + ) + out, _err = proc.communicate() + if proc.returncode != 0: + if PYTHON3: + sys.stdout.buffer.write(out) + else: + sys.stdout.write(out) + sys.exit(1) + def _outputcoverage(self): """Produce code coverage output.""" import coverage