mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Make sure from-filenames intersect with names-file
When both names-file an from-names are defined we want to make sure the tests that from-filenames returns intersect with the test in the names file.
This commit is contained in:
parent
ed864ceb28
commit
25097f9933
1 changed files with 13 additions and 16 deletions
|
@ -193,7 +193,7 @@ class SaltTestingParser(optparse.OptionParser):
|
|||
'--name',
|
||||
dest='name',
|
||||
action='append',
|
||||
default=None,
|
||||
default=[],
|
||||
help=('Specific test name to run. A named test is the module path '
|
||||
'relative to the tests directory')
|
||||
)
|
||||
|
@ -449,27 +449,23 @@ class SaltTestingParser(optparse.OptionParser):
|
|||
def parse_args(self, args=None, values=None):
|
||||
self.options, self.args = optparse.OptionParser.parse_args(self, args, values)
|
||||
|
||||
file_names = []
|
||||
if self.options.names_file:
|
||||
with open(self.options.names_file, 'rb') as fp_: # pylint: disable=resource-leakage
|
||||
lines = []
|
||||
for line in fp_.readlines():
|
||||
if six.PY2:
|
||||
lines.append(line.strip())
|
||||
file_names.append(line.strip())
|
||||
else:
|
||||
lines.append(
|
||||
file_names.append(
|
||||
line.decode(__salt_system_encoding__).strip())
|
||||
if self.options.name:
|
||||
self.options.name.extend(lines)
|
||||
else:
|
||||
self.options.name = lines
|
||||
|
||||
if self.args:
|
||||
if not self.options.name:
|
||||
self.options.name = []
|
||||
for fpath in self.args:
|
||||
if os.path.isfile(fpath) and \
|
||||
fpath.endswith('.py') and \
|
||||
os.path.basename(fpath).startswith('test_'):
|
||||
self.options.name.append(fpath)
|
||||
if fpath in file_names:
|
||||
self.options.name.append(fpath)
|
||||
continue
|
||||
self.exit(status=1, msg='\'{}\' is not a valid test module'.format(fpath))
|
||||
|
||||
|
@ -483,11 +479,12 @@ class SaltTestingParser(optparse.OptionParser):
|
|||
'filename_map.yml'
|
||||
)
|
||||
|
||||
mapped_mods = self._map_files(self.options.from_filenames)
|
||||
if mapped_mods:
|
||||
if self.options.name is None:
|
||||
self.options.name = []
|
||||
self.options.name.extend(mapped_mods)
|
||||
self.options.name.extend(self._map_files(self.options.from_filenames))
|
||||
|
||||
if self.options.name and file_names:
|
||||
self.options.name = list(set(self.options.name).intersection(file_names))
|
||||
elif file_names:
|
||||
self.options.name = file_names
|
||||
|
||||
print_header(u'', inline=True, width=self.options.output_columns)
|
||||
self.pre_execution_cleanup()
|
||||
|
|
Loading…
Add table
Reference in a new issue