Ruby: add compression integration test

This commit is contained in:
Paolo Tranquilli
2025-05-28 16:38:36 +02:00
parent 8248c50bdf
commit fd00ed502d
4 changed files with 34 additions and 0 deletions

View File

@@ -0,0 +1 @@
| source.rb:1:1:3:3 | f |

View File

@@ -0,0 +1,4 @@
import codeql.ruby.AST
from Method m
select m

View File

@@ -0,0 +1,3 @@
def f
puts "hello"
end

View File

@@ -0,0 +1,26 @@
import pytest
@pytest.mark.parametrize(("compression", "suffix"), [
pytest.param("none", [], id="none"),
pytest.param("gzip", [".gz"], id="gzip"),
pytest.param("zstd", [".zst"], id="zstd"),
])
def test(codeql, ruby, compression, suffix, cwd):
codeql.database.create(
_env={
"CODEQL_EXTRACTOR_RUBY_OPTION_TRAP_COMPRESSION": compression,
}
)
trap_files = [*(cwd / "test-db" / "trap").rglob("*.trap*")]
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"