Skip to content

Keep symbolic links in the working directory of tests - #70

Open
TManhente wants to merge 2 commits into
python-cmake:mainfrom
TManhente:preserve-symlinked-working-directory
Open

TManhente wants to merge 2 commits into
python-cmake:mainfrom
TManhente:preserve-symlinked-working-directory

Conversation

@TManhente

Copy link
Copy Markdown

Fixes #69.

pytest_discover_tests resolved WORKING_DIRECTORY at configure time, so tests always ran from the real path, even when a symbolic link was given. A build tree configured through a link could not run its tests once the link targeted another location.

Changes

  • FindPytest.cmake: WORKING_DIRECTORY is made absolute (ABSOLUTE) instead of resolved (REALPATH). This is the value stored in the tests' WORKING_DIRECTORY property.
  • PytestAddTests.cmake: test collection resolves the path at build time and uses it for both --rootdir and the collection directory, keeping the 0.5.2 fix for Incorrect confcutdir inferred when rootdir is under a symlink directory pytest-dev/pytest#12291.
  • test/07-working-directory: also discovers and runs tests through a link to the test directory, and checks their WORKING_DIRECTORY property. The link is a junction on Windows, as it does not require elevated privileges. To share the property check, check_test_property.cmake moved from test/05-properties to test/utils.

Bundled tests are unchanged, as they are not collected.

Allow other tests to check the properties of discovered tests.
The working directory was resolved at configuration time, so the tests
ran from the real path even when a symbolic link was given. A build tree
configured through a link could not run its tests once the link targeted
another location.

The working directory is now only made absolute. Test collection still
resolves it, as Pytest resolves symbolic links in the invocation
directory but not in 'rootdir' (pytest-dev/pytest#12291).

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.

pytest_discover_tests resolves symbolic links used in CMake targets WORKING_DIRECTORY

1 participant