[Tests][Added] --list --no-names

This commit is contained in:
Salvador E. Tropea 2024-01-09 08:35:40 -03:00
parent 89d1721adf
commit c637dd50c6
2 changed files with 24 additions and 19 deletions

View File

@ -273,14 +273,19 @@ def test_auto_pcb_and_cfg_5(test_dir):
ctx.clean_up()
def test_list(test_dir):
def test_list_full(test_dir):
ctx = context.TestContext(test_dir, '3Rs', 'pre_and_position')
ctx.run(extra=['--list'], no_verbose=True, no_out_dir=True)
assert ctx.search_out('run_erc: True')
assert ctx.search_out('run_drc: True')
assert ctx.search_out('update_xml: True')
assert ctx.search_out(r'Pick and place file.? \(position\) \[position\]')
assert ctx.search_out(r'Pick and place file.? \(pos_ascii\) \[position\]')
ctx.search_out(['run_erc: True', 'run_drc: True', 'update_xml: True', r'Pick and place file.? \(position\) \[position\]',
r'Pick and place file.? \(pos_ascii\) \[position\]'])
ctx.clean_up()
def test_list_only_names(test_dir):
ctx = context.TestContext(test_dir, '3Rs', 'pre_and_position')
ctx.run(extra=['--list', '--only-names'], no_verbose=True, no_out_dir=True)
ctx.search_out(['position', 'pos_ascii'])
ctx.search_out('Pick and place file', invert=True)
ctx.clean_up()

View File

@ -444,34 +444,34 @@ class TestContext(object):
else:
del os.environ['LANG']
def search_out(self, text):
m = re.search(text, self.out, re.MULTILINE)
assert m is not None, text
logging.debug('output match: `{}` OK'.format(text))
return m
def search_err(self, text, invert=False):
def _search_txt(self, text, msgs, where, invert=False):
if isinstance(text, list):
res = []
for t in text:
m = re.search(t, self.err, re.MULTILINE)
m = re.search(t, msgs, re.MULTILINE)
if invert:
assert m is None, t
logging.debug('error no match: `{}` OK'.format(t))
logging.debug(f'{where} no match: `{t}` OK')
else:
assert m is not None, t
logging.debug('error match: `{}` (`{}`) OK'.format(t, m.group(0)))
logging.debug(f'{where} match: `{t}` (`{m.group(0)}`) OK')
res.append(m)
return res
m = re.search(text, self.err, re.MULTILINE)
m = re.search(text, msgs, re.MULTILINE)
if invert:
assert m is None, text
logging.debug('error no match: `{}` OK'.format(text))
logging.debug(f'{where} no match: `{text}` OK')
else:
assert m is not None, text
logging.debug('error match: `{}` (`{}`) OK'.format(text, m.group(0)))
logging.debug(f'{where} match: `{text}` (`{m.group(0)}`) OK')
return m
def search_out(self, text, invert=False):
return self._search_txt(text, self.out, 'output', invert)
def search_err(self, text, invert=False):
return self._search_txt(text, self.err, 'error', invert)
def search_in_file(self, file, texts, sub=False):
logging.debug('Searching in "'+file+'" output')
with open(self.get_out_path(file, sub=sub)) as f: