Repository navigation
_testing/_sourcetests/utils.py: Make the copied test project writable - #2221
Open
Thanatos9404 wants to merge 2 commits into
Open
Thanatos9404 wants to merge 2 commits into
Thanatos9404 wants to merge 2 commits into
Conversation
The shared source tests write into the copy of their project which the `datafiles` fixture makes, starting with the project.conf that the `kind` fixture updates. Since pytest-datafiles 3.0 that copy keeps the permissions of the installed files, so when buildstream is installed read-only, as in the Nix store, every test using `kind` fails with a PermissionError. Make the copy writable by its owner in the `kind` fixture, before anything is written into it. Fixes apache#2196
Check that the shared source tests can write into a copy of their project whose files and directories are read-only. This is a part of apache#2196
Thanatos9404
requested review from
BenjaminSchubert,
abderrahim,
cs-shadow,
gtristan and
juergbi
as code owners
November 11, 2026 21:30
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since pytest-datafiles 3.0, the
datafilescopy keeps the permissions of the files it copies. When buildstream is installed read-only, as in the Nix store from the issue, the shared source tests then fail with a PermissionError as soon as thekindfixture writes project.conf into the copy.The
kindfixture now makes the copy writable by its owner before writing anything into it. Directories also get read and search permission, so that the whole tree can be walked. Symlinks are left alone. Every test in_testing/_sourceteststhat usesdatafilestakeskind, and the later writes (elements, repositories, junctions) all go into that same copy, so this covers them.I added a test in tests/internals/sourcetests_utils.py. It copies the shared test project, makes it read-only, and checks that project.conf can be updated and that a new element can be written after
make_writable(). It is skipped as root, like the other permission tests. I also ran the full test suite, which includes the shared source tests throughkind, plus black and pylint, locally.Fixes #2196