-
-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a private
_PEX_FILE_LOCK_STYLE
knob. (#1962)
This allows experimenting with making all Pex file locks use BSD style locks to help debug file locking issues. This environment variable knob can be removed at any time Pex sees fit.
- Loading branch information
Showing
2 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from pex.atomic_directory import FileLockStyle, _is_bsd_lock | ||
from pex.testing import environment_as | ||
|
||
|
||
def test_is_bsd_lock(): | ||
# type: () -> None | ||
|
||
assert not _is_bsd_lock( | ||
lock_style=None | ||
), "Expected the default lock style to be POSIX for maximum compatibility." | ||
assert not _is_bsd_lock(lock_style=FileLockStyle.POSIX) | ||
assert _is_bsd_lock(lock_style=FileLockStyle.BSD) | ||
|
||
# The hard-coded default is already POSIX, so setting the env var default changes nothing. | ||
with environment_as(_PEX_FILE_LOCK_STYLE="posix"): | ||
assert not _is_bsd_lock(lock_style=None) | ||
assert not _is_bsd_lock(lock_style=FileLockStyle.POSIX) | ||
assert _is_bsd_lock(lock_style=FileLockStyle.BSD) | ||
|
||
with environment_as(_PEX_FILE_LOCK_STYLE="bsd"): | ||
assert _is_bsd_lock( | ||
lock_style=None | ||
), "Expected the default lock style to be taken from the environment when defined." | ||
assert not _is_bsd_lock(lock_style=FileLockStyle.POSIX) | ||
assert _is_bsd_lock(lock_style=FileLockStyle.BSD) |