diff --git a/tests/pythonpath.py b/tests/pythonpath.py new file mode 100644 --- /dev/null +++ b/tests/pythonpath.py @@ -0,0 +1,21 @@ +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.*') + ) + diff --git a/tests/test-check-py3-compat-hg.t b/tests/test-check-py3-compat-hg.t --- a/tests/test-check-py3-compat-hg.t +++ b/tests/test-check-py3-compat-hg.t @@ -95,9 +95,6 @@ setup.py not using absolute_import tests/bundlerepologger.py not using absolute_import tests/conduithttp.py not using absolute_import - tests/cstore-datapackstore.py not using absolute_import - tests/cstore-treemanifest.py not using absolute_import - tests/cstore-uniondatapackstore.py not using absolute_import tests/dummyext1.py not using absolute_import tests/dummyext2.py not using absolute_import tests/get-with-headers.py not using absolute_import @@ -110,9 +107,6 @@ tests/ls-l.py requires print_function tests/perftest.py not using absolute_import tests/perftest.py requires print_function - tests/remotefilelog-datapack.py not using absolute_import - tests/remotefilelog-datapack.py requires print_function - tests/remotefilelog-histpack.py not using absolute_import tests/test-absorb-filefixupstate.py not using absolute_import tests/test-extutil.py not using absolute_import tests/test-fastmanifest.py not using absolute_import diff --git a/tests/cstore-datapackstore.py b/tests/test-cstore-datapackstore.py rename from tests/cstore-datapackstore.py rename to tests/test-cstore-datapackstore.py --- a/tests/cstore-datapackstore.py +++ b/tests/test-cstore-datapackstore.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2.7 +from __future__ import absolute_import import hashlib import os @@ -12,8 +13,9 @@ import silenttestrunner # Load the local cstore, not the system one -fullpath = os.path.join(os.getcwd(), __file__) -sys.path.insert(0, os.path.dirname(os.path.dirname(fullpath))) +sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')] +import pythonpath +pythonpath.setcstorepath() from cstore import ( datapackstore, diff --git a/tests/cstore-treemanifest.py b/tests/test-cstore-treemanifest.py rename from tests/cstore-treemanifest.py rename to tests/test-cstore-treemanifest.py --- a/tests/cstore-treemanifest.py +++ b/tests/test-cstore-treemanifest.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2.7 +from __future__ import absolute_import import os import random @@ -8,8 +9,10 @@ import silenttestrunner # Add the repo root to the path so we can find the built ctreemanifest -fullpath = os.path.join(os.getcwd(), __file__) -sys.path.insert(0, os.path.dirname(os.path.dirname(fullpath))) +sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')] +import pythonpath +pythonpath.setcstorepath() + import cstore from mercurial import ( diff --git a/tests/cstore-uniondatapackstore.py b/tests/test-cstore-uniondatapackstore.py rename from tests/cstore-uniondatapackstore.py rename to tests/test-cstore-uniondatapackstore.py --- a/tests/cstore-uniondatapackstore.py +++ b/tests/test-cstore-uniondatapackstore.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2.7 +from __future__ import absolute_import import hashlib import os @@ -11,8 +12,9 @@ import silenttestrunner # Load the local cstore, not the system one -fullpath = os.path.join(os.getcwd(), __file__) -sys.path.insert(0, os.path.dirname(os.path.dirname(fullpath))) +sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')] +import pythonpath +pythonpath.setcstorepath() from cstore import ( datapackstore, diff --git a/tests/test-cstore.t b/tests/test-cstore.t deleted file mode 100644 --- a/tests/test-cstore.t +++ /dev/null @@ -1,21 +0,0 @@ -Get build path for native extensions -- Do this as a separate script so we can eat the ls errors - $ cat >> $TESTTMP/getbuildpath.sh < BUILD_PATH="`ls -d $TESTDIR/`" - > BUILD_PATH="\$BUILD_PATH:`ls -d $TESTDIR/../build/lib* 2> /dev/null`" - > BUILD_PATH="\$BUILD_PATH:`ls -d $TESTDIR/../../rpmbuild/BUILD/fb-mercurial-ext-*/build/lib.*/ 2> /dev/null`" - > echo "\$BUILD_PATH" - > EOF - $ chmod a+x $TESTTMP/getbuildpath.sh - $ BUILD_PATH="`$TESTTMP/getbuildpath.sh`" - - $ LD_LIBRARY_PATH="$BUILD_PATH" - $ export LD_LIBRARY_PATH - $ PYTHONPATH="$BUILD_PATH:$PYTHONPATH" - $ export PYTHONPATH - - $ $PYTHON $TESTDIR/remotefilelog-datapack.py - $ $PYTHON $TESTDIR/remotefilelog-histpack.py - $ $PYTHON $TESTDIR/cstore-datapackstore.py - $ $PYTHON $TESTDIR/cstore-treemanifest.py - $ $PYTHON $TESTDIR/cstore-uniondatapackstore.py diff --git a/tests/remotefilelog-datapack.py b/tests/test-remotefilelog-datapack.py old mode 100755 new mode 100644 rename from tests/remotefilelog-datapack.py rename to tests/test-remotefilelog-datapack.py --- a/tests/remotefilelog-datapack.py +++ b/tests/test-remotefilelog-datapack.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import absolute_import, print_function + import hashlib import os import random @@ -14,6 +16,8 @@ # Load the local remotefilelog, not the system one sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')] +import pythonpath +pythonpath.setcstorepath() from remotefilelog.datapack import ( datapack, @@ -316,7 +320,7 @@ # perf test off by default since it's slow def _testIndexPerf(self): random.seed(0) - print "Multi-get perf test" + print("Multi-get perf test") packsizes = [ 100, 10000, @@ -361,7 +365,7 @@ ('%s' % lookupsize).rjust(7), elapsed)) - print "" + print("") gc.enable() # The perf test is meant to produce output, so we always fail the test diff --git a/tests/remotefilelog-histpack.py b/tests/test-remotefilelog-histpack.py rename from tests/remotefilelog-histpack.py rename to tests/test-remotefilelog-histpack.py --- a/tests/remotefilelog-histpack.py +++ b/tests/test-remotefilelog-histpack.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import absolute_import + import hashlib import os import random @@ -13,6 +15,9 @@ # Load the local remotefilelog, not the system one sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')] +import pythonpath +pythonpath.setcstorepath() + from remotefilelog.historypack import historypack, mutablehistorypack from mercurial.node import nullid