1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Generate test script to file instead of stdout.

This commit is contained in:
Matt Clay 2016-08-11 15:42:43 -07:00
parent 2b0d63b0d8
commit 901042f458

View file

@ -63,6 +63,8 @@ def main():
help='platform to run tests on')
parser.add_argument('--version', dest='version', default=os.environ.get('VERSION'),
help='version of platform to run tests on')
parser.add_argument('--output', dest='output', required=True,
help='path to write output script to')
args = parser.parse_args()
@ -80,16 +82,17 @@ def main():
else:
raise Exception('job parameters not specified')
generate_test_commands(args.module_group, targets, script, jobs=jobs, verbose=args.verbose, changes=args.changes)
generate_test_commands(args.module_group, targets, script, args.output, jobs=jobs, verbose=args.verbose, changes=args.changes)
def generate_test_commands(module_group, targets, script, jobs=None, verbose=False, changes=None):
def generate_test_commands(module_group, targets, script, output, jobs=None, verbose=False, changes=None):
"""Generate test commands for the given module group and test targets.
Args:
module_group: The module group (core, extras) to examine.
targets: The test targets to examine.
script: The script used to execute the test targets.
output: The path to write the output script to.
jobs: The test jobs to execute, or None to auto-detect.
verbose: True to write detailed output to stderr.
changes: Path to file containing list of changed files, or None to query git.
@ -153,8 +156,9 @@ def generate_test_commands(module_group, targets, script, jobs=None, verbose=Fal
commands = ['TARGET="%s" TEST_FLAGS="-t %s" %s %s' % (target, tags, j, script_path) for j in jobs]
for command in commands:
print(command)
with open(output, 'w') as f:
f.writelines(commands)
f.write('\n')
def print_stderr(*args, **kwargs):