Skip to content

Commit

Permalink
Fix mx native-image --help and add a gate check.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandar Gradinac committed Jan 28, 2020
1 parent a542dda commit 59c24c5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion substratevm/ci_includes/gate.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ builds += [
MAVEN_REPO_LOCAL : "$BUILD_DIR/.m2"
}
run: [
${svm-cmd-gate} ["build,helloworld,test,relocations,maven"]
${svm-cmd-gate} ["build,helloworld,test,relocations,maven,nativeimagehelp"]
]
}
${oraclejdk8} ${svm-common-linux-gate} ${eclipse} ${jdt} ${linux-deploy} {
Expand Down
24 changes: 21 additions & 3 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ def __getattr__(self, name):
'build',
'benchmarktest',
'truffletck',
'relocations'
'relocations',
"nativeimagehelp"
])


Expand Down Expand Up @@ -539,6 +540,22 @@ def procOutput(output):
else:
mx.log('Skipping relocations test. Reason: Only tested on Linux.')

with Task('Check mx native-image --help', tasks, tags=[GraalTags.nativeimagehelp]) as t:
if t:
mx.log('Running mx native-image --help output check.')
# This check works by scanning stdout for the 'Usage' keyword. If that keyword does not appear, it means something broke mx native-image --help.
def help_stdout_check(output):
if 'Usage' in output:
help_stdout_check.found_usage = True

help_stdout_check.found_usage = False
# mx native-image --help is definitely broken if a non zero code is returned.
mx.run(['mx', 'native-image', '--help'], out=help_stdout_check, nonZeroIsFatal=True)
if not help_stdout_check.found_usage:
mx.abort('mx native-image --help does not seem to output the proper message. This can happen if you add extra arguments the mx native-image call without checking if an argument was --help or --help-extra.')

mx.log('mx native-image --help output check detected no errors.')

with Task('JavaScript', tasks, tags=[GraalTags.js]) as t:
if t:
build_native_image_image(config=_graalvm_js_config())
Expand Down Expand Up @@ -1373,8 +1390,9 @@ def native_image_on_jvm(args, **kwargs):
if hasattr(cpEntry, "getJavaProperties"):
for key, value in cpEntry.getJavaProperties().items():
javaProperties[key] = value
for key, value in javaProperties.items():
args.append("-D" + key + "=" + value)
if not any(arg.startswith('--help') for arg in args):
for key, value in javaProperties.items():
args.append("-D" + key + "=" + value)

mx.run([executable, '-H:CLibraryPath=' + clibrary_libpath()] + args, **kwargs)

Expand Down

0 comments on commit 59c24c5

Please sign in to comment.