Преглед на файлове

Merge pull request #60 from PQClean/format-check-in-python

Add formatting tests to the python-based testing framework.
tags/v0.0.1
Matthias J. Kannwischer преди 5 години
committed by GitHub
родител
ревизия
7a36262f6a
No known key found for this signature in database GPG ключ ID: 4AEE18F83AFDEB23
променени са 4 файла, в които са добавени 41 реда и са изтрити 9 реда
  1. +5
    -0
      .travis.yml
  2. +0
    -9
      Makefile
  3. +6
    -0
      test/pqclean.py
  4. +30
    -0
      test/test_format.py

+ 5
- 0
.travis.yml Целия файл

@@ -8,6 +8,10 @@ matrix:
- pip3 install -r requirements.txt
script:
- "cd test && python3 -m nose --rednose --verbose"
addons:
homebrew:
packages:
- astyle
- name: "MacOS + GCC8"
os: osx
osx_image: xcode10.1
@@ -15,6 +19,7 @@ matrix:
addons:
homebrew:
packages:
- astyle
- gcc@8
before_install:
- pip3 install -r requirements.txt


+ 0
- 9
Makefile Целия файл

@@ -13,14 +13,6 @@ endif
clean:
rm -rf bin

.PHONY: format
format:
astyle --project crypto_*/*/*/*.[ch] common/*.[ch]

.PHONY: check-format
check-format:
astyle --dry-run --project crypto_*/*/*/*.[ch] common/*.[ch] | grep Formatted && exit 1 || exit 0

.PHONY: tidy
tidy:
$(MAKE) do-tidy
@@ -40,7 +32,6 @@ apply-tidy:
.PHONY: help
help:
@echo "make clean Clean up the bin/ folder"
@echo "make format Automatically formats all the source code"
@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"


+ 6
- 0
test/pqclean.py Целия файл

@@ -92,6 +92,12 @@ class Implementation:
return '{}{}_'.format(self.scheme.namespace_prefix(),
self.name.upper()).replace('-', '')

def __str__(self):
return "{} implementation of {}".format(self.name, self.scheme.name)

def __repr__(self):
return "<Implementation({}, {})>".format(self.name, self.scheme.name)


class KEM(Scheme):



+ 30
- 0
test/test_format.py Целия файл

@@ -0,0 +1,30 @@
import os
from glob import glob

import pqclean
from helpers import run_subprocess


def test_formatting():
for scheme in pqclean.Scheme.all_schemes():
for implementation in scheme.implementations:
yield check_format, implementation


def check_format(implementation: pqclean.Implementation):
cfiles = glob(os.path.join(implementation.path(), '*.c'))
hfiles = glob(os.path.join(implementation.path(), '*.h'))
run_subprocess(['astyle',
'--dry-run',
'--options=../.astylerc',
*cfiles,
*hfiles])


if __name__ == "__main__":
try:
import nose2
nose2.main()
except ImportError:
import nose
nose.runmodule()

Зареждане…
Отказ
Запис