test.ListCmd: Append environment time stamp to output files

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2023-01-02 15:50:39 +01:00
commit 745dfa2737

View file

@ -276,7 +276,7 @@ class ListCmd(TestCase): # export
raise Exception('Failed to compile regex ({}): >{}<'.format(e, str(re_str))) raise Exception('Failed to compile regex ({}): >{}<'.format(e, str(re_str)))
return list(filter(None, [parse_line(l, fields) for l in lines])) return list(filter(None, [parse_line(l, fields) for l in lines]))
def _eval(self, output, features, header=None): def _eval(self, output, features, header=None, tstamp=None):
def format_rows(rows, quotes=False): def format_rows(rows, quotes=False):
#def cmp(r1, r2): #def cmp(r1, r2):
@ -361,6 +361,8 @@ class ListCmd(TestCase): # export
feature_diff = set(features) - last_features feature_diff = set(features) - last_features
if self.__write_response and len(feature_diff): if self.__write_response and len(feature_diff):
response_path = self.refpath[0] + '.bad' response_path = self.refpath[0] + '.bad'
if tstamp is not None:
response_path += '-' + tstamp
feature_diff_str = ', '.join(['"{}"'.format(f) for f in feature_diff]) feature_diff_str = ', '.join(['"{}"'.format(f) for f in feature_diff])
with open(response_path, "w") as f: with open(response_path, "w") as f:
slog(INFO, 'Writing feature diff to "{}"'.format(response_path)) slog(INFO, 'Writing feature diff to "{}"'.format(response_path))
@ -388,7 +390,7 @@ class ListCmd(TestCase): # export
else: else:
header = '# ' + cmd + '\n' header = '# ' + cmd + '\n'
header += '# features: {}\n'.format(' '.join(env.features)) header += '# features: {}\n'.format(' '.join(env.features))
return self._eval(output, env.features, header=header) return self._eval(output, env.features, header=header, tstamp=env.time_stamp)
def dump(self, prio, *args, **kwargs): def dump(self, prio, *args, **kwargs):
caller = kwargs['caller'] if 'caller' in kwargs.keys() else get_caller_pos(1) caller = kwargs['caller'] if 'caller' in kwargs.keys() else get_caller_pos(1)