Decompose oversized Rust files by responsibility
This commit is contained in:
parent
03bfe92ca0
commit
ee9201b057
1 changed files with 18648 additions and 18513 deletions
|
|
@ -25,6 +25,15 @@ CORPUS_LOADER.exec_module(CORPUS)
|
|||
|
||||
|
||||
class VerificationTests(unittest.TestCase):
|
||||
def test_verification_temporaries_use_the_ignored_target_tree(self) -> None:
|
||||
original = VERIFY.VERIFICATION_TEMP_ROOT
|
||||
try:
|
||||
VERIFY.VERIFICATION_TEMP_ROOT = ROOT / "target" / "verification-test"
|
||||
with VERIFY.temporary_directory("example-") as directory:
|
||||
self.assertEqual(Path(directory).parent, VERIFY.VERIFICATION_TEMP_ROOT)
|
||||
finally:
|
||||
VERIFY.VERIFICATION_TEMP_ROOT = original
|
||||
|
||||
def test_current_workspace_lints_pass(self) -> None:
|
||||
VERIFY.audit_workspace_lints(VERIFY.workspace_metadata())
|
||||
|
||||
|
|
@ -176,6 +185,47 @@ class VerificationTests(unittest.TestCase):
|
|||
with self.assertRaisesRegex(VERIFY.VerificationError, "must not contain"):
|
||||
VERIFY.workspace_rust_sources(metadata)
|
||||
|
||||
def test_rust_file_size_audit_rejects_unreviewed_oversized_source(self) -> None:
|
||||
with tempfile.TemporaryDirectory(dir=ROOT) as directory:
|
||||
package_root = Path(directory)
|
||||
source = package_root / "oversized.rs"
|
||||
source.write_text("fn item() {}\n" * (VERIFY.RUST_FILE_LINE_LIMIT + 1))
|
||||
metadata = {
|
||||
"workspace_members": ["outside"],
|
||||
"packages": [
|
||||
{
|
||||
"id": "outside",
|
||||
"manifest_path": str(package_root / "Cargo.toml"),
|
||||
}
|
||||
],
|
||||
"target_directory": str(ROOT / "target"),
|
||||
}
|
||||
original = VERIFY.RUST_FILE_SIZE_EXCEPTIONS
|
||||
try:
|
||||
VERIFY.RUST_FILE_SIZE_EXCEPTIONS = {}
|
||||
with self.assertRaisesRegex(VERIFY.VerificationError, "oversized.rs"):
|
||||
VERIFY.audit_rust_file_sizes(metadata)
|
||||
finally:
|
||||
VERIFY.RUST_FILE_SIZE_EXCEPTIONS = original
|
||||
|
||||
def test_rust_file_size_exceptions_are_exact_and_current(self) -> None:
|
||||
metadata = VERIFY.workspace_metadata()
|
||||
original = VERIFY.RUST_FILE_SIZE_EXCEPTIONS
|
||||
cases = (
|
||||
{"/absolute.rs": "one durable responsibility"},
|
||||
{"missing.rs": "one durable responsibility"},
|
||||
{"crates/lazaret-core/src/lib.rs": "one durable responsibility"},
|
||||
{"crates/lazaret-core/src/configuration.rs": "vague"},
|
||||
)
|
||||
try:
|
||||
for exceptions in cases:
|
||||
with self.subTest(exceptions=exceptions):
|
||||
VERIFY.RUST_FILE_SIZE_EXCEPTIONS = exceptions
|
||||
with self.assertRaises(VERIFY.VerificationError):
|
||||
VERIFY.audit_rust_file_sizes(metadata)
|
||||
finally:
|
||||
VERIFY.RUST_FILE_SIZE_EXCEPTIONS = original
|
||||
|
||||
def test_process_trace_requires_exactly_one_exec(self) -> None:
|
||||
VERIFY.validate_process_trace("example", ['execve("example", [], []) = 0'])
|
||||
with self.assertRaisesRegex(VERIFY.VerificationError, "execve surface count 0"):
|
||||
|
|
|
|||
Loading…
Reference in a new issue