WIP debug prints
This commit is contained in:
parent
a1bc348603
commit
d85eb38be1
|
@ -146,19 +146,33 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder, importlib.abc.Loader)
|
||||||
# atomic. POSIX's atomic rename comes in handy.
|
# atomic. POSIX's atomic rename comes in handy.
|
||||||
write = not sys.dont_write_bytecode
|
write = not sys.dont_write_bytecode
|
||||||
cache_dir = get_cache_dir(fn)
|
cache_dir = get_cache_dir(fn)
|
||||||
|
track_debug = getattr(sys, "TRACK_REWRITE", False)
|
||||||
|
if track_debug:
|
||||||
|
print("exec_module:")
|
||||||
|
print(f" cache_dir: {cache_dir}")
|
||||||
|
print(f" write (dont_write_bytecode): {write}")
|
||||||
if write:
|
if write:
|
||||||
ok = try_makedirs(cache_dir)
|
ok = try_makedirs(cache_dir)
|
||||||
if not ok:
|
if not ok:
|
||||||
write = False
|
write = False
|
||||||
|
if track_debug:
|
||||||
|
print(f" write: {write} (read-only dir!)")
|
||||||
state.trace(f"read only directory: {cache_dir}")
|
state.trace(f"read only directory: {cache_dir}")
|
||||||
|
|
||||||
|
if track_debug:
|
||||||
|
print(f" write (final): {write}")
|
||||||
cache_name = fn.name[:-3] + PYC_TAIL
|
cache_name = fn.name[:-3] + PYC_TAIL
|
||||||
pyc = cache_dir / cache_name
|
pyc = cache_dir / cache_name
|
||||||
# Notice that even if we're in a read-only directory, I'm going
|
# Notice that even if we're in a read-only directory, I'm going
|
||||||
# to check for a cached pyc. This may not be optimal...
|
# to check for a cached pyc. This may not be optimal...
|
||||||
co = _read_pyc(fn, pyc, state.trace)
|
co = _read_pyc(fn, pyc, state.trace)
|
||||||
|
if track_debug:
|
||||||
|
print(f" co = {co}")
|
||||||
if co is None:
|
if co is None:
|
||||||
state.trace(f"rewriting {fn!r}")
|
state.trace(f"rewriting {fn!r}")
|
||||||
|
if track_debug:
|
||||||
|
print(f" rewriting {fn!r} to:")
|
||||||
|
print(f" {pyc}")
|
||||||
source_stat, co = _rewrite_test(fn, self.config)
|
source_stat, co = _rewrite_test(fn, self.config)
|
||||||
if write:
|
if write:
|
||||||
self._writing_pyc = True
|
self._writing_pyc = True
|
||||||
|
|
|
@ -1737,6 +1737,7 @@ class TestPyCacheDir:
|
||||||
pycache_prefix = tmp_path / "my/pycs"
|
pycache_prefix = tmp_path / "my/pycs"
|
||||||
monkeypatch.setattr(sys, "pycache_prefix", os.fspath(pycache_prefix))
|
monkeypatch.setattr(sys, "pycache_prefix", os.fspath(pycache_prefix))
|
||||||
monkeypatch.setattr(sys, "dont_write_bytecode", False)
|
monkeypatch.setattr(sys, "dont_write_bytecode", False)
|
||||||
|
monkeypatch.setattr(sys, "TRACK_REWRITE", True, raising=False)
|
||||||
|
|
||||||
pytester.makepyfile(
|
pytester.makepyfile(
|
||||||
**{
|
**{
|
||||||
|
@ -1748,7 +1749,7 @@ class TestPyCacheDir:
|
||||||
"src/bar/__init__.py": "",
|
"src/bar/__init__.py": "",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
result = pytester.runpytest()
|
result = pytester.runpytest_inprocess("-s")
|
||||||
pprint.pprint(list(tmp_path.glob("**/*.*")))
|
pprint.pprint(list(tmp_path.glob("**/*.*")))
|
||||||
|
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
|
|
Loading…
Reference in New Issue