mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-13 00:34:43 +00:00
test(repo): generalize docs drift guard
This commit is contained in:
parent
95cba22a96
commit
e918cca2c9
1 changed files with 9 additions and 10 deletions
|
|
@ -3,19 +3,17 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import re
|
||||||
import unittest
|
import unittest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
REPO_ROOT = Path(__file__).resolve().parents[2]
|
REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||||
|
|
||||||
FORBIDDEN_SNIPPETS = (
|
FORBIDDEN_PATTERNS = (
|
||||||
"https://github.com/rcourtman/Pulse/blob/main/",
|
re.compile(r"https://github\.com/[^/\s\"')]+/[^/\s\"')]+/blob/(?:main|master)/"),
|
||||||
"https://github.com/rcourtman/Pulse/blob/master/",
|
re.compile(r"https://github\.com/[^/\s\"')]+/[^/\s\"')]+/tree/(?:main|master)/docs/"),
|
||||||
"https://github.com/rcourtman/Pulse/tree/main/docs/",
|
re.compile(r"https://raw\.githubusercontent\.com/[^/\s\"')]+/[^/\s\"')]+/(?:main|master)/docs/"),
|
||||||
"https://github.com/rcourtman/Pulse/tree/master/docs/",
|
|
||||||
"https://raw.githubusercontent.com/rcourtman/Pulse/main/docs/",
|
|
||||||
"https://raw.githubusercontent.com/rcourtman/Pulse/master/docs/",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
SKIP_DIR_NAMES = {
|
SKIP_DIR_NAMES = {
|
||||||
|
|
@ -81,9 +79,10 @@ class RepoDocsLinkDriftTest(unittest.TestCase):
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for snippet in FORBIDDEN_SNIPPETS:
|
for pattern in FORBIDDEN_PATTERNS:
|
||||||
if snippet in content:
|
match = pattern.search(content)
|
||||||
offenders.append(f"{rel_path}: {snippet}")
|
if match:
|
||||||
|
offenders.append(f"{rel_path}: {match.group(0)}")
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
offenders,
|
offenders,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue