Bug fixes and package updates.
This commit is contained in:
1 parent
19b789ef5c
commit
d0c977281d
11 files changed
+176
-27
No files matched your search
@@ -42,7 +42,7 @@ elif tool in ("go", "bootstrap-go"):
|
||||
version = "1.24.0" if tool == "bootstrap-go" else os.environ["INSTALLED_GO"]
|
||||
print("go version go" + version + " linux/amd64")
|
||||
elif args[0] == "build":
|
||||
if args[-1].endswith("cthulhu-braille") and os.environ.get("FAIL_BRAILLE"):
|
||||
if args[-1] == os.environ.get("FAIL_BUILD_TARGET"):
|
||||
sys.exit(2)
|
||||
Path(args[args.index("-o") + 1]).touch()
|
||||
'''
|
||||
@@ -162,11 +162,13 @@ class BuildScriptTests(unittest.TestCase):
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertFalse(self.calls("curl"))
|
||||
|
||||
def test_braille_failure_is_not_reported_as_success(self):
|
||||
self.env["FAIL_BRAILLE"] = "1"
|
||||
result = self.run_build()
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertNotIn("Cthulhu has been built", result.stdout)
|
||||
def test_helper_failure_is_not_reported_as_success(self):
|
||||
for helper in ("cthulhu-braille", "cthulhu-input-helper"):
|
||||
with self.subTest(helper=helper):
|
||||
self.env["FAIL_BUILD_TARGET"] = f"./cmd/{helper}"
|
||||
result = self.run_build()
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertNotIn("Cthulhu has been built", result.stdout)
|
||||
|
||||
def test_disabled_cgo_and_output_conflicts_fail_before_building(self):
|
||||
self.env["CGO_ENABLED"] = "0"
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check package contents for sources before and after Remote input support."""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
MOCK_GO = '''#!/usr/bin/env python3
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
args = sys.argv[1:]
|
||||
assert args[0] == "build"
|
||||
assert Path(args[-1]).is_dir(), "build target is absent from this source version"
|
||||
if args[-1] == os.environ.get("FAIL_BUILD_TARGET"):
|
||||
sys.exit(2)
|
||||
target = Path(args[args.index("-o") + 1])
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_text("#!/bin/sh\\nexit 0\\n")
|
||||
target.chmod(0o755)
|
||||
'''
|
||||
|
||||
|
||||
class PackageBinaryTests(unittest.TestCase):
|
||||
def test_build_and_install_source_supported_helpers(self):
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
recipes = sorted((root / "distro-packages").rglob("PKGBUILD"))
|
||||
self.assertTrue(recipes)
|
||||
for recipe in recipes:
|
||||
for has_input, fail_input in ((False, False), (True, False), (True, True)):
|
||||
with self.subTest(recipe=recipe.parent.name, has_input=has_input,
|
||||
fail_input=fail_input), tempfile.TemporaryDirectory() as tmp:
|
||||
work = Path(tmp)
|
||||
source = work / "cthulhu"
|
||||
binaries = ["cthulhu", "cthulhu-braille"]
|
||||
if has_input:
|
||||
binaries.append("cthulhu-input-helper")
|
||||
for binary in binaries:
|
||||
(source / "cmd" / binary).mkdir(parents=True)
|
||||
for name in ("LICENSE", "AUTHORS"):
|
||||
(source / name).write_text("fixture\n")
|
||||
# A stale artifact must not enter an older source's package.
|
||||
(source / "build").mkdir()
|
||||
(source / "build" / "cthulhu-input-helper").write_text("stale")
|
||||
tools = work / "tools"
|
||||
tools.mkdir()
|
||||
go = tools / "go"
|
||||
go.write_text(MOCK_GO)
|
||||
go.chmod(0o755)
|
||||
stage = work / "package"
|
||||
environment = dict(os.environ, PATH=f"{tools}:{os.environ['PATH']}",
|
||||
srcdir=str(work), pkgdir=str(stage))
|
||||
if fail_input:
|
||||
environment["FAIL_BUILD_TARGET"] = "./cmd/cthulhu-input-helper"
|
||||
result = subprocess.run(
|
||||
["bash", "-ec", 'source "$1"\nbuild\ncd "$srcdir"\npackage',
|
||||
"package-test", str(recipe)], cwd=work, env=environment,
|
||||
capture_output=True, text=True, check=False)
|
||||
if fail_input:
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertFalse(stage.exists())
|
||||
continue
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
installed = stage / "usr/bin"
|
||||
self.assertEqual(sorted(p.name for p in installed.iterdir()), sorted(binaries))
|
||||
for binary in binaries:
|
||||
self.assertTrue(os.access(installed / binary, os.X_OK))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user