-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config: fallback confcutdir to rootpath if inipath is not set #11043
Conversation
2765d8b
to
1eb1eb4
Compare
changelog/11043.improvement.rst
Outdated
@@ -0,0 +1,3 @@ | |||
In cases when `--confcutdir` is not specified, and there is no config file present, the conftest cutoff directory (confcutdir) is now set to the :ref:`rootdir`. | |||
Previously in such cases, conftest.py files will be probed all the way to the root directory of the filesystem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously in such cases, conftest.py files will be probed all the way to the root directory of the filesystem. | |
Previously in such cases, `conftest.py` files would be probed all the way to the root directory of the filesystem. |
changelog/11043.improvement.rst
Outdated
@@ -0,0 +1,3 @@ | |||
In cases when `--confcutdir` is not specified, and there is no config file present, the conftest cutoff directory (confcutdir) is now set to the :ref:`rootdir`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In cases when `--confcutdir` is not specified, and there is no config file present, the conftest cutoff directory (confcutdir) is now set to the :ref:`rootdir`. | |
In cases when `--confcutdir` is not specified, and there is no config file present, the conftest cutoff directory (`--confcutdir`) is now set to the :ref:`rootdir`. |
if self.inipath is not None: | ||
confcutdir = str(self.inipath.parent) | ||
else: | ||
confcutdir = str(self.rootpath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have a more specific test for this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added!
Currently, if `--confcutdir` is not set, `inipath.parent` is used, and if `initpath` is not set, then `confcutdir` is None, which means there is no cutoff. Having no cutoff is not great, it means we potentially start probing stuff all the way up to the filesystem root directory. So let's add another fallback, to `rootpath`, which is always something reasonable.
1eb1eb4
to
4a1bba2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @nicoddemus, I applied your suggestions.
if self.inipath is not None: | ||
confcutdir = str(self.inipath.parent) | ||
else: | ||
confcutdir = str(self.rootpath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added!
In pytest 7.4.0, there were some changes to how the configuration file for pytest is located. In our case, this resulted in a failure to find the conftest.py with the needed fixtures which then prevented our python tests from being executed successfully. Configure the --confcutdir to ensure it points to the system test directory, where our conftest.py is located. Related pytest-dev/pytest#11043
As of pytest 7.4 it no longer walks all the way to the root directory of the file system to find conftest files. As a result we don't find / usr/tests/conftest.py, and don't load atf_python. That in turn causes atf_python tests to fail. Explicitly set the confcutdir, as advised by the pytest changelog. See also: pytest-dev/pytest#11043 MFC after: 3 weeks Sponsored by: Orange Business Services Differential Revision: https://reviews.freebsd.org/D41064
As of pytest 7.4 it no longer walks all the way to the root directory of the file system to find conftest files. As a result we don't find / usr/tests/conftest.py, and don't load atf_python. That in turn causes atf_python tests to fail. Explicitly set the confcutdir, as advised by the pytest changelog. See also: pytest-dev/pytest#11043 MFC after: 3 weeks Sponsored by: Orange Business Services Differential Revision: https://reviews.freebsd.org/D41064 (cherry picked from commit 9f23cbd)
As of pytest 7.4 it no longer walks all the way to the root directory of the file system to find conftest files. As a result we don't find / usr/tests/conftest.py, and don't load atf_python. That in turn causes atf_python tests to fail. Explicitly set the confcutdir, as advised by the pytest changelog. See also: pytest-dev/pytest#11043 MFC after: 3 weeks Sponsored by: Orange Business Services Differential Revision: https://reviews.freebsd.org/D41064
Currently, if
--confcutdir
is not set,inipath.parent
is used, and ifinitpath
is not set, thenconfcutdir
is None, which means there is no cutoff.Having no cutoff is not great, it means we potentially start probing stuff all the way up to the filesystem root directory. So let's add another fallback, to
rootpath
, which is always something reasonable.