2019-03-01 10:44:22 +00:00
|
|
|
import os
|
|
|
|
from glob import glob
|
2019-04-06 12:57:35 +01:00
|
|
|
import sys
|
2019-03-01 10:44:22 +00:00
|
|
|
|
|
|
|
import pqclean
|
2019-04-10 22:03:02 +01:00
|
|
|
import helpers
|
2019-03-01 10:44:22 +00:00
|
|
|
|
2019-04-06 12:57:35 +01:00
|
|
|
additional_flags = []
|
|
|
|
|
2019-03-01 10:44:22 +00:00
|
|
|
|
|
|
|
def test_clang_tidy():
|
|
|
|
for scheme in pqclean.Scheme.all_schemes():
|
|
|
|
for implementation in scheme.implementations:
|
2019-04-10 22:03:02 +01:00
|
|
|
if helpers.permit_test('linter', implementation):
|
|
|
|
yield check_tidy, implementation
|
2019-03-01 10:44:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
def check_tidy(implementation: pqclean.Implementation):
|
2019-04-10 22:03:02 +01:00
|
|
|
helpers.ensure_available('clang-tidy')
|
2019-03-01 10:44:22 +00:00
|
|
|
cfiles = glob(os.path.join(implementation.path(), '*.c'))
|
|
|
|
common_files = glob(os.path.join('..', 'common', '*.c'))
|
2019-04-10 22:03:02 +01:00
|
|
|
helpers.run_subprocess(['clang-tidy',
|
2019-03-01 10:44:22 +00:00
|
|
|
'-quiet',
|
2019-04-06 12:57:35 +01:00
|
|
|
'-header-filter=.*'] +
|
|
|
|
additional_flags +
|
|
|
|
[*cfiles,
|
2019-03-01 10:44:22 +00:00
|
|
|
*common_files,
|
|
|
|
'--',
|
|
|
|
'-iquote', os.path.join('..', 'common'),
|
|
|
|
'-iquote', implementation.path(),
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2019-04-06 12:57:35 +01:00
|
|
|
# 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']
|
|
|
|
sys.argv = sys.argv[0:1] + sys.argv[2:]
|
2019-03-01 10:44:22 +00:00
|
|
|
try:
|
|
|
|
import nose2
|
|
|
|
nose2.main()
|
|
|
|
except ImportError:
|
|
|
|
import nose
|
|
|
|
nose.runmodule()
|