-
Notifications
You must be signed in to change notification settings - Fork 3k
TEST: update python script to enable examples smoke test #10521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@jamesbeyond, thank you for your changes. |
* it will check examples.json if contains 'test', 'compare_log', 'baud_rate' keys * it will dump test_spec.json test in examples compiled successfully
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this all seems pretty reasonable! I have a few suggestions below,
tools/test/examples/examples_lib.py
Outdated
"""save the given json data to test_spec.json""" | ||
print ("Dumping json test_specs file {}".format(name)) | ||
with open(name, 'w') as outfile: | ||
json.dump(json_spec, outfile , indent=4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we have an existing function that you can use: https://github.com/ARMmbed/mbed-os/blob/master/tools/utils.py#L184
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review, all your comments been addressed
tools/test/examples/examples_lib.py
Outdated
if image: | ||
image_info = [{"binary_type": "bootable","path": normpath(join(name,image)),"compare_log":log}] | ||
else: | ||
print ("Warning: could not found built image for example %s" % name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit pick on the wording of the warning:
print ("Warning: could not found built image for example %s" % name) | |
print ("Warning: could not find built image for example %s" % name) |
print ("\n#### STDOUT ####\n%s\n#### STDERR ####\n%s\n#### End of STDOUT/STDERR ####\n" % (std_out,std_err)) | ||
|
||
if test_example: | ||
log = example['compare_log'].pop(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason this needs to be a pop
vs the following:
log = example['compare_log'].pop(0) | |
log = example['compare_log'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here pop()
is used because the value of compare_log
will be a list of logs files.
The reason for that is because some of the example repos contains more than one example, e.g. the mbed-os-example-tls
and mbed-os-example-ble
. So the each log file need to match with
the individual sub-example. So we need to pop the file out of list regardless the compilation for each sub-example pass of fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I request that this comment is added to the code please.
tools/test/examples/examples_lib.py
Outdated
test_json['builds'][test_group]['tests'][name]={"binaries":image_info} | ||
else: | ||
print("Warning: Test for %s will not be generated." % name) | ||
print("One or more of 'test' 'baud_rate' and 'compare_log' keys are missing from the json file\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit pick on wording, missing some commas:
print("One or more of 'test' 'baud_rate' and 'compare_log' keys are missing from the json file\n") | |
print("One or more of 'test', 'baud_rate', and 'compare_log' keys are missing from the example config json file\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides above suggestions, LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need documenting at least
tools/test/examples/examples_lib.py
Outdated
@@ -380,31 +382,60 @@ def compile_repos(config, toolchains, targets, profile, verbose, examples): | |||
successes = [] | |||
compiled = True | |||
pass_status = True | |||
if example.has_key('test') and example.has_key('baud_rate') and example.has_key('compare_log'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true for this kind of json object:
{
"name": "Something",
"test": False,
"baund_rate": "invalid",
"compare_log": null
}
Why it need to have "test" key even if the value is not documented or does not even matter?
These values really need to be documented. Actually same problem with whole examples.json. @adbridge do you know any documentation for that json file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No not that i am aware of....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, the test
key is just a on/off switch. similar to the compile
key, just following the conventions.
It can be used, when we have the compare_log
and baud_rate
ready, but choose not run the test for some reasons. (e.g. the example requires some special HW, but that's not available on the RaaS, or there are some breaking change happening, we need to turn off tests for some examples temperately )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamesbeyond then the condition need to check the value of example['test'] alse. For example:
if example.has_key('test') and example['test'] and example.has_key('baud_rate') and example.has_key('compare_log'):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was checking that condition in later code, after reviewing, I think what you suggested would be more make scene. So this is fixed
all comments been addressed, please review again @bridadan @OPpuolitaival |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing my comments!
While waiting for final approvals, CI started |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
@OPpuolitaival @adbridge Happy with this? PRs to examples are slowly getting integrated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to use the logging module rather than print but I'm not going to block the PR on that. That could always be a downline improvement.
Yeah, I just following the original script that using the print. I agree logging module would be a better solution. I think we will consider the improvements in separate PR |
@mark-edgeworth are you happy with the comment? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's what I had in mind 👍
I think we got good level of reviews, can we have the CI start? @ARMmbed/mbed-os-maintainers |
CI started |
seems something wrong with checkout stage of the CI? @ARMmbed/mbed-os-maintainers |
Pipeline restarted. |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Description
The goal of this PR is to enable examples smoke test in CI
examples.json
if contains 'test', 'compare_log', 'baud_rate' keystest_spec.json
test in examples compiled successfullyThe auto generated
test_spec.json
can be consumed by GreenTea.This PR is related with ARMmbed/mbed-os-tools#162
examples.json
is not required to be changed at moment.later on when test cases in each example are ready, corresponding example then will need to be updated.
Pull request type
Reviewers
@OPpuolitaival