Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 

55 рядки
1.4 KiB

  1. import os
  2. from glob import glob
  3. import sys
  4. import unittest
  5. import pqclean
  6. import helpers
  7. additional_flags = []
  8. def test_clang_tidy():
  9. for scheme in pqclean.Scheme.all_schemes():
  10. for implementation in scheme.implementations:
  11. yield check_tidy, implementation
  12. @helpers.filtered_test
  13. @helpers.skip_windows()
  14. def check_tidy(implementation: pqclean.Implementation):
  15. helpers.ensure_available('clang-tidy')
  16. cfiles = implementation.cfiles()
  17. common_files = glob(os.path.join('..', 'common', '*.c'))
  18. (returncode, _) = helpers.run_subprocess(
  19. ['clang-tidy',
  20. '-quiet',
  21. '-header-filter=.*',
  22. *additional_flags,
  23. *cfiles,
  24. *common_files,
  25. '--',
  26. '-iquote', os.path.join('..', 'common'),
  27. '-iquote', implementation.path()],
  28. expected_returncode=None,
  29. )
  30. # Detect and gracefully avoid segfaults
  31. if returncode == -11:
  32. raise unittest.SkipTest("clang-tidy segfaulted")
  33. else:
  34. assert returncode == 0, "Clang-tidy returned %d" % returncode
  35. if __name__ == "__main__":
  36. # allow a user to specify --fix-errors, to immediately fix errors
  37. if len(sys.argv) >= 2 and sys.argv[1] == '-fix-errors':
  38. additional_flags = ['-fix-errors']
  39. sys.argv = sys.argv[0:1] + sys.argv[2:]
  40. try:
  41. import nose2
  42. nose2.main()
  43. except ImportError:
  44. import nose
  45. nose.runmodule()