Wrote in the missing functionality to the new testlist.py.
This commit is contained in:
parent
cfc4b60ea1
commit
f95c87dc96
|
@ -47,6 +47,15 @@ class listCommand:
|
||||||
print('Test' + x)
|
print('Test' + x)
|
||||||
command.register(listCommand)
|
command.register(listCommand)
|
||||||
|
|
||||||
|
headerHeader = '''// Generated by testlist.py; do not edit
|
||||||
|
struct testingprivCase {
|
||||||
|
const char *name;
|
||||||
|
void (*f)(void);
|
||||||
|
};
|
||||||
|
extern const struct testingprivCase testingprivCases[];
|
||||||
|
extern const size_t testingprivNumCases;'''
|
||||||
|
headerEntryFmt = 'extern void testingprivImplName(Test{})(void);'
|
||||||
|
|
||||||
class headerCommand:
|
class headerCommand:
|
||||||
filename = None
|
filename = None
|
||||||
|
|
||||||
|
@ -66,13 +75,49 @@ class headerCommand:
|
||||||
return args[1:]
|
return args[1:]
|
||||||
|
|
||||||
def run(self, casenames):
|
def run(self, casenames):
|
||||||
# TODO
|
with open(self.filename, 'wt') as f:
|
||||||
raise NotImplementedError
|
print(headerHeader, file = f)
|
||||||
|
for x in casenames:
|
||||||
|
print(headerEntryFmt.format(x), file = f)
|
||||||
command.register(headerCommand)
|
command.register(headerCommand)
|
||||||
|
|
||||||
|
sourceHeader = '''// Generated by testlist.py; do not edit
|
||||||
|
#include "test.h"
|
||||||
|
const struct testingprivCase testingprivCases[] = {'''
|
||||||
|
sourceEntryFmt = ' {{ "Test{0}", testingprivImplName(Test{0}) }},'
|
||||||
|
sourceFooter = '''}};
|
||||||
|
const size_t testingprivNumCases = {};'''
|
||||||
|
|
||||||
|
class sourceCommand:
|
||||||
|
filename = None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def name(cls):
|
||||||
|
return 'source'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def usageString(cls):
|
||||||
|
return 'source source-file [source-files...]'
|
||||||
|
|
||||||
|
def processArgs(self, args):
|
||||||
|
if len(args) < 1:
|
||||||
|
errf('error: output filename missing')
|
||||||
|
return None
|
||||||
|
self.filename = args[0]
|
||||||
|
return args[1:]
|
||||||
|
|
||||||
|
def run(self, casenames):
|
||||||
|
with open(self.filename, 'wt') as f:
|
||||||
|
print(sourceHeader, file = f)
|
||||||
|
for x in casenames:
|
||||||
|
print(sourceEntryFmt.format(x), file = f)
|
||||||
|
print(sourceFooter.format(len(casenames)), file = f)
|
||||||
|
command.register(sourceCommand)
|
||||||
|
|
||||||
commands = [
|
commands = [
|
||||||
listCommand,
|
listCommand,
|
||||||
headerCommand,
|
headerCommand,
|
||||||
|
sourceCommand,
|
||||||
]
|
]
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
|
@ -96,7 +141,7 @@ def main():
|
||||||
cmdtype = cmd
|
cmdtype = cmd
|
||||||
break
|
break
|
||||||
if cmdtype is None:
|
if cmdtype is None:
|
||||||
errf('error: unknown command {}', cmdname)
|
errf('error: unknown command {!r}', cmdname)
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
cmd = cmdtype()
|
cmd = cmdtype()
|
||||||
|
@ -109,6 +154,6 @@ def main():
|
||||||
match = r.match(line)
|
match = r.match(line)
|
||||||
if match is not None:
|
if match is not None:
|
||||||
casenames.append(match.group(1))
|
casenames.append(match.group(1))
|
||||||
cmd.run(casenames)
|
cmd.run(sorted(casenames))
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue