[Piglit] [PATCH] framework/log: Avoid carriage-return when stdout is not a TTY.
Jose Fonseca
jfonseca at vmware.com
Thu Jun 5 09:21:55 PDT 2014
----- Original Message -----
> On Thu, Jun 5, 2014 at 11:47 AM, Jose Fonseca <jfonseca at vmware.com> wrote:
> > ----- Original Message -----
> >> On Thu, Jun 5, 2014 at 11:23 AM, <jfonseca at vmware.com> wrote:
> >> > From: José Fonseca <jfonseca at vmware.com>
> >> >
> >> > Otherwise Jenkins won't show any progress while piglit is running.
> >> >
> >> > PS: Another alternative would be to detect the presence of
> >> > JENKINS_HOME/HUDSON_HOME environment variables. I'm happy either way.
> >>
> >> Hm, perhaps "not a tty" should be synonymous with verbose mode where
> >> it prints all the tests?
> >
> > No, the current verbosity level is fine. I just need "\n" instead of "\r".
> > For the same reason there is a sys.stdout.flush() -- so that I can see
> > the output immediately.
>
> Well, my point was that if you flip it to \n, it's ~same number of
> lines as in the verbose mode (well, verbose is 2x since it has one for
> run and one for finish).
I understand what you meant now. I just tried "-v". Yes, the info is not bad, but the \r still screwups things a bit, even on the command line. Here's what I get:
fail :: spec/glsl-1.20/execution/variable-indexing/vs-varying-mat2-col-rd
running :: spec/ARB_texture_gather/textureGather/vs-rgb-none-int-CubeArray
running :: spec/glsl-1.10/execution/built-in-functions/fs-notEqual-bvec2-bvec2
fail :: spec/ARB_uniform_buffer_object/getintegeri_vg Test(s): 01431 01432
running :: spec/glsl-1.50/execution/built-in-functions/gs-op-not-bool01432 01433
running :: shaders/glsl-vs-vec4-indexing-temp-dst-in-loopt(s): 01432 01433
fail :: spec/ARB_texture_gather/textureGather/vs-rgb-none-int-CubeArray433 01434
fail :: spec/glsl-1.10/execution/built-in-functions/fs-notEqual-bvec2-bvec201434 01435
running :: spec/glsl-1.30/execution/built-in-functions/fs-op-rshift-ivec3-uvec34 01435
fail :: spec/glsl-1.50/execution/built-in-functions/gs-op-not-bool34 01435
running :: spec/glsl-1.10/execution/variable-indexing/fs-varying-array-mat3-col-rd
fail :: shaders/glsl-vs-vec4-indexing-temp-dst-in-loopTest(s): 01435 01436
> Anyways, if the current thing is useful to you with just the \n's,
> that's fine by me. Merely wanted to point out a potential alternative.
Thanks.
Jose
>
> >
> >> (What is Jenkins? Some sort of continuous
> >> build system?)
> >
> > It's a continuous integration server. I use it to schedule mesa/piglit
> > builds, and the testing of both across many platforms.
> >
> > Jose
> >
> >
> >>
> >> > ---
> >> > framework/log.py | 25 ++++++++++++++++++-------
> >> > 1 file changed, 18 insertions(+), 7 deletions(-)
> >> >
> >> > diff --git a/framework/log.py b/framework/log.py
> >> > index e5154aa..d261dbb 100644
> >> > --- a/framework/log.py
> >> > +++ b/framework/log.py
> >> > @@ -43,8 +43,18 @@ class Log(object):
> >> > 'timeout'])
> >> > self.__summary = collections.defaultdict(lambda: 0)
> >> > self.__lastlength = 0
> >> > + self.__tty = sys.stdout.isatty()
> >> > +
> >> > + self.__output = "[{percent}] {summary} {running}"
> >> > +
> >> > + # Some automation tools (e.g, Jenkins) will buffer all output
> >> > until
> >> > + # newline, so don't use carriage return character if the stdout
> >> > is
> >> > not
> >> > + # a TTY.
> >> > + if self.__tty:
> >> > + self.__output += "\r"
> >> > + else:
> >> > + self.__output += "\n"
> >> >
> >> > - self.__output = "[{percent}] {summary} {running}\r"
> >> > if verbose:
> >> > self.__output = "{result} :: {name}\n" + self.__output
> >> >
> >> > @@ -53,13 +63,14 @@ class Log(object):
> >> > def _write_output(self, output):
> >> > """ write the output to stdout, ensuring any previous line is
> >> > cleared """
> >> >
> >> > - length = len(output)
> >> > - if self.__lastlength > length:
> >> > - output = "{0}{1}{2}".format(output[:-1],
> >> > - " " * (self.__lastlength -
> >> > length),
> >> > - output[-1])
> >> > + if self.__tty:
> >> > + length = len(output)
> >> > + if self.__lastlength > length:
> >> > + output = "{0}{1}{2}".format(output[:-1],
> >> > + " " * (self.__lastlength -
> >> > length),
> >> > + output[-1])
> >> >
> >> > - self.__lastlength = length
> >> > + self.__lastlength = length
> >> >
> >> > sys.stdout.write(output)
> >> >
> >> > --
> >> > 1.9.1
> >> >
> >> > _______________________________________________
> >> > Piglit mailing list
> >> > Piglit at lists.freedesktop.org
> >> > https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/piglit&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=NMr9uy2iTjWVixC0wOcYCWEIYhfo80qKwRgdodpoDzA%3D%0A&m=FNt%2BBK4qrgRJfsKN%2BxKHASdaLIGEZIB2EQR8JpimJg4%3D%0A&s=7b5f7c6507fc56be773b80618a11873f44e61dbe0c05360d2ea75abb939d1a70
> >>
>
More information about the Piglit
mailing list