1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-22 23:48:58 +00:00
pqcrypto/test/test_linter.py
Thom Wiggers 78a65d6ec9 Parallel tests (#206)
* Do tests with pytest to run them in parallel

* attempt to handle merge commits better for PR test path

Similar to how we solved this for travis

* Clean up imports

* don't run valgrind if not specified slow_test

* Fix functest after initializer rename

* upload tests results as junit

* Upload test-common files since #200 got merged

* Catch test results upload failure
2019-07-29 10:38:25 +02:00

52 lines
1.2 KiB
Python

import os
import unittest
from glob import glob
import pytest
import helpers
import pqclean
additional_flags = []
@pytest.mark.parametrize(
'implementation',
pqclean.Scheme.all_implementations(),
ids=str,
)
@helpers.skip_windows()
@helpers.filtered_test
def test_clang_tidy(implementation: pqclean.Implementation):
helpers.ensure_available('clang-tidy')
cfiles = implementation.cfiles()
common_files = glob(os.path.join('..', 'common', '*.c'))
(returncode, _) = helpers.run_subprocess(
['clang-tidy',
'-quiet',
'-header-filter=.*',
*additional_flags,
*cfiles,
*common_files,
'--',
'-iquote', os.path.join('..', 'common'),
'-iquote', implementation.path()],
expected_returncode=None,
)
# Detect and gracefully avoid segfaults
if returncode == -11:
raise unittest.SkipTest("clang-tidy segfaulted")
assert returncode == 0, "Clang-tidy returned %d" % returncode
if __name__ == "__main__":
import sys
# allow a user to specify --fix-errors, to immediately fix errors
if len(sys.argv) >= 2 and sys.argv[1] == '-fix-errors':
additional_flags = ['-fix-errors']
del sys.argv[1]
pytest.main(sys.argv)