diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-21 11:36:01 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-21 11:36:01 +0200 |
| commit | 766ce6ff1ea584dfe980a5e0b29251768c4c0726 (patch) | |
| tree | eaa047f46fc9b59acae745406a116d2e479239ca /tests/test_remote.py | |
| parent | fb93767351dc0d7d4d4da8068b2f94df6ef44b6d (diff) | |
| download | sb-builder-766ce6ff1ea584dfe980a5e0b29251768c4c0726.tar.gz sb-builder-766ce6ff1ea584dfe980a5e0b29251768c4c0726.zip | |
sbb-remote 0.12.0: named builds, per-package job results, prune
- Packages: named packages run slackrepo build, which also updates outdated
ones; update on a named item finds only already-built packages. The
per-row Update action is gone, Update all stays.
- A real slackrepo job reads its items' buildresults rows into the job's
results and is failed when any item failed, aborted or was bad:
slackrepo itself exits 0. The notification names the failed items; a
Build results dialog lists every item with its log and Retry failed,
reopenable from the Jobs ribbon.
- slackrepo prune: the helper lists built items whose SlackBuild is gone
and runs slackrepo remove on them, without an Update all. stats gives
the count; Packages gets a Prune action, the Built tile a 'to prune'
note. Remove and prune ask for confirmation at Run it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_remote.py')
| -rw-r--r-- | tests/test_remote.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/test_remote.py b/tests/test_remote.py index 44d3a90..9f28701 100644 --- a/tests/test_remote.py +++ b/tests/test_remote.py @@ -172,6 +172,26 @@ class KindsTest(Base): with self.subTest(args=args), self.assertRaises(sbb.Error): sbb.KINDS["slackrepo"](self.cfg, args) + def test_slackrepo_prune(self): + self.make_pkg("misc/kept") + db = sqlite3.connect(self.cfg["slackrepo_db"]) + db.executescript(""" + create table packages (pkgnam text primary key, itemid text); + insert into packages values ('kept-1-x86_64-1_x', 'misc/kept'), + ('gone-1-x86_64-1_x', 'misc/gone'), ('gone-doc-1-noarch-1_x', 'misc/gone'), + ('evil-1', '-rf/x'); + """) + db.close() + kind = sbb.KINDS["slackrepo"] + self.assertEqual(kind(self.cfg, ["prune", "--preview"]), + (["slackrepo", "--repo=SBo-danix", "remove", "--preview", "misc/gone"], {})) + self.assertEqual(sbb.cmd_stats(self.cfg)["prunable"], 1) + with self.assertRaises(sbb.Error): + kind(self.cfg, ["prune", "kept"]) + self.make_pkg("misc/gone") + with self.assertRaisesRegex(sbb.Error, "nothing to prune"): + kind(self.cfg, ["prune"]) + def test_publish(self): self.assertEqual(sbb.KINDS["publish"](self.cfg, []), (["sb-publish"], {})) with self.assertRaises(sbb.Error): @@ -749,6 +769,32 @@ class JobsTest(Base): m = sbb.read_meta(d) self.assertEqual((m["status"], m["exit"]), ("failed", 3)) + def slackrepo_job(self, results, args=("build", "a", "b")): + jid, d = self.make_job(["sh", "-c", "exit 0"], kind="slackrepo", args=list(args)) + db = sqlite3.connect(self.cfg["slackrepo_db"]) + db.execute("create table buildresults (itemid text primary key, time text, result text)") + db.execute("insert into buildresults values ('cat/old', '1', 'failed')") # before the job + db.executemany("insert into buildresults values (?, ?, ?)", + [(i, str(int(time.time()) + 1), r) for i, r in results.items()]) + db.commit() + db.close() + sbb.cmd_run(self.cfg, jid) + return sbb.read_meta(d) + + def test_run_results_failed(self): + m = self.slackrepo_job({"cat/a": "ok", "cat/b": "aborted"}) + self.assertEqual((m["status"], m["exit"]), ("failed", 0)) + self.assertEqual(m["results"], {"cat/a": "ok", "cat/b": "aborted"}) + + def test_run_results_ok(self): + m = self.slackrepo_job({"cat/a": "ok", "cat/b": "skipped"}) + self.assertEqual((m["status"], m["results"]), ("ok", {"cat/a": "ok", "cat/b": "skipped"})) + + def test_run_preview_no_results(self): + m = self.slackrepo_job({"cat/a": "failed"}, args=("build", "--preview", "a")) + self.assertEqual(m["status"], "ok") + self.assertNotIn("results", m) + def test_run_missing_program(self): jid, d = self.make_job(["/nonexistent/prog"]) sbb.cmd_run(self.cfg, jid) |
