Skip to content

Commit fd00ed5

Browse files
author
Paolo Tranquilli
committed
Ruby: add compression integration test
1 parent 8248c50 commit fd00ed5

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| source.rb:1:1:3:3 | f |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import codeql.ruby.AST
2+
3+
from Method m
4+
select m
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def f
2+
puts "hello"
3+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import pytest
2+
3+
4+
@pytest.mark.parametrize(("compression", "suffix"), [
5+
pytest.param("none", [], id="none"),
6+
pytest.param("gzip", [".gz"], id="gzip"),
7+
pytest.param("zstd", [".zst"], id="zstd"),
8+
])
9+
def test(codeql, ruby, compression, suffix, cwd):
10+
codeql.database.create(
11+
_env={
12+
"CODEQL_EXTRACTOR_RUBY_OPTION_TRAP_COMPRESSION": compression,
13+
}
14+
)
15+
trap_files = [*(cwd / "test-db" / "trap").rglob("*.trap*")]
16+
assert trap_files, "No trap files found"
17+
expected_suffixes = [".trap"] + suffix
18+
19+
def is_of_expected_format(file):
20+
return file.name == "metadata.trap.gz" or \
21+
file.suffixes[-len(expected_suffixes):] == expected_suffixes
22+
23+
files_with_wrong_format = [
24+
f for f in trap_files if not is_of_expected_format(f)
25+
]
26+
assert not files_with_wrong_format, f"Found trap files with wrong format"

0 commit comments

Comments
 (0)