Include reason in cache path warnings to aid debugging (#11005)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
This commit is contained in:
parent
6041511fb4
commit
c8641f879f
|
@ -0,0 +1 @@
|
||||||
|
Added underlying exception to cache provider path creation and write warning messages.
|
|
@ -179,16 +179,22 @@ class Cache:
|
||||||
else:
|
else:
|
||||||
cache_dir_exists_already = self._cachedir.exists()
|
cache_dir_exists_already = self._cachedir.exists()
|
||||||
path.parent.mkdir(exist_ok=True, parents=True)
|
path.parent.mkdir(exist_ok=True, parents=True)
|
||||||
except OSError:
|
except OSError as exc:
|
||||||
self.warn("could not create cache path {path}", path=path, _ispytest=True)
|
self.warn(
|
||||||
|
f"could not create cache path {path}: {exc}",
|
||||||
|
_ispytest=True,
|
||||||
|
)
|
||||||
return
|
return
|
||||||
if not cache_dir_exists_already:
|
if not cache_dir_exists_already:
|
||||||
self._ensure_supporting_files()
|
self._ensure_supporting_files()
|
||||||
data = json.dumps(value, ensure_ascii=False, indent=2)
|
data = json.dumps(value, ensure_ascii=False, indent=2)
|
||||||
try:
|
try:
|
||||||
f = path.open("w", encoding="UTF-8")
|
f = path.open("w", encoding="UTF-8")
|
||||||
except OSError:
|
except OSError as exc:
|
||||||
self.warn("cache could not write path {path}", path=path, _ispytest=True)
|
self.warn(
|
||||||
|
f"cache could not write path {path}: {exc}",
|
||||||
|
_ispytest=True,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
with f:
|
with f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
|
@ -87,7 +87,7 @@ class TestNewAPI:
|
||||||
"*= warnings summary =*",
|
"*= warnings summary =*",
|
||||||
"*/cacheprovider.py:*",
|
"*/cacheprovider.py:*",
|
||||||
" */cacheprovider.py:*: PytestCacheWarning: could not create cache path "
|
" */cacheprovider.py:*: PytestCacheWarning: could not create cache path "
|
||||||
f"{unwritable_cache_dir}/v/cache/nodeids",
|
f"{unwritable_cache_dir}/v/cache/nodeids: *",
|
||||||
' config.cache.set("cache/nodeids", sorted(self.cached_nodeids))',
|
' config.cache.set("cache/nodeids", sorted(self.cached_nodeids))',
|
||||||
"*1 failed, 3 warnings in*",
|
"*1 failed, 3 warnings in*",
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue