Skip to content
Snippets Groups Projects
Commit 6024776b authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[ci][makeyml] use multiline command

For a large number of tests, the resulting .yml could not be interpreted 
by the GitLab ci
parent fd904f8a
No related branches found
No related tags found
1 merge request!2408Feature/ci integration
...@@ -44,6 +44,17 @@ with open(args['outfile'], 'w') as ymlFile: ...@@ -44,6 +44,17 @@ with open(args['outfile'], 'w') as ymlFile:
commands = [commandIndentation + '- ' + comm for comm in commands] commands = [commandIndentation + '- ' + comm for comm in commands]
return '\n'.join(commands) return '\n'.join(commands)
def makeMultiLineCommand(commandParts):
# add indentation to each part
result = [commandIndentation + ' ' + cp for cp in commandParts]
# add line break token at the end of each part
result = ' \\\n'.join(result)
# add multiline trigger token at the beginning
return '|\n' + result
# if no configuration is given, build and run all tests # if no configuration is given, build and run all tests
if not args['testconfig']: if not args['testconfig']:
buildCommand = [duneConfigCommand, buildCommand = [duneConfigCommand,
...@@ -56,7 +67,7 @@ with open(args['outfile'], 'w') as ymlFile: ...@@ -56,7 +67,7 @@ with open(args['outfile'], 'w') as ymlFile:
with open(args['testconfig']) as configFile: with open(args['testconfig']) as configFile:
config = json.load(configFile) config = json.load(configFile)
testNames = config.keys() testNames = list(config.keys())
targetNames = [tc['target'] for tc in config.values()] targetNames = [tc['target'] for tc in config.values()]
if not targetNames: if not targetNames:
...@@ -74,10 +85,9 @@ with open(args['outfile'], 'w') as ymlFile: ...@@ -74,10 +85,9 @@ with open(args['outfile'], 'w') as ymlFile:
'rm -f TestMakefile && touch TestMakefile', 'rm -f TestMakefile && touch TestMakefile',
'echo "include CMakeFiles/Makefile2" >> TestMakefile', 'echo "include CMakeFiles/Makefile2" >> TestMakefile',
'echo "" >> TestMakefile', 'echo "" >> TestMakefile',
'|\n' makeMultiLineCommand(['echo "build_selected_tests:"']
+ commandIndentation + targetNames
+ ' echo "build_selected_tests: {}" >> TestMakefile' + ['>> TestMakefile']),
.format(' '.join(targetNames)),
'make -f TestMakefile -j4 build_selected_tests'] 'make -f TestMakefile -j4 build_selected_tests']
if not testNames: if not testNames:
...@@ -86,8 +96,10 @@ with open(args['outfile'], 'w') as ymlFile: ...@@ -86,8 +96,10 @@ with open(args['outfile'], 'w') as ymlFile:
'dune-ctest -R NOOP'] 'dune-ctest -R NOOP']
else: else:
testCommand = ['cd build-cmake', testCommand = ['cd build-cmake',
'dune-ctest -j4 --output-on-failure -R {}' makeMultiLineCommand(['dune-ctest -j4 '
.format(' '.join(testNames))] '--output-on-failure '
'-R']
+ testNames)]
substituteAndWrite({'build_script': makeScriptString(buildCommand), substituteAndWrite({'build_script': makeScriptString(buildCommand),
'test_script': makeScriptString(testCommand)}) 'test_script': makeScriptString(testCommand)})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment