Merge commit 'f1087e81ecdca5a59ba5ffca684c955c5b38f7c2' as 'third_party/unordered_dense'
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from glob import glob
|
||||
from pathlib import Path
|
||||
from subprocess import run
|
||||
from os import path
|
||||
from time import time
|
||||
|
||||
|
||||
time_start = time()
|
||||
|
||||
exit_code = 0
|
||||
num_linters = 0
|
||||
mod_path = Path(__file__).parent
|
||||
for lint in glob(f"{mod_path}/lint-*"):
|
||||
lint = path.abspath(lint)
|
||||
if lint == path.abspath(__file__):
|
||||
continue
|
||||
|
||||
num_linters += 1
|
||||
result = run([lint])
|
||||
if result.returncode == 0:
|
||||
continue
|
||||
|
||||
print(f"^---- failure from {lint.split('/')[-1]}")
|
||||
exit_code |= result.returncode
|
||||
|
||||
time_end = time()
|
||||
print(f"{num_linters} linters in {time_end - time_start:0.2}s")
|
||||
exit(exit_code)
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from glob import glob
|
||||
from pathlib import Path
|
||||
from subprocess import run
|
||||
from os import path
|
||||
import subprocess
|
||||
import sys
|
||||
from time import time
|
||||
import re
|
||||
|
||||
root_path = path.abspath(Path(__file__).parent.parent.parent)
|
||||
|
||||
globs = [
|
||||
f"{root_path}/include/**/*.h",
|
||||
f"{root_path}/test/**/*.h",
|
||||
f"{root_path}/test/**/*.cpp",
|
||||
]
|
||||
exclusions = [
|
||||
"nanobench\\.h",
|
||||
"FuzzedDataProvider\\.h",
|
||||
'/third-party/']
|
||||
|
||||
files = []
|
||||
for g in globs:
|
||||
r = glob(g, recursive=True)
|
||||
files.extend(r)
|
||||
|
||||
# filter out exclusions
|
||||
for exclusion in exclusions:
|
||||
l = filter(lambda file: re.search(exclusion, file) == None, files)
|
||||
files = list(l)
|
||||
|
||||
if len(files) == 0:
|
||||
print("could not find any files!")
|
||||
sys.exit(1)
|
||||
|
||||
command = ['clang-format', '--dry-run', '-Werror'] + files
|
||||
p = subprocess.Popen(command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=None,
|
||||
stdin=subprocess.PIPE,
|
||||
universal_newlines=True)
|
||||
|
||||
stdout, stderr = p.communicate()
|
||||
|
||||
print(f"clang-format checked {len(files)} files")
|
||||
|
||||
if p.returncode != 0:
|
||||
sys.exit(p.returncode)
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
|
||||
|
||||
root = os.path.abspath(pathlib.Path(__file__).parent.parent.parent)
|
||||
|
||||
# filename, pattern, number of occurrences
|
||||
file_pattern_count = [
|
||||
(
|
||||
f"{root}/meson.build",
|
||||
r"version: '(\d+)\.(\d+)\.(\d+)'",
|
||||
1),
|
||||
(
|
||||
f"{root}/include/ankerl/unordered_dense.h",
|
||||
r"Version (\d+)\.(\d+)\.(\d+)\n",
|
||||
1),
|
||||
(
|
||||
f"{root}/CMakeLists.txt",
|
||||
r"^\s+VERSION (\d+)\.(\d+)\.(\d+)\n",
|
||||
1),
|
||||
(
|
||||
f"{root}/test/unit/namespace.cpp",
|
||||
r"unordered_dense::v(\d+)_(\d+)_(\d+)",
|
||||
1
|
||||
)
|
||||
]
|
||||
|
||||
# let's parse the reference from svector.h
|
||||
major = "??"
|
||||
minor = "??"
|
||||
patch = "??"
|
||||
with open(f"{root}/include/ankerl/unordered_dense.h", "r") as f:
|
||||
for line in f:
|
||||
r = re.search(r"#define ANKERL_UNORDERED_DENSE_VERSION_([A-Z]+) (\d+)", line)
|
||||
if not r:
|
||||
continue
|
||||
|
||||
if "MAJOR" == r.group(1):
|
||||
major = r.group(2)
|
||||
elif "MINOR" == r.group(1):
|
||||
minor = r.group(2)
|
||||
elif "PATCH" == r.group(1):
|
||||
patch = r.group(2)
|
||||
else:
|
||||
"match but with something else!"
|
||||
exit(1)
|
||||
|
||||
is_ok = True
|
||||
for (filename, pattern, count) in file_pattern_count:
|
||||
num_found = 0
|
||||
with open(filename, "r") as f:
|
||||
for line in f:
|
||||
r = re.search(pattern, line)
|
||||
if r:
|
||||
num_found += 1
|
||||
if major != r.group(1) or minor != r.group(2) or patch != r.group(3):
|
||||
is_ok = False
|
||||
print(f"ERROR in {filename}: got '{line.strip()}' but version should be '{major}.{minor}.{patch}'")
|
||||
if num_found != count:
|
||||
is_ok = False
|
||||
print(f"ERROR in {filename}: expected {count} occurrences but found it {num_found} times")
|
||||
|
||||
if not is_ok:
|
||||
exit(1)
|
||||
|
||||
Reference in New Issue
Block a user