Move clang-tidy into python-based tests
This commit is contained in:
parent
7a36262f6a
commit
e8c4cf949b
52
Makefile
52
Makefile
@ -1,52 +0,0 @@
|
|||||||
ALL_SCHEMES=$(filter-out crypto_%.c, $(wildcard crypto_*/*))
|
|
||||||
|
|
||||||
default: help
|
|
||||||
|
|
||||||
.PHONY: require_scheme
|
|
||||||
require_scheme:
|
|
||||||
# assumes a SCHEME variable; e.g. make functest SCHEME=crypto_kem/kyber768
|
|
||||||
ifndef SCHEME
|
|
||||||
$(error The SCHEME variable is not set. Example: SCHEME=crypto_kem/kyber768)
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
rm -rf bin
|
|
||||||
|
|
||||||
.PHONY: tidy
|
|
||||||
tidy:
|
|
||||||
$(MAKE) do-tidy
|
|
||||||
|
|
||||||
do-tidy: require_scheme
|
|
||||||
clang-tidy \
|
|
||||||
-quiet $(.TIDY_FIX) \
|
|
||||||
$(SCHEME)/clean/*.c \
|
|
||||||
common/*.c \
|
|
||||||
-- -iquote "common/" -iquote "$(SCHEME)/clean"
|
|
||||||
|
|
||||||
.PHONY: apply-tidy
|
|
||||||
apply-tidy:
|
|
||||||
$(MAKE) do-tidy .TIDY_FIX=-fix
|
|
||||||
|
|
||||||
# The below should be outlined with ts=8
|
|
||||||
.PHONY: help
|
|
||||||
help:
|
|
||||||
@echo "make clean Clean up the bin/ folder"
|
|
||||||
@echo "make tidy SCHEME=scheme Runs the clang-tidy linter against SCHEME"
|
|
||||||
@echo "make apply-tidy SCHEME=scheme Tries to automatically fix the issues found by clang-tidy in SCHEME"
|
|
||||||
@echo "make tidy-all Runs the clang-tidy linter against all schemes"
|
|
||||||
@echo "make apply-tidy-all Tidy up all schemes"
|
|
||||||
@echo "make help Displays this message"
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: tidy-all
|
|
||||||
tidy-all:
|
|
||||||
@for scheme in $(ALL_SCHEMES); do \
|
|
||||||
$(MAKE) tidy SCHEME=$$scheme || exit 1 ; \
|
|
||||||
done
|
|
||||||
|
|
||||||
.PHONY: apply-tidy-all
|
|
||||||
apply-tidy-all:
|
|
||||||
@for scheme in $(ALL_SCHEMES); do \
|
|
||||||
$(MAKE) apply-tidy SCHEME=$$scheme; \
|
|
||||||
done
|
|
34
test/test_linter.py
Normal file
34
test/test_linter.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import os
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
|
import pqclean
|
||||||
|
from helpers import run_subprocess
|
||||||
|
|
||||||
|
|
||||||
|
def test_clang_tidy():
|
||||||
|
for scheme in pqclean.Scheme.all_schemes():
|
||||||
|
for implementation in scheme.implementations:
|
||||||
|
yield check_tidy, implementation
|
||||||
|
|
||||||
|
|
||||||
|
def check_tidy(implementation: pqclean.Implementation):
|
||||||
|
cfiles = glob(os.path.join(implementation.path(), '*.c'))
|
||||||
|
common_files = glob(os.path.join('..', 'common', '*.c'))
|
||||||
|
run_subprocess(['clang-tidy',
|
||||||
|
'-quiet',
|
||||||
|
'-header-filter=.*',
|
||||||
|
*cfiles,
|
||||||
|
*common_files,
|
||||||
|
'--',
|
||||||
|
'-iquote', os.path.join('..', 'common'),
|
||||||
|
'-iquote', implementation.path(),
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
try:
|
||||||
|
import nose2
|
||||||
|
nose2.main()
|
||||||
|
except ImportError:
|
||||||
|
import nose
|
||||||
|
nose.runmodule()
|
Loading…
Reference in New Issue
Block a user