Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion RegressionTests/corpus_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,11 @@ def buckets_for(state, detections, sig_subtypes, in_errors):
def find_run(explicit, channel="develop", corpus="full"):
if explicit:
p = Path(explicit)
return p if p.is_absolute() else REG_DIR / p
p = p if p.is_absolute() else REG_DIR / p
log = p / "PlexCleaner_process.log"
if not log.is_file():
sys.exit(f"ERROR: --run {explicit} has no process log at {log}")
return p
best, best_mt = None, 0
for d in REG_DIR.glob("*/"):
log, bi = d / "PlexCleaner_process.log", d / "buildinfo.json"
Expand Down
25 changes: 23 additions & 2 deletions RegressionTests/tests/test_corpus_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,29 @@ def test_parse(self) -> None:

class FindRunTests(unittest.TestCase):
def test_explicit_absolute_and_relative(self) -> None:
self.assertEqual(cc.find_run("/some/abs"), Path("/some/abs"))
self.assertEqual(cc.find_run("rel"), cc.REG_DIR / "rel")
with tempfile.TemporaryDirectory() as d:
root = Path(d)
self._run(root, "1.0.0-ga", 1000, {"Channel": "develop"})
self.assertEqual(cc.find_run(str(root / "1.0.0-ga")), root / "1.0.0-ga")
with mock.patch.object(cc, "REG_DIR", root):
self.assertEqual(cc.find_run("1.0.0-ga"), root / "1.0.0-ga")

def test_explicit_missing_dir_exits(self) -> None:
with tempfile.TemporaryDirectory() as d:
root = Path(d)
with mock.patch.object(cc, "REG_DIR", root), self.assertRaises(SystemExit) as cm:
cc.find_run("0.0.0-gmissing")
self.assertIn(
str(root / "0.0.0-gmissing" / "PlexCleaner_process.log"), str(cm.exception.code)
)

def test_explicit_dir_without_log_exits(self) -> None:
with tempfile.TemporaryDirectory() as d:
run = Path(d) / "1.0.0-ga"
run.mkdir()
with self.assertRaises(SystemExit) as cm:
cc.find_run(str(run))
self.assertIn("no process log", str(cm.exception.code))

@staticmethod
def _run(root: Path, name: str, mtime: int, info: dict[str, str]) -> None:
Expand Down
Loading