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
19 changes: 18 additions & 1 deletion tests/test_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,29 @@ def tearDownClass(cls):

def test_expected_files_and_archives(self):
for name in ("php2shell-quickcheck.sh", "php2shell-quickcheck.bat", "php2shell-quickcheck.ps1", "php2shell_kr.py",
"LICENSE", "NOTICE", "SHA256SUMS", "data/advisory.json", "virtual-patch/README.ko.md"):
"LICENSE", "NOTICE", "SHA256SUMS", "data/advisory.json", "virtual-patch/README.ko.md",
"CHANGELOG.md", "CONTRIBUTING.md", "SECURITY.md"):
self.assertTrue(os.path.isfile(os.path.join(self.dir, name)), name)
base = "php2shell-kr-%s" % php2shell_kr.__version__
self.assertTrue(os.path.isfile(os.path.join(self.out, base + ".zip")))
self.assertTrue(os.path.isfile(os.path.join(self.out, base + ".tar.gz")))

def test_readme_relative_links_resolve_inside_the_bundle(self):
import re
with open(os.path.join(self.dir, "README.md"), encoding="utf-8") as handle:
text = handle.read()
links = [m.group(1).split("#")[0] for m in re.finditer(r"\]\(([^)\s]+)\)", text)]
relative = sorted({l for l in links if l and not re.match(r"^[a-z][a-z0-9+.-]*:", l, re.I)})
self.assertIn("SECURITY.md", relative)
missing = [l for l in relative if not os.path.exists(os.path.join(self.dir, l))]
self.assertEqual(missing, [], "README 의 상대 링크 대상이 배포 묶음에 없습니다")

def test_policy_docs_are_listed_in_sha256sums(self):
with open(os.path.join(self.dir, "SHA256SUMS"), encoding="utf-8") as handle:
listed = {line.partition(" ")[2].strip() for line in handle if line.strip()}
for name in ("CHANGELOG.md", "CONTRIBUTING.md", "SECURITY.md"):
self.assertIn(name, listed)

def test_checksums_match_every_file(self):
with open(os.path.join(self.dir, "SHA256SUMS"), encoding="utf-8") as handle:
lines = [line.rstrip("\n") for line in handle if line.strip()]
Expand Down
5 changes: 4 additions & 1 deletion tools/build_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ def main(argv=None):
required = [("quickcheck/php2shell-quickcheck.sh", "php2shell-quickcheck.sh"),
("quickcheck/php2shell-quickcheck.ps1", "php2shell-quickcheck.ps1"),
("php2shell_kr.py", "php2shell_kr.py"), ("LICENSE", "LICENSE"), ("NOTICE", "NOTICE"),
("README.md", "README.md")]
("README.md", "README.md"),
# README 가 상대 링크로 참조하는 문서: 오프라인(폐쇄망) 반입 묶음에서도 열려야 한다.
("CHANGELOG.md", "CHANGELOG.md"), ("CONTRIBUTING.md", "CONTRIBUTING.md"),
("SECURITY.md", "SECURITY.md")]
for src, dst in required:
path = os.path.join(ROOT, src)
if not os.path.isfile(path):
Expand Down
Loading