mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Ruby: add compression integration test
This commit is contained in:
1
ruby/ql/integration-tests/compression/methods.expected
Normal file
1
ruby/ql/integration-tests/compression/methods.expected
Normal file
@@ -0,0 +1 @@
|
||||
| source.rb:1:1:3:3 | f |
|
||||
4
ruby/ql/integration-tests/compression/methods.ql
Normal file
4
ruby/ql/integration-tests/compression/methods.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import codeql.ruby.AST
|
||||
|
||||
from Method m
|
||||
select m
|
||||
3
ruby/ql/integration-tests/compression/source.rb
Normal file
3
ruby/ql/integration-tests/compression/source.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
def f
|
||||
puts "hello"
|
||||
end
|
||||
26
ruby/ql/integration-tests/compression/test.py
Normal file
26
ruby/ql/integration-tests/compression/test.py
Normal 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"
|
||||
Reference in New Issue
Block a user