Skip to content

Commit a346718

Browse files
committed
parametrize cli test
1 parent 7c6eb1d commit a346718

1 file changed

Lines changed: 10 additions & 22 deletions

File tree

test/cli/other_test.py

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4863,7 +4863,16 @@ def test_ipc_inline_suppressions(tmp_path):
48634863
assert stdout_lines == stdout_exp
48644864
assert stderr.splitlines() == []
48654865

4866-
def __count_openat_calls(tmpdir, flags, expected):
4866+
test_redundant_file_reads_params = [
4867+
([], 3),
4868+
(['--suppress=zerodiv'], 1),
4869+
(['--template=cppcheck1'], 1),
4870+
(['--xml'], 1),
4871+
]
4872+
4873+
@pytest.mark.skipif(sys.platform != 'linux' or 'ASAN_OPTIONS' in os.environ, reason="uses strace")
4874+
@pytest.mark.parametrize('flags,expected', test_redundant_file_reads_params)
4875+
def test_redundant_file_reads(tmpdir, flags, expected):
48674876
source_pathname = os.path.join(tmpdir, 'test.c')
48684877
content = """
48694878
void f(int x) {
@@ -4895,24 +4904,3 @@ def __count_openat_calls(tmpdir, flags, expected):
48954904

48964905
assert proc.returncode == 0
48974906
assert stderr.splitlines()[-1].strip() == f'{expected} total'.encode('utf-8')
4898-
4899-
__strace_decorator = pytest.mark.skipif(
4900-
sys.platform != 'linux' or 'ASAN_OPTIONS' in os.environ,
4901-
reason="uses strace"
4902-
)
4903-
4904-
@__strace_decorator
4905-
def test_redundant_file_reads(tmpdir):
4906-
__count_openat_calls(tmpdir, [], 3)
4907-
4908-
@__strace_decorator
4909-
def test_redundant_file_reads_suppress(tmpdir):
4910-
__count_openat_calls(tmpdir, [ '--suppress=zerodiv' ], 1)
4911-
4912-
@__strace_decorator
4913-
def test_redundant_file_reads_template_cppcheck1(tmpdir):
4914-
__count_openat_calls(tmpdir, [ '--template=cppcheck1' ], 1)
4915-
4916-
@__strace_decorator
4917-
def test_redundant_file_reads_xml(tmpdir):
4918-
__count_openat_calls(tmpdir, [ '--xml' ], 1)

0 commit comments

Comments
 (0)