Skip to content
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

Implement TAP (https://testanything.org/) #17

Merged
merged 4 commits into from
Jan 3, 2019
Merged

Implement TAP (https://testanything.org/) #17

merged 4 commits into from
Jan 3, 2019

Conversation

mity
Copy link
Owner

@mity mity commented Jan 3, 2019

Fixes #16.

mity added 2 commits January 3, 2019 10:15
Rationale: TAP shall likely be used only from scripts, so using long
option --tap is not an issue. And I want to have -t reserved for future
if we ever add some duration/time measuring feature.
@sandhose
Copy link

sandhose commented Jan 3, 2019

Thanks for this!

I think there is an issue with stdout not being flushed before forking. When I pipe the output, the plan (1..n) repeats itself for each test, making the output invalid.

> ./tests/main --tap # Works as expected
1..5
ok 1 - ast/new
ok 2 - quad/new
ok 3 - quad/list
ok 4 - symbol/memory
ok 5 - symbol/same_name
> ./tests/main --tap | cat -
1..5
ok 1 - ast/new
1..5
ok 2 - quad/new
1..5
ok 3 - quad/list
1..5
ok 4 - symbol/memory
1..5
ok 5 - symbol/same_name
1..5

Not sure if it is a macOS specific issue, but here's a patch that solves it:

diff --git a/include/acutest.h b/include/acutest.h
index dba6370..5cf26b8 100644
--- a/include/acutest.h
+++ b/include/acutest.h
@@ -1162,8 +1162,10 @@ main(int argc, char** argv)
         /* TAP harness should provide some summary. */
         test_no_summary__ = 1;
 
-        if(!test_worker__)
+        if(!test_worker__) {
             printf("1..%d\n", (int) test_count__);
+            fflush(stdout);
+        }
     }
 
     /* Run the tests */

@mity mity merged commit df68bcf into master Jan 3, 2019
@mity mity deleted the tap branch January 3, 2019 12:46
@mity
Copy link
Owner Author

mity commented Jan 3, 2019

Added the fflush() just before fork(), it's imho more robust.

Thanks for the testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants