find tests and commands

This commit is contained in:
Erik Frojdh 2020-03-03 11:04:05 +01:00
parent ecc3b36204
commit 75e083ae46
2 changed files with 19 additions and 13 deletions

View File

@ -4,10 +4,11 @@ out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.ge
cmd = out.stdout.splitlines() cmd = out.stdout.splitlines()
cmd.pop(0) cmd.pop(0)
from sls_detector import Detector, Eiger, Ctb from slsdet import Detector, Eiger, Ctb
pycmd = dir(Detector)+dir(Eiger)+dir(Ctb) pycmd = dir(Detector)+dir(Eiger)+dir(Ctb)
#Add commands that we should not expect as direct commands in python
pycmd += ['vrf', 'vtr', 'vrs', 'vtgstv', 'vsvn', 'vtrim', pycmd += ['vrf', 'vtr', 'vrs', 'vtgstv', 'vsvn', 'vtrim',
'vsvp', 'vth1', 'vth2', 'vth3', 'vshaper', 'vshaperneg', 'rxb_rb', 'vsvp', 'vth1', 'vth2', 'vth3', 'vshaper', 'vshaperneg', 'rxb_rb',
'rxb_lb', 'vref_prech', 'vref_rstore', 'vref_cds', 'rxb_lb', 'vref_prech', 'vref_rstore', 'vref_cds',

View File

@ -1,11 +1,19 @@
"""
Utility to find and list which command line functions have tests and
where the tests are located
"""
#local import for for parsing c++
import parse import parse
from pathlib import Path
#General python stuff
import os import os
import locale import locale
import argparse import argparse
path = Path('../../slsDetectorSoftware/tests/')
import subprocess import subprocess
from pathlib import Path
#Realative path from this dir
path = Path('../../slsDetectorSoftware/tests/')
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-s", "--startswith", help="for filter", type = str, default=None) parser.add_argument("-s", "--startswith", help="for filter", type = str, default=None)
args = parser.parse_args() args = parser.parse_args()
@ -15,15 +23,12 @@ tested = []
for fname in files: for fname in files:
with open(path/fname) as f: with open(path/fname) as f:
data = f.read() data = f.read()
data = parse.remove_comments(data) data = parse.remove_comments(data)
data = data.splitlines() data = data.splitlines()
for line in data: for line in data:
if 'TEST_CASE' in line or 'SECTION' in line: if 'TEST_CASE' in line or 'SECTION' in line:
cmd = line.split("\"")[1] cmd = line.split("\"")[1]
tested.append(cmd) tested.append([cmd, fname])
out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding()) out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding())
all_cmd = out.stdout.splitlines() all_cmd = out.stdout.splitlines()
@ -33,18 +38,18 @@ all_cmd.pop(0)
if args.startswith is not None: if args.startswith is not None:
all_cmd = [cmd for cmd in all_cmd if cmd.startswith(args.startswith)] all_cmd = [cmd for cmd in all_cmd if cmd.startswith(args.startswith)]
tested = [cmd for cmd in tested if cmd.startswith(args.startswith)] tested = [cmd for cmd in tested if cmd[0].startswith(args.startswith)]
tn = [cmd[0] for cmd in tested]
not_tested = [cmd for cmd in all_cmd if cmd not in tn]
not_tested = [cmd for cmd in all_cmd if cmd not in tested] misnamed = [cmd for cmd in tn if cmd not in all_cmd]
misnamed = [cmd for cmd in tested if cmd not in all_cmd] tested = [cmd for cmd in tested if cmd[0] in all_cmd]
tested = [cmd for cmd in tested if cmd in all_cmd]
print("\nThe following commands are tested:") print("\nThe following commands are tested:")
for cmd in tested: for cmd in tested:
print(cmd) print(f'{cmd[0]:>18} : {cmd[1]}')
print("\nThe following commands are NOT tested:") print("\nThe following commands are NOT tested:")
for cmd in not_tested: for cmd in not_tested: