瀏覽代碼

Filter tests when diff'ing against master branch (#103)

tags/v0.0.1
Douglas Stebila 5 年之前
committed by GitHub
父節點
當前提交
d07e8ae7cb
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 2 個檔案被更改,包括 36 行新增1 行删除
  1. +35
    -0
      test/helpers.py
  2. +1
    -1
      test/pqclean.py

+ 35
- 0
test/helpers.py 查看文件

@@ -132,4 +132,39 @@ def permit_test(testname, thing, **args):
if scheme.name.lower() in os.environ['PQCLEAN_SKIP_SCHEMES'].lower().split(','):
return False

if 'PQCLEAN_ONLY_DIFF' in os.environ:
if shutil.which('git') != None:
# if we're on a non-master branch, and the only changes are in schemes,
# only run tests on those schemes
branch_result = subprocess.run(
['git', 'status', '--porcelain=2', '--branch'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
# ensure we're in a working directory
if branch_result.returncode != 0:
return True
# ensure we're not on master branch
for branch_line in branch_result.stdout.decode('utf-8').splitlines():
tokens = branch_line.split(' ')
if tokens[0] == '#' and tokens[1] == 'branch.head':
if tokens[2] == 'master':
return True
# where are there changes?
diff_result = subprocess.run(
['git', 'diff', '--name-only', 'master'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
assert(diff_result.returncode == 0), "Got unexpected return code {}".format(diff_result.returncode)
for diff_line in diff_result.stdout.decode('utf-8').splitlines():
# don't skip test if there are any changes outside schemes
if not(diff_line.startswith('crypto_kem')) and not (diff_line.startswith('crypto_sign')):
return True
# do test if the scheme in question has been changed
if diff_line.startswith(thing.path(base='')):
return True
# there were no changes outside schemes, and the scheme in question had no diffs
return False

return True

+ 1
- 1
test/pqclean.py 查看文件

@@ -77,7 +77,7 @@ class Implementation:
return i

def path(self, base='..') -> str:
return os.path.join(self.scheme.path(), self.name)
return os.path.join(self.scheme.path(base=base), self.name)

def libname(self) -> str:
if os.name == 'nt':


Loading…
取消
儲存