running scalatests with sbt 0.9.10 prints some ugly characters

83 views
Skip to first unread message

David Craven

unread,
Jun 1, 2011, 8:43:53 AM6/1/11
to simple-build-tool
when running the test command in sbt 0.9.10 on windows 7 prints this:

C:\Users\dvc\workspace\booksApp>set SCRIPT_DIR=C:\sbt\

C:\Users\dvc\workspace\booksApp>java -Xmx512M -jar "C:\sbt\sbt-
launch.jar" test
[info] Set current project to default (in build file:/C:/Users/dvc/
workspace/foo/)
[info] Compiling 1 Scala source to C:\Users\dvc\workspace\foo\target
\scala-2.8.1.final\test-classes...
[info] [32mhelloworldTest: [0m
[info] [32mhelloworld [0m
[info] [32m- is being tested [0m
[info] Passed: : Total 1, Failed 0, Errors 0, Passed 1, Skipped 0
[success] Total time: 12 s, completed 01.06.2011 14:12:32

can some one tell me how to get rid of [32m and [0m? I find it
difficult to read if running more than a few tests. I tried it with
sbt 0.9.8 and it did the same, so I'm not sure if it's a sbt or a
scalatest thing. I looked at the scalatest mailing list do and didn't
find anything. I used the Spec example from the scalatest website
after my custom test didn't work and that produced the same strange
output. http://www.scalatest.org/getting_started_with_bdd

cheers david

Mark Harrah

unread,
Jun 1, 2011, 1:01:53 PM6/1/11
to simple-b...@googlegroups.com
Hi David,

Because sbt isn't writing out the escape sequences for its own logging, it is probably ScalaTest not checking the ansiCodesSupported value. You can explicitly pass ScalaTest's no-color option:

testOptions in Test += Tests.Arguments(TestFrameworks.ScalaTest, "-W")

The available options are described here:

http://www.scalatest.org/scaladoc-1.5/org/scalatest/tools/ScalaTestFramework.html

-Mark

Bill Venners

unread,
Jun 1, 2011, 7:40:32 PM6/1/11
to simple-b...@googlegroups.com
Hi Mark,

ScalaTest is trying to not send out the ANSI codes if
ansiCodesSupported returns false:

logger.info(
if (logger.ansiCodesSupported && presentInColor)
colorizeLinesIndividually(text, ansiColor)
else
text
)

Don't have an easy way to reproduce the problem right now. Maybe we
can try it at ScalaDays.

Bill


> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
> To post to this group, send email to simple-b...@googlegroups.com.
> To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.
>
>

--
Bill Venners
Artima, Inc.
http://www.artima.com

Mark Harrah

unread,
Jun 1, 2011, 7:51:48 PM6/1/11
to simple-b...@googlegroups.com

Yes, that looks right, sorry. I will try to see if it is sbt's fault then.

-Mark

etorreborre

unread,
Jun 1, 2011, 8:02:48 PM6/1/11
to simple-build-tool
Hi,

I'm pretty sure that if there's an issue you can fix it but I would
recommend David to try to get colors on its Windows DOS console,
that's even better!

David, you can check this link out: http://softkube.com/blog/ansi-command-line-colors-under-windows/

Cheers,

Eric.

PS: I think that with sbt 0.7.4 it was also required to add -
Djline.terminal=jline.UnsupportedTerminal to the launch script.

On Jun 2, 9:51 am, Mark Harrah <dmhar...@gmail.com> wrote:
> On Wed, 1 Jun 2011 16:40:32 -0700
>
>
>
>
>
>
>
>
>
> Bill Venners <b...@artima.com> wrote:
> > Hi Mark,
>
> > On Wed, Jun 1, 2011 at 10:01 AM, Mark Harrah <dmhar...@gmail.com> wrote:
> > > Hi David,
>
> > > On Wed, 1 Jun 2011 05:43:53 -0700 (PDT)
> > > David Craven <da...@craven.ch> wrote:
>
> > >> when running the test command in sbt 0.9.10 on windows 7 prints this:
>
> > >> C:\Users\dvc\workspace\booksApp>set SCRIPT_DIR=C:\sbt\
>
> > >> C:\Users\dvc\workspace\booksApp>java -Xmx512M -jar "C:\sbt\sbt-
> > >> launch.jar" test
> > >> [info] Set current project to default (in build file:/C:/Users/dvc/
> > >> workspace/foo/)
> > >> [info] Compiling 1 Scala source to C:\Users\dvc\workspace\foo\target
> > >> \scala-2.8.1.final\test-classes...
> > >> [info]  [32mhelloworldTest: [0m
> > >> [info]  [32mhelloworld  [0m
> > >> [info]  [32m- is being tested [0m
> > >> [info] Passed: : Total 1, Failed 0, Errors 0, Passed 1, Skipped 0
> > >> [success] Total time: 12 s, completed 01.06.2011 14:12:32
>
> > >> can some one tell me how to get rid of [32m and [0m? I find it
> > >> difficult to read if running more than a few tests. I tried it with
> > >> sbt 0.9.8 and it did the same, so I'm not sure if it's a sbt or a
> > >> scalatest thing. I looked at the scalatest mailing list do and didn't
> > >> find anything. I used the Spec example from the scalatest website
> > >> after my custom test didn't work and that produced the same strange
> > >> output.http://www.scalatest.org/getting_started_with_bdd
>
> > > Because sbt isn't writing out the escape sequences for its own logging, it is probably ScalaTest not checking the ansiCodesSupported value.  You can explicitly pass ScalaTest's no-color option:
>
> > > testOptions in Test += Tests.Arguments(TestFrameworks.ScalaTest, "-W")
>
> > > The available options are described here:
>
> > >  http://www.scalatest.org/scaladoc-1.5/org/scalatest/tools/ScalaTestFr...

David Craven

unread,
Jun 2, 2011, 1:12:33 PM6/2/11
to simple-build-tool
hi,

thx for the workaround and @etorreborre I use Windows Power Shell ;)

ijuma

unread,
Jun 7, 2011, 1:48:51 PM6/7/11
to simple-b...@googlegroups.com
On Thursday, 2 June 2011 00:51:48 UTC+1, Mark Harrah wrote:

Yes, that looks right, sorry.  I will try to see if it is sbt's fault then.

I ran into this same issue. Shall a bug be filed so that this doesn't get lost?

Best,
Ismael

ijuma

unread,
Jun 8, 2011, 4:20:49 AM6/8/11
to simple-b...@googlegroups.com
I should note specs 1.6.8 is also affected by this.

Ismael

huynhjl

unread,
Jun 8, 2011, 7:28:28 AM6/8/11
to simple-build-tool
I wonder if the jansi dependency that was brought with jline can help
(and I hope the issue is not related to the new jline). When jline
starts it wraps its output stream in something that can handle ansi
codes:

http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/jline/src/main/java/scala/tools/jline/AnsiWindowsTerminal.java#L43

See https://github.com/huynhjl/jansi/blob/master/src/main/java/org/fusesource/jansi/WindowsAnsiOutputStream.java
for what's supported.

You can sort of experiment it at the 2.9 console on win32:

val out = new org.fusesource.jansi.WindowsAnsiOutputStream(System.out)
out.write("\u001B[33mhi\u001B[0m\n".getBytes)

May be this can be used to bring sbt colorization to Windows?


--Jean-Laurent

On Jun 1, 4:51 pm, Mark Harrah <dmhar...@gmail.com> wrote:
> On Wed, 1 Jun 2011 16:40:32 -0700
>
>
> Bill Venners <b...@artima.com> wrote:
> > Hi Mark,
>
> > On Wed, Jun 1, 2011 at 10:01 AM, Mark Harrah <dmhar...@gmail.com> wrote:
> > > Hi David,
>
> > > On Wed, 1 Jun 2011 05:43:53 -0700 (PDT)
> > > David Craven <da...@craven.ch> wrote:
>
> > >> when running the test command in sbt 0.9.10 on windows 7 prints this:
>
> > >> C:\Users\dvc\workspace\booksApp>set SCRIPT_DIR=C:\sbt\
>
> > >> C:\Users\dvc\workspace\booksApp>java -Xmx512M -jar "C:\sbt\sbt-
> > >> launch.jar" test
> > >> [info] Set current project to default (in build file:/C:/Users/dvc/
> > >> workspace/foo/)
> > >> [info] Compiling 1 Scala source to C:\Users\dvc\workspace\foo\target
> > >> \scala-2.8.1.final\test-classes...
> > >> [info]  [32mhelloworldTest: [0m
> > >> [info]  [32mhelloworld  [0m
> > >> [info]  [32m- is being tested [0m
> > >> [info] Passed: : Total 1, Failed 0, Errors 0, Passed 1, Skipped 0
> > >> [success] Total time: 12 s, completed 01.06.2011 14:12:32
>
> > >> can some one tell me how to get rid of [32m and [0m? I find it
> > >> difficult to read if running more than a few tests. I tried it with
> > >> sbt 0.9.8 and it did the same, so I'm not sure if it's a sbt or a
> > >> scalatest thing. I looked at the scalatest mailing list do and didn't
> > >> find anything. I used the Spec example from the scalatest website
> > >> after my custom test didn't work and that produced the same strange
> > >> output.http://www.scalatest.org/getting_started_with_bdd
>
> > > Because sbt isn't writing out the escape sequences for its own logging, it is probably ScalaTest not checking the ansiCodesSupported value.  You can explicitly pass ScalaTest's no-color option:
>
> > > testOptions in Test += Tests.Arguments(TestFrameworks.ScalaTest, "-W")
>
> > > The available options are described here:
>
> > >  http://www.scalatest.org/scaladoc-1.5/org/scalatest/tools/ScalaTestFr...

Mark Harrah

unread,
Jun 9, 2011, 8:11:55 AM6/9/11
to simple-b...@googlegroups.com

Yes, I've identified it as a bug in sbt, so please file away.

-Mark

Mark Harrah

unread,
Jun 9, 2011, 8:13:38 AM6/9/11
to simple-b...@googlegroups.com
On Wed, 8 Jun 2011 04:28:28 -0700 (PDT)
huynhjl <huy...@gmail.com> wrote:

> I wonder if the jansi dependency that was brought with jline can help
> (and I hope the issue is not related to the new jline). When jline
> starts it wraps its output stream in something that can handle ansi
> codes:
>
> http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/jline/src/main/java/scala/tools/jline/AnsiWindowsTerminal.java#L43
>
> See https://github.com/huynhjl/jansi/blob/master/src/main/java/org/fusesource/jansi/WindowsAnsiOutputStream.java
> for what's supported.
>
> You can sort of experiment it at the 2.9 console on win32:
>
> val out = new org.fusesource.jansi.WindowsAnsiOutputStream(System.out)
> out.write("\u001B[33mhi\u001B[0m\n".getBytes)
>
> May be this can be used to bring sbt colorization to Windows?

The long term plan is to use Scala's jline. There is a fair amount of work to do on it, though. jline2 introduced ThreadLocals (!) and a more intrusive shutdown hook if I remember correctly.

-Mark

ijuma

unread,
Jun 9, 2011, 9:47:12 AM6/9/11
to simple-b...@googlegroups.com
On Thursday, 9 June 2011 13:11:55 UTC+1, Mark Harrah wrote:

Yes, I've identified it as a bug in sbt, so please file away.


Best,
Ismael

Reply all
Reply to author
Forward
0 new messages