Files
RustBox/tests/test_warning_hygiene.py
T
Mateusz Gruszczyński 425ea7449b
RustBox CI / rustbox (push) Canceled after 0s
v0.1.0
2026-10-30 17:22:17 +01:00

36 lines
1.3 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def test_query_catalog_dead_code_lint_is_scoped_to_queries_only():
queries_mod = (ROOT / "src/queries/mod.rs").read_text()
for dialect in ("sqlite", "mysql", "pgsql"):
assert f"#[allow(dead_code)]\npub mod {dialect};" in queries_mod
assert "#![allow(dead_code)]" not in queries_mod
rust_sources = [p for p in (ROOT / "src").rglob("*.rs") if p != ROOT / "src/queries/mod.rs"]
for path in rust_sources:
text = path.read_text()
assert "#![allow(warnings)]" not in text, path
assert "#![allow(dead_code)]" not in text, path
def test_test_only_session_helpers_are_not_in_production_build():
text = (ROOT / "src/auth/session.rs").read_text()
signatures = [
"pub fn new(timeout: Duration) -> Self",
"pub fn new_with_tls_verify(timeout: Duration, tls_verify_override: Option<bool>) -> Self",
"pub fn add_account_to_browser(",
]
for signature in signatures:
pos = text.index(signature)
prefix = text[max(0, pos - 120):pos]
assert "#[cfg(test)]" in prefix, signature
def test_test_only_rfc822_helper_is_not_in_production_build():
text = (ROOT / "src/smtp/builder.rs").read_text()
pos = text.index("pub fn build_rfc822(")
assert "#[cfg(test)]" in text[max(0, pos - 80):pos]