sapling/tests/pythonpath.py
Jun Wu 2247a2f8df test-cstore: run native Python tests directly
Previously the test sets up `LD_LIBRARY_PATH` and `PYTHONPATH`, then runs
Python tests.

Within Python code, setting `sys.path` would achieve the same effect of
setting `PYTHONPATH`. For `LD_LIBRARY_PATH`, it's necessary for C libraries.
But the only C library that cstore depends on is `lz4`, which is supposed to
use the system version. There is no C library provided by this repo -
features like sha1 are compiled in `cstore.so`.

Therefore it's unnecessary to have a separate `.t` file wrapping `.py`
tests. Let's just use `.py` tests directly.

Test Plan:
`./script/unit.py`

Make a temporary change to `cdatapack.c` so it fails unconditionally in
open_datapack. Build the repo in different ways: `make local` and
`python2 setup.py build_clib build_ext`. Then run the test by using
`$HG_CREW/tests/run-tests.py -l test-remotefilelog-datapack.py` without the
`hg-dev` environment and make sure it fails with the expected exception.

Differential Revision: https://phab.mercurial-scm.org/D1429
2017-11-16 10:56:44 -08:00

22 lines
480 B
Python

from __future__ import absolute_import
import glob
import os
import sys
reporoot = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def globrelative(path):
return glob.glob(os.path.join(reporoot, path))
def setcstorepath():
sys.path[0:0] = (
# make local
[reporoot] +
# python2 setup.py build_ext
globrelative('build/lib*') +
# rpmbuild
globrelative('../rpmbuild/BUILD/fb-mercurial-ext-*/build/lib.*')
)