29 lines
1010 B
Python
29 lines
1010 B
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: MIT
|
|
"""Unknown PR paths must retain compiled source checks."""
|
|
|
|
import importlib.util
|
|
from pathlib import Path
|
|
import unittest
|
|
|
|
|
|
spec = importlib.util.spec_from_file_location("pr_surface", Path(__file__).with_name("pr_surface.py"))
|
|
surface = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(surface)
|
|
|
|
|
|
class PrSurfaceTest(unittest.TestCase):
|
|
def test_documentation_and_tooling(self):
|
|
self.assertEqual(surface.classify(["README.md", "docs/boards.md"]), "documentation")
|
|
self.assertEqual(surface.classify(["ci/evidence_status.py", "ci/CONFORMANCE.md"]), "tooling")
|
|
|
|
def test_unknown_and_rust_paths_fail_open_to_build(self):
|
|
for paths in ([], ["src/main.rs"], ["Cargo.toml"], ["unknown/file"],
|
|
["ci/evidence_status.py", "src/main.rs"]):
|
|
with self.subTest(paths=paths):
|
|
self.assertEqual(surface.classify(paths), "rust")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|