Closed
Bug 1472199
Opened 6 years ago
Closed 6 years ago
Set the root directory for Python unit tests to topsrcdir
Categories
(Testing :: Python Test, enhancement)
Tracking
(firefox63 fixed)
RESOLVED
FIXED
mozilla63
Tracking | Status | |
---|---|---|
firefox63 | --- | fixed |
People
(Reporter: davehunt, Assigned: davehunt, Mentored)
References
Details
(Keywords: good-first-bug)
Attachments
(2 files)
Currently the root directory for the tests executed via |mach python-test| is determined using pytest default strategy [1]. This means that it's often the common ancestor of the tests, and as the nodeids is constructed from the root directory, were unable to uniquely identify tests from different parts of the source code. pytest 3.5 introduced a `--rootdir` command line option for overriding the root directory. We should use this to set the root directory to the top of the source tree, so all tests will have an absolute path and unique nodeid. [1] https://docs.pytest.org/en/latest/customize.html#finding-the-rootdir
Comment hidden (mozreview-request) |
Assignee | ||
Updated•6 years ago
|
Assignee: nobody → dave.hunt
Status: NEW → ASSIGNED
Assignee | ||
Comment 2•6 years ago
|
||
You can see the rootdir in the pytest header. Wthout the patch running |mach python-test mozfile| shows a rootdir for me of /Users/dhunt/workspace/firefox/testing/mozbase/mozfile/tests, which means an example test node of test_extract.py::TestExtract::test_extract. With the patch shows a rootdir for me of /Users/dhunt/workspace/firefox, which means the same test node id would be testing/mozbase/mozfile/tests/test_extract.py::TestExtract::test_extract. Note that the standard output from pytest shows the relative path to the test, however the mozlog pytest plugin uses the node ids, so the issue of tests not being uniquely identifiable only applies to any files created by mozlog.
Comment 3•6 years ago
|
||
mozreview-review |
Comment on attachment 8989134 [details] Bug 1472199 - Set the root directory for Python unit tests to topsrcdir; https://reviewboard.mozilla.org/r/254194/#review261308 ::: config/mozunit/mozunit/mozunit.py:22 (Diff revision 1) > +except ImportError: > + import buildconfig > + topsrcdir = buildconfig.topsrcdir This will fail if you don't have a local build of Firefox which is bad because many of the python tests don't need a build. Instead use: from mozbuild.base import MozbuildObject build = MozbuildObject.from_environment(cwd=here) build.topsrcdir I'm not sure if `mozbuild.base` is python 3 compatible or not, but would be worth checking (and if it isn't it would be a good candidate to prioritize).
Attachment #8989134 -
Flags: review?(ahal) → review+
Comment hidden (mozreview-request) |
Assignee | ||
Comment 5•6 years ago
|
||
mozreview-review-reply |
Comment on attachment 8989134 [details] Bug 1472199 - Set the root directory for Python unit tests to topsrcdir; https://reviewboard.mozilla.org/r/254194/#review261308 > This will fail if you don't have a local build of Firefox which is bad because many of the python tests don't need a build. Instead use: > > from mozbuild.base import MozbuildObject > build = MozbuildObject.from_environment(cwd=here) > build.topsrcdir > > I'm not sure if `mozbuild.base` is python 3 compatible or not, but would be worth checking (and if it isn't it would be a good candidate to prioritize). Unfortunately `mozbuild.base` depends on `mach`, which depends on `mozprocess`. I'll raise bugs for adding Python 3 support to mach and mozbase.
Pushed by dhunt@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/530f89f70093 Set the root directory for Python unit tests to topsrcdir; r=ahal
Comment 7•6 years ago
|
||
Backed out for build bustages Push with failures: https://treeherder.mozilla.org/#/jobs?repo=autoland&revision=530f89f7009363d46fd2552078d9dc9d4b2a939e Failure log: https://treeherder.mozilla.org/logviewer.html#?job_id=186562634&repo=autoland&lineNumber=885 Backout: https://hg.mozilla.org/integration/autoland/rev/1fc5a72a842f4581dec2f6c88d309e982facd8c0
Flags: needinfo?(dave.hunt)
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Updated•6 years ago
|
Flags: needinfo?(dave.hunt)
Comment 10•6 years ago
|
||
mozreview-review |
Comment on attachment 8989998 [details] Bug 1472199 - [mozbuild] Remove unittest dependency from test_pythonutil.py and narrow to tests module; https://reviewboard.mozilla.org/r/255020/#review261972 Lgtm!
Attachment #8989998 -
Flags: review?(ahal) → review+
Comment 11•6 years ago
|
||
Pushed by dhunt@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/565f27e6e753 [mozbuild] Remove unittest dependency from test_pythonutil.py and narrow to tests module; r=ahal https://hg.mozilla.org/integration/autoland/rev/9da7f0f1cb6d Set the root directory for Python unit tests to topsrcdir; r=ahal
Comment 12•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/565f27e6e753 https://hg.mozilla.org/mozilla-central/rev/9da7f0f1cb6d
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
status-firefox63:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in
before you can comment on or make changes to this bug.
Description
•