-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
lib/tinytest: fix result not printed on newline #5414
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
Do you have a pointer to the code that does this? I don't see any problem with the output as it currently is. Eg excerpt from
|
I've been using MicroPython's copy of tinytest with custom code that is integrated with MicroPython. Since MicroPython tests use printf with trailing newlines instead of tinytest macros, the problem probably isn't really a problem with anything currently in MicroPython itself. So, this change will probably cause an empty line before |
Hmm, that might make it mildly confusing because it will group the result of one test (this OK line) with the output of the next test (the following lines which are not separated by a blank line).
How did the output look for "normal use" of tinytest before that commit? |
Example code: #include <tinytest.h>
#include <tinytest_macros.h>
static void test1(void *env) {
tt_fail_msg("didn't work");
}
static struct testcase_t example_tests[] = {
{ "test1", test1, 0, NULL, NULL },
END_OF_TESTCASES
};
static struct testgroup_t test_groups[] = {
{ "example/", example_tests },
END_OF_GROUPS
};
int main(int argc, const char **argv) {
return tinytest_main(argc, argv, test_groups);
} Output before f4ed2df:
Output after f4ed2df:
Output with this PR:
I think the fact that it always mentions the test name (e.g. |
Ok, thanks for the further info. One option would be to revert the changes made in f4ed2df to keep tinytest as-is (and work as it was originally designed), then modify the MicroPython-tinytest interface code to just print out a bit of extra info, eg: --- a/tools/tinytest-codegen.py
+++ b/tools/tinytest-codegen.py
@@ -33,8 +33,10 @@ test_function = (
"void {name}(void* data) {{\n"
" static const char pystr[] = {script};\n"
" static const char exp[] = {output};\n"
+ ' printf("\\n");\n'
" upytest_set_expected_output(exp, sizeof(exp) - 1);\n"
" upytest_execute_test(pystr);\n"
+ ' printf("result: ");\n'
"}}"
) |
…ut output." This reverts commit f4ed2df. An alternate solution will be implemented in a future commit.
I have update the PR with your suggestion. The effects of the changes on I tested locally with the qemu-arm port and tests pass. Also, this should not break Current:
Proposed:
|
Thanks for updating and for the tests. Looks good now. Merged in fd0ba7b |
This replaces supervisor.enable_autoreload() and supervisor.disable_autoreload(). It also allows user code to get the current autoreload state. Replaces micropython#5352 and part of micropython#5414
This replaces supervisor.enable_autoreload() and supervisor.disable_autoreload(). It also allows user code to get the current autoreload state. Replaces micropython#5352 and part of micropython#5414
When a test prints output during a test, it does so by adding a newline to the beginning of the line, rather than the end. So we need to do the same when printing the final result of the test, otherwise it ends up being appended to the end of the last message, which makes it hard to read.
Fixes: f4ed2df