Rust: add none compression integration test

This commit is contained in:
Paolo Tranquilli
2025-05-28 16:38:25 +02:00
parent 923a2854cb
commit 8248c50bdf

View File

@@ -19,14 +19,25 @@ def test_do_not_print_env(codeql, rust, rust_edition, cargo, check_env_not_dumpe
@pytest.mark.ql_test("steps.ql", expected=".cargo.expected")
@pytest.mark.parametrize(("rust_edition", "compression", "suffix"), [
pytest.param(2024, "gzip", ".gz", id="gzip"),
pytest.param(2024, "zstd", ".zst", id="zstd"),
pytest.param(2024, "none", [], id="none"),
pytest.param(2024, "gzip", [".gz"], id="gzip"),
pytest.param(2024, "zstd", [".zst"], id="zstd"),
])
def test_compression(codeql, rust, rust_edition, compression, suffix, cargo, rust_check_diagnostics, cwd):
codeql.database.create(cleanup=False, _env={
"CODEQL_EXTRACTOR_RUST_TRAP_COMPRESSION": compression,
})
codeql.database.create(
_env={
"CODEQL_EXTRACTOR_RUST_OPTION_TRAP_COMPRESSION": compression,
}
)
trap_files = [*(cwd / "test-db" / "trap").rglob("*.trap*")]
assert trap_files
files_with_wrong_format = [f for f in trap_files if f.suffix != suffix and f.name != "metadata.trap.gz"]
assert not files_with_wrong_format, f"Found trap files with wrong format: {files_with_wrong_format}"
assert trap_files, "No trap files found"
expected_suffixes = [".trap"] + suffix
def is_of_expected_format(file):
return file.name == "metadata.trap.gz" or \
file.suffixes[-len(expected_suffixes):] == expected_suffixes
files_with_wrong_format = [
f for f in trap_files if not is_of_expected_format(f)
]
assert not files_with_wrong_format, f"Found trap files with wrong format"