On Mon, Oct 22, 2007 at 08:53:36AM +0000, Johannes Sixt wrote:
quoted text > Pierre Habouzit schrieb:
> >Signed-off-by: Pierre Habouzit <madcoder@debian.org>
> >---
> >Maybe this is just me, but I don't find the output of the test-suite
> >easy to watch while scrolling. This puts some colors in proper places.
> > * end-test summaries are in green or red depending on the sucess of
> > the tests.
> > * errors are in red.
> > * skipped tests and other things that tests `say` are in brown (now
> > you can _see_ that your testsuite skips some tests on purpose, I
> > only noticed recently that I missed part of the environment for
> > proper testing).
> >I'm not 100% sure the test to see if terminal supports color is correct,=
=20
quoted text > >and
> >people using emacs shell buffer or alike tools may have better ideas on=
=20
quoted text > >how to
> >make it.
> >and yes, I know that it "depends" upon tput, but if tput isn't=20
> >available, the
> > [ "x$TERM" !=3D "xdumb" ] && tput hpa 60 >/dev/null 2>&1 && tput set=
af=20
quoted text > >1 >/dev/null 2>&1
> >expression will fail, and color will be disabled.
> > t/test-lib.sh | 32 ++++++++++++++++++++++----------
> > 1 files changed, 22 insertions(+), 10 deletions(-)
> >diff --git a/t/test-lib.sh b/t/test-lib.sh
> >index cc1253c..c6521c0 100644
> >--- a/t/test-lib.sh
> >+++ b/t/test-lib.sh
> >@@ -59,14 +59,24 @@ esac
> > # '
> > # . ./test-lib.sh
> > +[ "x$TERM" !=3D "xdumb" ] && tput hpa 60 >/dev/null 2>&1 && tput setaf=
1=20
quoted text > >>/dev/null 2>&1
> >+nocolor=3D$?
>=20
> test "x$TERM" !=3D "xdumb" &&
> tput hpa 60 >/dev/null 2>&1 &&
> tput setaf 1 >/dev/null 2>&1 &&
> color=3Dt
>=20
> BTW, doesn't tput fail if stdout/stderr is not a terminal, like above?
>=20
> >+
> >+say_color () {
> >+ [ "$nocolor" =3D 0 ] && [ "" !=3D '-1' ] && tput setaf ""
> >+ shift
> >+ echo "* $*"
> >+ tput op
> >+}
>=20
> What if tput is not available, like on Windows? How about this (at the=20
> end of the file, so it can obey --no-color):
I answered to it already in my first mail: if tput isn't available,
the command fails, and $? is non 0. and nocolor is set. Or color isn't
set to 't' for your proposal.
--=20
=C2=B7O=C2=B7 Pierre Habouzit
=C2=B7=C2=B7O madcoder@debia=
n.org
OOO
http://www.madism.org