mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 14:58:03 +03:00
92f6f35e7a
Summary: This diff marks **ALL** mercurial tests requiring Python 2 feature. After you fixes some tests, simply remove the `py2` feature requirement and that tests will be continuously run after your diff is landed. To bypass this feature requirement, run the tests command with `HGTEST_FORCE_PY2=1`. For example: ``` HGTEST_FORCE_PY2=1 buck test //eden/scm/tests:hg_run_tests ``` or ``` HGTEST_FORCE_PY2=1 python run-tests.py ``` ---- Basically this diff are created with the following commands: ``` $ sed -i 's/import feature\(.*\)$/import feature\1\n\nfeature.require(["py2"])/' test-*-t.py $ sed -i '1s/^/#require py2\n/' test-*.t $ ls | grep -P "^test.*(?<\!-t)\.py$" > list && vim -p $(cat list) # manually adding feature requires for these Python tests. ``` (Note: this ignores all push blocking failures!) ignore-conflict-markers Reviewed By: singhsrb Differential Revision: D19655148 fbshipit-source-id: 985e3ccb4010cc559049f1d89f8909bc2d9b5e20
90 lines
2.8 KiB
Python
90 lines
2.8 KiB
Python
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
from __future__ import absolute_import
|
|
|
|
from testutil.dott import feature, sh, testtmp # noqa: F401
|
|
|
|
|
|
feature.require(["py2"])
|
|
|
|
|
|
sh % ". '$TESTDIR/hgsql/library.sh'"
|
|
sh % "initdb"
|
|
sh % "setconfig 'extensions.treemanifest=!'"
|
|
|
|
# Populate the db with an initial commit
|
|
|
|
sh % "initclient client"
|
|
sh % "cd client"
|
|
sh % "echo x" > "x"
|
|
sh % "hg commit -qAm x"
|
|
sh % "cd .."
|
|
|
|
sh % "initserver master masterrepo"
|
|
|
|
sh % "cat" << r"""
|
|
from edenscm.mercurial import extensions
|
|
from edenscm.mercurial import ui as uimod
|
|
def uisetup(ui):
|
|
extensions.wrapfunction(uimod.ui, 'log', mylog)
|
|
def mylog(orig, self, service, *msg, **opts):
|
|
if service in ['sqllock']:
|
|
kwstr = ", ".join("%s=%s" % (k, v) for k, v in
|
|
sorted(opts.iteritems()))
|
|
msgstr = msg[0] % msg[1:]
|
|
self.warn('%s: %s (%s)\n' % (service, msgstr, kwstr))
|
|
return orig(self, service, *msg, **opts)
|
|
""" >> "$TESTTMP/uilog.py"
|
|
sh % "cat" << r"""
|
|
[extensions]
|
|
uilog=$TESTTMP/uilog.py
|
|
""" >> "master/.hg/hgrc"
|
|
|
|
# Verify timeouts are logged
|
|
sh % "cat" << r"""
|
|
from edenscm.mercurial import error, extensions
|
|
def uisetup(ui):
|
|
hgsql = extensions.find('hgsql')
|
|
extensions.wrapfunction(hgsql.sqlcontext, '__enter__', fakeenter)
|
|
def fakeenter(orig, self):
|
|
if self.dbwritable:
|
|
extensions.wrapfunction(self.repo.__class__, '_sqllock', lockthrow)
|
|
return orig(self)
|
|
def lockthrow(*args, **kwargs):
|
|
raise error.Abort("fake timeout")
|
|
""" >> "$TESTTMP/forcetimeout.py"
|
|
|
|
sh % "cp master/.hg/hgrc $TESTTMP/orighgrc"
|
|
sh % "cat" << r"""
|
|
[extensions]
|
|
forcetimeout=$TESTTMP/forcetimeout.py
|
|
""" >> "master/.hg/hgrc"
|
|
sh % "cd client"
|
|
sh % "hg push 'ssh://user@dummy/master'" == r"""
|
|
pushing to ssh://user@dummy/master
|
|
searching for changes
|
|
remote: sqllock: failed to get sql lock after * seconds (glob)
|
|
remote: (elapsed=*, repository=$TESTTMP/master, success=false, valuetype=lockwait) (glob)
|
|
remote: abort: fake timeout
|
|
abort: not a Mercurial bundle
|
|
[255]"""
|
|
sh % "cd .."
|
|
sh % "cp $TESTTMP/orighgrc master/.hg/hgrc"
|
|
|
|
# Verify sqllock times are logged
|
|
sh % "cd client"
|
|
sh % "hg push 'ssh://user@dummy/master'" == r"""
|
|
pushing to ssh://user@dummy/master
|
|
searching for changes
|
|
remote: sqllock: waited for sql lock for * seconds (read 1 rows) (glob)
|
|
remote: (elapsed=*, repository=$TESTTMP/master, success=true, valuetype=lockwait) (glob)
|
|
remote: adding changesets
|
|
remote: adding manifests
|
|
remote: adding file changes
|
|
remote: added 1 changesets with 1 changes to 1 files
|
|
remote: sqllock: held sql lock for * seconds (read 5 rows; write 5 rows) (glob)
|
|
remote: (elapsed=*, readrows=5, repository=$TESTTMP/master, valuetype=lockheld, writerows=5) (glob)"""
|