Skip to content

Commit 3b025b2

Browse files
oharboeclaude
andcommitted
test: issue archive members are relative to the archive's root
Files under FLOW_HOME lose its path in the archive, so a design outside the ORFS checkout gives a working archive (#1410). Files under an absolute WORK_HOME, such as a CI workspace, lose its path too, through a symlink and with a trailing slash, while a directory that only starts with WORK_HOME's name keeps its path (#4274). The tests make archives with WORK_HOME ".", absolute, absolute with a trailing slash and through a symlink, and check the logs, results, scripts, design, platform, run-me and vars files are at the archive's root and no absolute path is recreated. Without the --transform expressions four of the five fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 75b7212 commit 3b025b2

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

‎flow/test/test_make_issue.py‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,5 +391,62 @@ def test_step_named_after_the_target_not_its_path(self):
391391
self.assertTrue(recorded["script"].startswith("./scripts/"), recorded)
392392

393393

394+
class TestArchiveLayout(StubFlowTestCase):
395+
"""Archive members are relative to the archive's root: files under
396+
FLOW_HOME lose its path, so a design outside the ORFS checkout works
397+
(#1410), and so do files under an absolute WORK_HOME, however it is
398+
spelled: through a symlink or with a trailing slash (#4274). A
399+
directory that only starts with WORK_HOME's name keeps its path
400+
(#4274)."""
401+
402+
def root_entries(self, archive):
403+
prefix = f"{STEP}_{TAG}/"
404+
members = self.stub.members(archive)
405+
for member in members:
406+
self.assertTrue(member.startswith(prefix), member)
407+
return {os.path.normpath(m[len(prefix) :]).split("/")[0] for m in members}
408+
409+
def assert_at_root(self, work_home, **extra):
410+
archive = self.stub.make_issue(work_home, **extra)
411+
entries = self.root_entries(archive)
412+
for entry in [
413+
"results_dir",
414+
"log_dir",
415+
f"run-me-{FLOW_NAME}.sh",
416+
f"vars-{FLOW_NAME}.sh",
417+
"scripts",
418+
"designs",
419+
"platforms",
420+
]:
421+
self.assertIn(entry, entries)
422+
tmp_top = self.stub.tmp.strip("/").split("/")[0]
423+
self.assertNotIn(tmp_top, entries)
424+
return archive
425+
426+
def test_flow_home_files(self):
427+
self.assert_at_root(".")
428+
429+
def test_absolute_work_home(self):
430+
self.assert_at_root(os.path.join(self.stub.tmp, "work"))
431+
432+
def test_absolute_work_home_with_trailing_slash(self):
433+
self.assert_at_root(os.path.join(self.stub.tmp, "work") + "/")
434+
435+
def test_work_home_through_a_symlink(self):
436+
real = os.path.join(self.stub.tmp, "real_work")
437+
os.makedirs(real)
438+
link = os.path.join(self.stub.tmp, "work")
439+
os.symlink(real, link)
440+
self.assert_at_root(link)
441+
442+
def test_a_sibling_of_work_home_keeps_its_path(self):
443+
work = os.path.join(self.stub.tmp, "work")
444+
sibling = os.path.join(self.stub.tmp, "work_other", "d.sdc")
445+
self.stub.write(sibling, "\n")
446+
archive = self.stub.make_issue(work, SDC_FILE=sibling)
447+
members = self.stub.members(archive)
448+
self.assertIn(f"{STEP}_{TAG}{sibling}", members)
449+
450+
394451
if __name__ == "__main__":
395452
unittest.main()

0 commit comments

Comments
 (0)