fix: resolve the pipeline output dir once

Every step runs from the repository root, but the lock and the purge of
stale packs read --output-dir from the caller's directory. Started from
scripts/, the run locked and purged scripts/dist/ and wrote to dist/,
leaving the stale packs there. The directory is now made absolute before
the lock, dist/ at the root by default.
This commit is contained in:
Abdessamad Derraz committed 2026-10-21 05:24:25 +02:00
1 parent 4fa598645e
commit 0457bd8f40
2 files changed
+36 -1

No files matched your search

+20
View File
@@ -5975,5 +5975,25 @@ class ErrorsGoToStderr(unittest.TestCase):
self.assertGreater(seen, 0, script)
class PipelineOutputDirIsTheOneItWrites(unittest.TestCase):
"""Started from scripts/, the pipeline locked and purged scripts/dist/
while every step, run from the repository root, wrote to dist/."""
def test_the_default_is_the_root_dist_wherever_the_run_starts(self):
previous = os.getcwd()
self.addCleanup(os.chdir, previous)
os.chdir(ROOT / "scripts")
self.assertEqual(pipeline._output_dir(None), str(ROOT / "dist"))
self.assertEqual(pipeline._output_dir("out"), str(ROOT / "scripts" / "out"))
def test_main_resolves_it_before_the_lock(self):
source = (ROOT / "scripts" / "pipeline.py").read_text(encoding="utf-8")
body = source[source.index("def main("):]
self.assertLess(
body.index("args.output_dir = _output_dir(args.output_dir)"),
body.index("hold_artifact_lock(args.output_dir)"),
)
if __name__ == "__main__":
unittest.main()