hugo.yaml now stacks themes: hackertours, then zen. layouts/, assets/, i18n/ and the design files from static/ (web manifest, Lucide icons) move to themes/hackertours/. themes/zen goes back to the unmodified upstream v7.1.0; the changes from the hackertours-mobile-nav fork branch live in themes/hackertours instead (mobilemenu.css and mobilemenu.js override zen's, the mobile menu colour is set in _custom.css; the fork's _custom.css additions were already in ours). The generated site is unchanged, apart from where the mobile menu colour is declared in the CSS.
64 lines
2.4 KiB
Python
64 lines
2.4 KiB
Python
import shutil
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class BrandLintTest(unittest.TestCase):
|
|
def build(self, source):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
root = Path(directory)
|
|
(root / "content").mkdir()
|
|
(root / "layouts" / "_partials").mkdir(parents=True)
|
|
(root / "hugo.toml").write_text('baseURL = "https://example.org/"\n')
|
|
(root / "content" / "_index.md").write_text(source)
|
|
(root / "layouts" / "home.html").write_text(
|
|
'{{ partial "lint-brand.html" . }}{{ .Content }}'
|
|
)
|
|
shutil.copy(
|
|
ROOT / "themes" / "hackertours" / "layouts" / "_partials" / "lint-brand.html",
|
|
root / "layouts" / "_partials" / "lint-brand.html",
|
|
)
|
|
return subprocess.run(
|
|
["hugo", "--source", str(root)],
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
|
|
def test_errors_include_spelling_and_source_line(self):
|
|
result = self.build("---\ntitle: Hackertours\n---\nHACKERTOURS and hackertours\n")
|
|
self.assertNotEqual(result.returncode, 0)
|
|
for line, spelling in [(2, "Hackertours"), (4, "HACKERTOURS"), (4, "hackertours")]:
|
|
self.assertIn(f':{line}: "{spelling}" should be "Hackertours"', result.stderr)
|
|
|
|
def test_valid_names_identifiers_and_explicit_exceptions(self):
|
|
result = self.build(
|
|
"---\n"
|
|
"title: Hackertours # hackertours-lint-ignore\n"
|
|
"---\n"
|
|
"Hackertours\n"
|
|
"Hackertours <!-- hackertours-lint-ignore -->\n"
|
|
"[Shop](https://hackertours.example/hackertours) "
|
|
"ticket@hackertours.example @hackertours "
|
|
"#easterhegg-hackertours:example.org\n"
|
|
)
|
|
self.assertEqual(result.returncode, 0, result.stderr)
|
|
|
|
def test_marker_only_ignores_its_own_line(self):
|
|
result = self.build(
|
|
"---\ntitle: Hackertours\n---\n"
|
|
"Hackertours <!-- hackertours-lint-ignore -->\n"
|
|
"Hackertours\n"
|
|
)
|
|
self.assertNotEqual(result.returncode, 0)
|
|
self.assertIn(':5: "Hackertours" should be "Hackertours"', result.stderr)
|
|
self.assertNotIn(':4: "Hackertours" should be "Hackertours"', result.stderr)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|