Exit code when run tests with cljs.test.

121 views
Skip to first unread message

Andrey Antukh

unread,
Feb 27, 2015, 3:18:28 PM2/27/15
to clojur...@googlegroups.com
Hi!

I'm not clearly understand how I can get the number of failed tests when run test with cljs.test and return proper exit-code.

I have previously experimented with run.js and with  :main option on cljs compiler. But in all cases i found the same behavior. 

I don't know a proper way for obtain a result after test are run for proper set nodejs process.exitCode property...

- The `run-tests` function does not returns any result.
- Passing custom env to `run-test` has same effect.
- I have tried set the env with binding (obviously, same effect)

I have read the documentation (the docstrings) but I do not find any relevant that can help me.

I'm currently have tests with cljs.test (sync and async) on varios apps running with nodejs and the only way to see if tests pases is viewing the output to the console. Without proper returncode when tests are failing travis (or any other service for tests) does not work properly.

Thanks!

Cheers.
Andrey

--

David Nolen

unread,
Feb 27, 2015, 3:31:48 PM2/27/15
to clojur...@googlegroups.com
You can supply your own reporter and instead of printing you can aggregate results.

David

--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to the Google Groups "ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojurescrip...@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Andrey Antukh

unread,
Feb 27, 2015, 5:37:20 PM2/27/15
to clojur...@googlegroups.com
Ok, will try it, thanks...

But, in any case, cljs.test does not support something like thas out of the box? Run tests with simply printing result in a console is not very useful :(

I don't know, but I think this is the first testing library that by default does not have easy way to check if all test passes or not. 
I'm missing something?

Having something like this would be awesome. Should be enough if cljs.test/run-tests true if all tests passes or  false in case contrary. Or something similar. 

Cheers.
Andrey

Andrey Antukh

unread,
Feb 28, 2015, 7:12:04 AM2/28/15
to Andrey Antukh, clojur...@googlegroups.com
I have just created cljs-testrunners package for solve it and not repeat the same code in all packages that need a return code properly set.


Maybe it can be useful to some one.

Cheers.
Andrey

Antonin Hildebrand

unread,
Feb 28, 2015, 9:15:23 AM2/28/15
to clojur...@googlegroups.com
Andrey, thank you for packaging it and sharing as a library.

Just for record, my solution for phantomjs-based test runner:

https://github.com/binaryage/cljs-devtools/blob/23a850807c7d8cb4c5030a943cbe15bd7db1ff86/test/runner.cljs#L15
https://github.com/binaryage/cljs-devtools/blob/23a850807c7d8cb4c5030a943cbe15bd7db1ff86/test/phantom.js#L24

By overriding one method via ::test/default I didn't have to provide all reporting methods.
Antonin

Andrey Antukh

unread,
Feb 28, 2015, 9:56:12 AM2/28/15
to clojur...@googlegroups.com
2015-02-28 15:15 GMT+01:00 Antonin Hildebrand <antonin.h...@gmail.com>:
Andrey, thank you for packaging it and sharing as a library.

Just for record, my solution for phantomjs-based test runner:

https://github.com/binaryage/cljs-devtools/blob/23a850807c7d8cb4c5030a943cbe15bd7db1ff86/test/runner.cljs#L15
https://github.com/binaryage/cljs-devtools/blob/23a850807c7d8cb4c5030a943cbe15bd7db1ff86/test/phantom.js#L24

By overriding one method via ::test/default I didn't have to provide all reporting methods.
Antonin

Oh, great! Thanks also for sharing!

I'll provide more reporting methods for change the console output to be more compact ;)

Cheers.
Andrey
Reply all
Reply to author
Forward
0 new messages