mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-11 04:17:15 +02:00
added list of tests
This commit is contained in:
@ -10,18 +10,18 @@ import re
|
||||
import subprocess
|
||||
|
||||
|
||||
def remove_comments(text):
|
||||
def replacer(match):
|
||||
s = match.group(0)
|
||||
if s.startswith('/'):
|
||||
return " " # note: a space and not an empty string
|
||||
else:
|
||||
return s
|
||||
pattern = re.compile(
|
||||
r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
|
||||
re.DOTALL | re.MULTILINE
|
||||
)
|
||||
return re.sub(pattern, replacer, text)
|
||||
# def remove_comments(text):
|
||||
# def replacer(match):
|
||||
# s = match.group(0)
|
||||
# if s.startswith('/'):
|
||||
# return " " # note: a space and not an empty string
|
||||
# else:
|
||||
# return s
|
||||
# pattern = re.compile(
|
||||
# r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
|
||||
# re.DOTALL | re.MULTILINE
|
||||
# )
|
||||
# return re.sub(pattern, replacer, text)
|
||||
|
||||
def extract_enums(lines):
|
||||
line_iter = iter(lines)
|
||||
|
62
python/scripts/list_tested_cmd.py
Normal file
62
python/scripts/list_tested_cmd.py
Normal file
@ -0,0 +1,62 @@
|
||||
import parse
|
||||
from pathlib import Path
|
||||
import os
|
||||
import locale
|
||||
import argparse
|
||||
path = Path('../../slsDetectorSoftware/tests/')
|
||||
import subprocess
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-s", "--startswith", help="for filter", type = str, default=None)
|
||||
args = parser.parse_args()
|
||||
|
||||
files = [f for f in os.listdir(path) if 'CmdProxy' in f]
|
||||
tested = []
|
||||
for fname in files:
|
||||
with open(path/fname) as f:
|
||||
data = f.read()
|
||||
|
||||
data = parse.remove_comments(data)
|
||||
data = data.splitlines()
|
||||
|
||||
|
||||
for line in data:
|
||||
if 'TEST_CASE' in line:
|
||||
cmd = line.split("\"")[1]
|
||||
print(cmd)
|
||||
tested.append(cmd)
|
||||
|
||||
out = subprocess.run(['g', 'list'], capture_output = True, encoding=locale.getpreferredencoding())
|
||||
all_cmd = out.stdout.splitlines()
|
||||
|
||||
if 'vrf' in all_cmd:
|
||||
print('HEY\n')
|
||||
|
||||
if args.startswith is not None:
|
||||
all_cmd = [cmd for cmd in all_cmd if cmd.startswith(args.startswith)]
|
||||
tested = [cmd for cmd in tested if cmd.startswith(args.startswith)]
|
||||
|
||||
|
||||
|
||||
not_tested = []
|
||||
misnamed = []
|
||||
for cmd in all_cmd:
|
||||
if cmd not in tested:
|
||||
not_tested.append(cmd)
|
||||
|
||||
for cmd in tested:
|
||||
if cmd not in all_cmd:
|
||||
misnamed.append(cmd)
|
||||
|
||||
print("\nThe following commands are tested:")
|
||||
for cmd in tested:
|
||||
print(cmd)
|
||||
|
||||
print("\nThe following commands are NOT tested:")
|
||||
for cmd in not_tested:
|
||||
print(cmd)
|
||||
|
||||
print(f"\nThe following {len(misnamed)} tests are misnamed and should be renamed:")
|
||||
for cmd in misnamed:
|
||||
print(cmd)
|
||||
print(f'\nTests cover {len(tested)} of {len(all_cmd)} commands')
|
13
python/scripts/parse.py
Normal file
13
python/scripts/parse.py
Normal file
@ -0,0 +1,13 @@
|
||||
import re
|
||||
def remove_comments(text):
|
||||
def replacer(match):
|
||||
s = match.group(0)
|
||||
if s.startswith('/'):
|
||||
return " " # note: a space and not an empty string
|
||||
else:
|
||||
return s
|
||||
pattern = re.compile(
|
||||
r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
|
||||
re.DOTALL | re.MULTILINE
|
||||
)
|
||||
return re.sub(pattern, replacer, text)
|
Reference in New Issue
Block a user