2016-04-08 21:46:18 +03:00
|
|
|
import os
|
2016-05-27 03:04:23 +03:00
|
|
|
import time
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
import silenttestrunner
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial import error, manifest, ui, util, vfs as vfsmod
|
2016-04-08 21:46:18 +03:00
|
|
|
|
|
|
|
|
2016-06-22 03:07:46 +03:00
|
|
|
class mockmanifest(object):
|
|
|
|
def __init__(self, text):
|
|
|
|
self.text = text
|
|
|
|
|
|
|
|
def copy(self):
|
|
|
|
return mockmanifest(self.text)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-06-22 03:07:46 +03:00
|
|
|
class mockondiskcache(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.data = {}
|
|
|
|
|
|
|
|
def _pathfromnode(self, hexnode):
|
|
|
|
return hexnode
|
|
|
|
|
|
|
|
def touch(self, hexnode, delay=0):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def __contains__(self, hexnode):
|
|
|
|
return hexnode in self.data
|
|
|
|
|
|
|
|
def items(self):
|
|
|
|
return self.data.keys()
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return iter(self.items())
|
|
|
|
|
|
|
|
def __setitem__(self, hexnode, manifest):
|
|
|
|
self.data[hexnode] = manifest
|
|
|
|
|
|
|
|
def __delitem__(self, hexnode):
|
|
|
|
if hexnode in self.data:
|
|
|
|
del self.data[hexnode]
|
|
|
|
|
|
|
|
def __getitem__(self, hexnode):
|
|
|
|
return self.data.get(hexnode, None)
|
|
|
|
|
|
|
|
def entrysize(self, hexnode):
|
|
|
|
return len(self.data[hexnode]) if hexnode in self.data else None
|
|
|
|
|
|
|
|
def totalsize(self, silent=True):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
return (sum(self.entrysize(hexnode) for hexnode in self), len(self.items()))
|
|
|
|
|
2016-06-22 03:07:46 +03:00
|
|
|
|
2016-04-08 21:46:18 +03:00
|
|
|
class HybridManifest(unittest.TestCase):
|
2016-05-25 23:23:19 +03:00
|
|
|
def test_wrap(self):
|
|
|
|
"""If a new magic method is added to manifestdict, we want to make sure
|
|
|
|
that hybridmanifest implement it, this test validates that all magic
|
|
|
|
methods of manifestdict are implemented by hybridmanifest to avoid
|
|
|
|
breakage in prod
|
2016-04-08 21:46:18 +03:00
|
|
|
|
2016-05-25 23:23:19 +03:00
|
|
|
"""
|
2017-04-19 00:42:33 +03:00
|
|
|
vfs = vfsmod.vfs(os.getcwd())
|
2017-10-24 06:13:13 +03:00
|
|
|
tempui = ui.ui()
|
|
|
|
tempui.setconfig("fastmanifest", "usecache", True)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
hd = fastmanifest.implementation.hybridmanifest(tempui, vfs, None, fast=True)
|
2016-05-25 23:23:19 +03:00
|
|
|
ismagic = lambda x: x.startswith("__") and x.endswith("__")
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
magicmethods = [
|
|
|
|
k
|
|
|
|
for k, v in manifest.manifestdict.__dict__.items()
|
|
|
|
if util.safehasattr(v, "__call__") and ismagic(k)
|
|
|
|
]
|
2016-05-25 23:23:19 +03:00
|
|
|
for method in magicmethods:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
assert util.safehasattr(hd, method), (
|
|
|
|
"%s missing in hybrid manifest" % method
|
|
|
|
)
|
2016-05-25 23:23:19 +03:00
|
|
|
|
|
|
|
def test_cachelimit(self):
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.hgext.fastmanifest.cachemanager import _systemawarecachelimit
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-05-27 03:05:01 +03:00
|
|
|
cachealloc = _systemawarecachelimit.cacheallocation
|
|
|
|
GB = fastmanifest.cachemanager.GB
|
|
|
|
MB = fastmanifest.cachemanager.MB
|
2016-05-25 23:23:19 +03:00
|
|
|
assert cachealloc(0) == 0
|
|
|
|
assert cachealloc(120 * GB) == 6 * GB
|
|
|
|
assert abs(cachealloc(28 * GB) - 5.6 * GB) < 5 * MB
|
2016-05-23 21:52:42 +03:00
|
|
|
|
2016-05-27 03:04:23 +03:00
|
|
|
def test_looselock_basic(self):
|
|
|
|
"""Attempt to secure two locks. The second one should fail."""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
vfs = vfsmod.vfs("")
|
2016-05-27 03:04:23 +03:00
|
|
|
with fastmanifest.concurrency.looselock(vfs, "lock") as l1:
|
|
|
|
assert l1.held()
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
vfs2 = vfsmod.vfs("")
|
2016-05-27 03:04:23 +03:00
|
|
|
try:
|
|
|
|
with fastmanifest.concurrency.looselock(vfs2, "lock") as l2:
|
|
|
|
assert l2.held()
|
|
|
|
|
|
|
|
except error.LockHeld:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
self.fail("two locks both succeeded.")
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
self.assertRaises(OSError, lambda: vfs.lstat("lock"))
|
2016-05-27 03:04:23 +03:00
|
|
|
|
2016-06-22 03:07:46 +03:00
|
|
|
def test_cachehierarchy(self):
|
|
|
|
"""We mock the ondisk cache and test that the two layers of cache
|
|
|
|
work properly"""
|
2017-04-19 00:42:33 +03:00
|
|
|
vfs = vfsmod.vfs(os.getcwd())
|
2017-10-24 06:13:13 +03:00
|
|
|
tempui = ui.ui()
|
|
|
|
tempui.setconfig("fastmanifest", "usecache", True)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
cache = fastmanifest.implementation.fastmanifestcache(vfs, tempui, None)
|
2016-06-22 03:07:46 +03:00
|
|
|
ondiskcache = mockondiskcache()
|
|
|
|
cache.ondiskcache = ondiskcache
|
|
|
|
# Test 1) Put one manifest in the cache, check that retrieving it does
|
|
|
|
# not hit the disk
|
|
|
|
cache["abc"] = mockmanifest("abcnode")
|
|
|
|
# remove the ondiskcache to make sure we don't hit it
|
|
|
|
cache.ondiskcache = None
|
|
|
|
assert cache["abc"].text == "abcnode"
|
|
|
|
assert ondiskcache.data["abc"].text == "abcnode"
|
|
|
|
cache.ondiskcache = ondiskcache
|
|
|
|
|
|
|
|
# Test 2) Put an entry in the cache that is already in memory but not
|
|
|
|
# on disk, should write it on disk
|
|
|
|
ondiskcache.data.clear()
|
|
|
|
cache["abc"] = mockmanifest("abcnode")
|
|
|
|
assert ondiskcache.data["abc"].text == "abcnode"
|
|
|
|
|
|
|
|
# Test 3) Put an entry in the cache that is already on disk, not in
|
|
|
|
# memory, it should be added to the inmemorycache
|
|
|
|
cache.inmemorycache.clear()
|
|
|
|
cache["abc"] = mockmanifest("abcnode")
|
|
|
|
assert cache.inmemorycache["abc"].text == "abcnode"
|
|
|
|
|
|
|
|
# Test 4) We have at most 10 entries in the in memorycache by
|
|
|
|
# default
|
|
|
|
for a in range(20):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
cache[chr(a + ord("a"))] = mockmanifest(chr(a + ord("a")) + "node")
|
2016-06-22 03:07:46 +03:00
|
|
|
|
|
|
|
assert len(cache.ondiskcache.items()) == 21
|
|
|
|
assert len(cache.inmemorycache) == 10
|
|
|
|
|
2016-05-27 03:04:23 +03:00
|
|
|
def test_looselock_stealing(self):
|
|
|
|
"""Attempt to secure three locks. The second lock should succeed
|
|
|
|
through a steal. The third lock should fail because the second lock
|
|
|
|
should have refreshed the lock.
|
|
|
|
|
|
|
|
Finally, verify that the locks are properly cleaned up.
|
|
|
|
"""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
vfs = vfsmod.vfs("")
|
2016-05-27 03:04:23 +03:00
|
|
|
with fastmanifest.concurrency.looselock(vfs, "lock") as l1:
|
|
|
|
assert l1.held()
|
|
|
|
|
|
|
|
# locks are implemented as symlinks, and we can't utime those, so we
|
|
|
|
# have to wait.........
|
|
|
|
time.sleep(2)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
vfs2 = vfsmod.vfs("")
|
2016-05-27 03:04:23 +03:00
|
|
|
with fastmanifest.concurrency.looselock(vfs2, "lock", 0.2) as l2:
|
|
|
|
assert l2.held()
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
vfs3 = vfsmod.vfs("")
|
2016-05-27 03:04:23 +03:00
|
|
|
try:
|
|
|
|
with fastmanifest.concurrency.looselock(vfs3, "lock") as l3:
|
|
|
|
assert l3.held()
|
|
|
|
except error.LockHeld:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
self.fail("third lock shouldn't be able to steal.")
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
self.assertRaises(OSError, lambda: vfs.lstat("lock"))
|
|
|
|
|
2016-05-27 03:04:23 +03:00
|
|
|
|
2016-04-08 21:46:18 +03:00
|
|
|
if __name__ == "__main__":
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.hgext import fastmanifest
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-04-08 21:46:18 +03:00
|
|
|
silenttestrunner.main(__name__)
|