Skip to content

_testing/_sourcetests/utils.py: Make the copied test project writable - #2221

Open
Thanatos9404 wants to merge 2 commits into
apache:masterfrom
Thanatos9404:thanatos/sourcetests-read-only-datafiles
Open

Thanatos9404 wants to merge 2 commits into
apache:masterfrom
Thanatos9404:thanatos/sourcetests-read-only-datafiles

Conversation

@Thanatos9404

Copy link
Copy Markdown
Contributor

Since pytest-datafiles 3.0, the datafiles copy 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 the kind fixture writes project.conf into the copy.

The kind fixture 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/_sourcetests that uses datafiles takes kind, 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 through kind, plus black and pylint, locally.

Fixes #2196

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_testing._sourcetests: shared repo-kind tests assume the datafiles fixture copy is writable, which breaks when package data is installed read-only

1 participant