clojure.main always exits with code 0

431 views
Skip to first unread message

John D. Hume

unread,
Apr 5, 2009, 8:15:55 PM4/5/09
to clo...@googlegroups.com
Earlier today I was surprised to notice that some test-is unit tests I
was running from Ant failed, but it still reported BUILD SUCCESSFUL. I
figured I'd forgotten to include failonerror="true" in the java task,
but it was there. So I played around and found that

$ java -cp clojure.jar clojure.main -e "garbage"
java.lang.Exception: Unable to resolve symbol: garbage in this context
(NO_SOURCE_FILE:0)
at clojure.lang.Compiler.analyze(Compiler.java:4330)
.......etc
$ echo $?
0

Likewise with a script. This seems like a bug. Would it be acceptable
to change clojure.main/main as follows?

Currently it does this:
(try
.... the good stuff ...
(catch Exception e
(.printStackTrace e *err*)))
(flush))

Instead I'd like it to:
(try
.... the good stuff ...
(flush)
(catch Exception e
(flush)
(throw e)))

Basically just let Java do what Java does when an unhandled exception
is thrown (after flushing *out* to keep from confusing people). I know
a lot of what's in clojure.main is meant to be useful for embedding in
larger programs, but it doesn't look to me like the main function is
intended for that.

Thanks.
-hume.
--
http://elhumidor.blogspot.com/

Tom Faulhaber

unread,
Apr 8, 2009, 2:28:56 PM4/8/09
to Clojure
I'd like to second this request. It's pretty necessary to have an exit
code for any type of scripting.

Of course, you can always use (System/exit result-code), but a return
value is "prettier" to me.

abe...@wcnet.org

unread,
Apr 9, 2009, 10:13:58 AM4/9/09
to clo...@googlegroups.com
I have experienced this as well. My problem is that I would like my test suite to exit
the proper way
so that CI knows that the build actually failed. Currently test-is seems to just report
to stdout, but
not set anything that would cause the suite to fail with the proper exit code.

Any ideas?

Aaron

On Apr 8, 2009, at 2:28 PM, Tom Faulhaber wrote:


I'd like to second this request. It's pretty necessary to have an exit
code for any type of scripting.

Of course, you can always use (System/exit result-code), but a return
value is "prettier" to me.

---------------------------------------------
This message was sent using Endymion MailMan.
http://www.endymion.com/products/mailman/


John D. Hume

unread,
Apr 11, 2009, 6:13:52 PM4/11/09
to clo...@googlegroups.com
Rich,
Can I submit an issue and patch for this? I have a CA on file.

Thanks.
-hume.

On Sun, Apr 5, 2009 at 8:15 PM, John D. Hume <duelin....@gmail.com> wrote:
> Currently it does this:
>  (try
>   .... the good stuff ...
>   (catch Exception e
>     (.printStackTrace e *err*)))
>  (flush))
>
> Instead I'd like it to:
>  (try
>   .... the good stuff ...
>   (flush)
>   (catch Exception e
>     (flush)
>     (throw e)))
>
> Basically just let Java do what Java does when an unhandled exception
> is thrown (after flushing *out* to keep from confusing people). I know
> a lot of what's in clojure.main is meant to be useful for embedding in
> larger programs, but it doesn't look to me like the main function is
> intended for that.

--
http://elhumidor.blogspot.com/

Rich Hickey

unread,
Apr 12, 2009, 7:40:13 AM4/12/09
to Clojure


On Apr 11, 6:13 pm, "John D. Hume" <duelin.mark...@gmail.com> wrote:
> Rich,
> Can I submit an issue and patch for this? I have a CA on file.
>

Sure, thanks.

Rich

John D. Hume

unread,
Apr 12, 2009, 12:01:54 PM4/12/09
to clo...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages