Investigate why `PathUtils.getTempDir()` can fail in tests
Categories
(Toolkit Graveyard :: OS.File, defect, P2)
Tracking
(firefox98 fixed)
Tracking | Status | |
---|---|---|
firefox98 | --- | fixed |
People
(Reporter: standard8, Assigned: beth)
References
Details
Attachments
(1 file)
In working on bug 1733540, we initially tried using await PathUtils.getTempDir()
for getting the temp directory:
https://phabricator.services.mozilla.com/D128168#inline-710625
That failed in test_system_update_custom.js with the call being rejected with NS_ERROR_FAILURE
.
Using Services.dirsvc.get("TmpD", Ci.nsIFile).path
the test worked fine.
Assignee | ||
Comment 1•3 years ago
|
||
PathUtils.getTempDir can fail in tests only if there is no profile directory. When we ask for the temp dir, PathUtils will eagerly fetch TmpD, ProfD, and ProfLD from the directory service. If any of the fetches fail, we end up returning an error.
Assignee | ||
Comment 2•3 years ago
|
||
It is also failing because getTempDir()
returns NS_APP_CONTENT_PROCESS_TEMP_DIR, which will be "ContentTmpD"
instead of "TmpD"
in tests.
Updated•3 years ago
|
Comment 3•3 years ago
|
||
The severity field is not set for this bug.
:barret, could you have a look please?
For more information, please visit auto_nag documentation.
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 4•3 years ago
|
||
PathUtils.getTempDir() was failing in xpcshell tests for two reasons:
- It was requesting NS_APP_CONTENT_PROCESS_TEMP_DIR, which resolves to
ContentTmpD
, which the directory provider did not have an entry for. - By default, XPC shell tests do not have a profile set up, so when we request
the temporary directory and eagerly fetch the profile directory, we would fail.
We now only fetch the entry for the single directory that is requested to work
around these edge cases in tests and getTempDir()
resolves to TmpD
instead.
We now provide a getContentTempDir()
method on PathUtils for consumers that
want the old behaviour.
To accomplish this, we now have PathUtils.dirs.h
, which defines the various
directory entries that we want to cache and PathUtils now generates code via
macros to implement the relevant methods. This allows us to add additional
directories to PathUtils by adding an entry to PathUtils.dirs.h
and a
matching method in PathUtils.webidl
.
Comment 6•3 years ago
|
||
Backed out changeset 9743e5209921 (bug 1745427) for causing mochitest failures in dom/system/tests/test_pathutils.html
Backout link: https://hg.mozilla.org/integration/autoland/rev/1533aeb19090150db14738d3eae2d9adb06a287b
TEST-UNEXPECTED-FAIL | dom/system/tests/test_pathutils.html | [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIProperties.get]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://mochitests/content/chrome/dom/system/tests/test_pathutils.html :: test_getDirectories :: line 414" data: no] - Should not throw any errors
[task 2022-01-22T01:53:48.805Z] 01:53:48 test_getDirectories@chrome://mochitests/content/chrome/dom/system/tests/test_pathutils.html:414:23
Assignee | ||
Updated•3 years ago
|
Comment 8•3 years ago
|
||
bugherder |
Updated•1 year ago
|
Description
•