def run(self):
''' run command '''
if self.roles is not None:
print("Roles:\n{0}".format(yaml.dump(self.roles, default_flow_style=False)))
if self.excludes is not None:
print("Excludes:\n{0}".format(yaml.dump(self.excludes, default_flow_style=False)))
starting_dir = '.'
if self.roles is not None:
starting_dir = 'roles'
molecule_dirs = find_dirs(starting_dir, self.excludes, self.roles, 'molecule')
print("Found:\n{0}".format(yaml.dump(molecule_dirs, default_flow_style=False)))
base_dir = os.getcwd()
errors = ""
warnings = ""
for role in molecule_dirs:
role = os.path.dirname(role)
print("Testing: {0}".format(role))
os.chdir(role)
try:
print(sh.molecule.test())
except ErrorReturnCode as e:
print(e.stdout)
errors += e.stdout
os.chdir(base_dir)
if len(warnings) > 0:
print("Warnings:\n{0}\n".format(warnings))
if len(errors) > 0:
print("Errors:\n{0}\n".format(errors))
sys.exit(1)
评论列表
文章目录