aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_remote.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_remote.py')
-rw-r--r--tests/test_remote.py75
1 files changed, 73 insertions, 2 deletions
diff --git a/tests/test_remote.py b/tests/test_remote.py
index 57d492c..30bdc73 100644
--- a/tests/test_remote.py
+++ b/tests/test_remote.py
@@ -135,6 +135,12 @@ class ConfigTest(Base):
with self.assertRaisesRegex(sbb.Error, "bogus: unknown key"):
sbb.load_config(self.write("bogus = 1\n"))
+ def test_manifests(self):
+ self.assertEqual(sbb.load_config(self.write("[manifests]\nx = \"u{VERSION}\"\n"))["manifests"],
+ {"x": "u{VERSION}"})
+ with self.assertRaisesRegex(sbb.Error, "manifests: expected strings"):
+ sbb.load_config(self.write("[manifests]\nx = 1\n"))
+
def test_wrong_type(self):
with self.assertRaisesRegex(sbb.Error, "state_dir: expected str"):
sbb.load_config(self.write("state_dir = 1\n"))
@@ -302,6 +308,73 @@ class ApplyVersionTest(Base):
self.apply(f'VERSION="1.0"\nDOWNLOAD="{self.www.url}/x-1.0.tgz"\nMD5SUM="m"\n', "3.0")
+GH = "https://github.com"
+# neovim 0.12.4: hint URLs (SBo shapes) and their deps.txt counterparts
+NVIM_HINT = [f"{GH}/neovim/neovim/archive/v0.12.4/neovim-0.12.4.tar.gz",
+ f"{GH}/luajit/LuaJIT/archive/fbb36bb/LuaJIT-fbb36bb6bfa88716a47c58bcf9ce9f2ef752abac.tar.gz",
+ f"{GH}/luvit/luv/releases/download/1.52.1-0/luv-1.52.1-0.tar.gz",
+ f"{GH}/lunarmodules/lua-compat-5.3/archive/v0.13/lua-compat-5.3-0.13.tar.gz",
+ f"{GH}/tree-sitter/tree-sitter/archive/v0.26.7/tree-sitter-0.26.7.tar.gz",
+ "https://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.1.0.tar.gz",
+ f"{GH}/JuliaStrings/utf8proc/archive/v2.11.3/utf8proc-2.11.3.tar.gz"]
+NVIM_DEPS = [f"{GH}/luajit/luajit/archive/fbb36bb6bfa88716a47c58bcf9ce9f2ef752abac.tar.gz",
+ f"{GH}/luvit/luv/archive/1.52.1-0.tar.gz",
+ f"{GH}/lunarmodules/lua-compat-5.3/archive/v0.13.tar.gz",
+ f"{GH}/tree-sitter/tree-sitter-c/archive/v0.24.1.tar.gz",
+ f"{GH}/tree-sitter/tree-sitter/archive/v0.26.7.tar.gz",
+ f"{GH}/neovim/deps/raw/d495ee6f79e7962a53ad79670cb92488abe0b9b4/opt/lpeg-1.1.0.tar.gz",
+ f"{GH}/juliastrings/utf8proc/archive/v2.11.3.tar.gz"]
+
+
+class BundledDepsTest(Base):
+ def test_hint_and_manifest_shapes_match_with_equal_versions(self):
+ for url in NVIM_HINT[1:]:
+ m = sbb._match(url, NVIM_DEPS)
+ with self.subTest(url=url):
+ self.assertIsNotNone(m)
+ self.assertEqual(sbb._url_version(url), sbb._url_version(m))
+ self.assertIsNone(sbb._match(NVIM_HINT[0], NVIM_DEPS))
+ self.assertEqual([sbb._url_version(u) for u in NVIM_HINT[2:4]], ["1.52.1_0", "0.13"])
+ self.assertEqual(sbb._dep_name(NVIM_HINT[5]), "lpeg")
+
+ def test_reconcile(self):
+ hint = 'DOWNLOAD="' + " \\\n ".join(NVIM_HINT[:3] + [f"{GH}/a/gone/archive/v1/gone-1.tar.gz"]) + '"\n'
+ deps = "\n".join(f"X_URL {u}\nX_SHA256 ab" for u in NVIM_DEPS).replace("1.52.1-0", "1.53.0-0")
+ log = []
+ out = sbb.reconcile(hint, deps, log.append)
+ self.assertEqual(sbb.hint_tokens(out, "DOWNLOAD"),
+ NVIM_HINT[:2] + [f"{GH}/luvit/luv/archive/1.53.0-0.tar.gz",
+ f"{GH}/a/gone/archive/v1/gone-1.tar.gz"])
+ self.assertEqual(log, ["luv 1.52.1_0 -> 1.53.0_0", "gone no manifest match, left as is",
+ "manifest has 5 deps not in the hint"])
+ self.assertIs(sbb.reconcile(hint, deps.replace("1.53.0-0", "1.52.1-0"), log.append), hint)
+ with self.assertRaisesRegex(sbb.Error, "no URLs"):
+ sbb.reconcile(hint, "moved\n", log.append)
+
+ def test_apply_version_follows_manifest(self):
+ www = Served(self, {"x-2.0.tgz": b"two", "dep-0.6.tgz": b"dep11", "keep-3.tgz": b"keep"})
+ u, log = www.url, []
+ with open(os.path.join(self.tmp, "www", "deps-2.0.txt"), "w") as f:
+ f.write(f"DEP_URL {u}/dep-0.6.tgz\nKEEP_URL {u}/keep-3.tgz\n")
+ text = (f'VERSION="1.0"\nDOWNLOAD="{u}/x-1.0.tgz \\\n {u}/dep-0.5.tgz \\\n {u}/keep-3.tgz"\n'
+ 'MD5SUM="a \\\n b \\\n c"\n')
+ out = sbb.apply_version(text, "", "2.0", False, log.append, u + "/deps-{VERSION}.txt")
+ self.assertEqual(out, f'VERSION="2.0"\nDOWNLOAD="{u}/x-2.0.tgz \\\n {u}/dep-0.6.tgz \\\n'
+ f' {u}/keep-3.tgz"\nMD5SUM="{md5(b"two")} \\\n {md5(b"dep11")} \\\n c"\n')
+ self.assertEqual(log, [f"manifest {u}/deps-2.0.txt", "dep 0.5 -> 0.6",
+ f"downloading {u}/x-2.0.tgz", f"downloading {u}/dep-0.6.tgz"])
+ with self.assertRaises(OSError): # no deps list at 3.0: the package fails, hint untouched
+ sbb.apply_version(text, "", "3.0", False, log.append, u + "/deps-{VERSION}.txt")
+
+ def test_changed_continuation_url_gets_its_md5(self):
+ www = Served(self, {"f-2.0.tgz": b"two", "f-2.0-vendor.tgz": b"vendor"})
+ u, log = www.url, []
+ text = f'VERSION="1.0"\nDOWNLOAD="{u}/f-1.0.tgz \\\n {u}/f-1.0-vendor.tgz"\nMD5SUM="a \\\n b"\n'
+ self.assertIn(f'MD5SUM="{md5(b"two")} \\\n {md5(b"vendor")}"',
+ sbb.apply_version(text, "", "2.0", False, log.append))
+ self.assertEqual(log, [f"downloading {u}/f-2.0.tgz", f"downloading {u}/f-2.0-vendor.tgz"])
+
+
class HintJobsTest(Base):
def setUp(self):
super().setUp()
@@ -349,14 +422,12 @@ class HintJobsTest(Base):
("hint-update", ["nope=1"], "no such package"),
("hint-update", ["x=1", "x=2"], "twice"),
("hint-update", ["x=1", "--force"], "unknown option"),
- ("hint-update", ["neovim=1"], "bundled deps"),
("hint-update", ["shadowed=1"], "not managed"),
("hint-new", [], "hint-new <pkg>"),
("hint-new", ["x", "2.0"], "no such package: 2.0"), # no version any more
("hint-new", ["x", "x"], "twice")):
with self.subTest(kind=kind, args=args), self.assertRaisesRegex(sbb.Error, why):
sbb.KINDS[kind](self.cfg, args)
- sbb.KINDS["hint-new"](self.cfg, ["neovim"]) # no version: no bundled deps to touch
self.make_pkg("misc/y", self.info, hint="")
with self.assertRaisesRegex(sbb.Error, "y: hint exists"):
sbb.KINDS["hint-new"](self.cfg, ["x", "y"]) # one with a hint refuses the whole job