Re: [Piglit] [PATCH 1/3] framework/backends/junit.py: restore time for stderr
On Thu, Oct 15, 2015 at 05:13:38PM -0700, Mark Janes wrote: > baker.dyla...@gmail.com writes: > > > From: Dylan Baker> > > > This allows time to be fully restored. > > --- > > framework/backends/junit.py | 12 > > framework/tests/junit_backends_tests.py | 22 +- > > 2 files changed, 29 insertions(+), 5 deletions(-) > > > > diff --git a/framework/backends/junit.py b/framework/backends/junit.py > > index 11fb09e..ce6a27a 100644 > > --- a/framework/backends/junit.py > > +++ b/framework/backends/junit.py > > @@ -255,6 +255,9 @@ def _load(results_file): > > name = name[:-1] > > > > result.result = test.attrib['status'] > > + > > +# This is the fallback path, we'll try to overwrite this with the > > value > > +# in stderr > > result.time = results.TimeAttribute(end=float(test.attrib['time'])) > > result.err = test.find('system-err').text > > > > I noticed that a few lines above this hunk, there is this: > > # Take the class name minus the 'piglit.' element, replace junit's '.' > # separator with piglit's separator, and join the group and test names > > The transformation is not reversible, eg: > > test/foo.bar/baz -> test.foo.bar.baz -> test/foo/bar/baz Not exactly. '.' is first replaced with '_': test/foo.bar/baz -> test/foo_bar/baz test/foo_bar/baz -> test.foo_bar.baz So the '.' is reversible, but the '_' is not because piglit uses '_' in it's names. > > This doesn't affect my use case, though. > > Reviewed-by: Mark Janes Thanks for the review > > > @@ -264,6 +267,15 @@ def _load(results_file): > > result.command = out[0] > > result.out = '\n'.join(out[1:]) > > > > +# Try to get the values in stderr for time > > +if 'time start' in result.err: > > +for line in result.err.split('\n'): > > +if line.startswith('time start:'): > > +result.time.start = float(line[len('time start: '):]) > > +elif line.startswith('time end:'): > > +result.time.end = float(line[len('time end: '):]) > > +break > > + > > run_result.tests[name] = result > > > > return run_result > > diff --git a/framework/tests/junit_backends_tests.py > > b/framework/tests/junit_backends_tests.py > > index 96335f3..1a4be0e 100644 > > --- a/framework/tests/junit_backends_tests.py > > +++ b/framework/tests/junit_backends_tests.py > > @@ -47,7 +47,11 @@ _XML = """\ > > > > > time="1.12345"> > > this/is/a/command\nThis is stdout > > -this is stderr > > +this is stderr > > + > > +time start: 1.0 > > +time end: 4.5 > > + > > > > > > > > @@ -234,11 +238,17 @@ class TestJUnitLoad(utils.StaticDirectory): > > nt.assert_is_instance(self.xml().tests[self.testname].result, > >status.Status) > > > > -def test_time(self): > > -"""backends.junit._load: Time is loaded correctly.""" > > +def test_time_start(self): > > +"""backends.junit._load: Time.start is loaded correctly.""" > > time = self.xml().tests[self.testname].time > > nt.assert_is_instance(time, results.TimeAttribute) > > -nt.assert_equal(time.total, 1.12345) > > +nt.eq_(time.start, 1.0) > > + > > +def test_time_end(self): > > +"""backends.junit._load: Time.end is loaded correctly.""" > > +time = self.xml().tests[self.testname].time > > +nt.assert_is_instance(time, results.TimeAttribute) > > +nt.eq_(time.end, 4.5) > > > > def test_command(self): > > """backends.junit._load: command is loaded correctly.""" > > @@ -253,7 +263,9 @@ class TestJUnitLoad(utils.StaticDirectory): > > def test_err(self): > > """backends.junit._load: stderr is loaded correctly.""" > > test = self.xml().tests[self.testname].err > > -nt.assert_equal(test, 'this is stderr') > > +nt.eq_( > > +test, 'this is stderr\n\ntime start: 1.0\ntime end: 4.5\n > > ') > > + > > > > @utils.no_error > > def test_load_file(self): > > -- > > 2.6.1 signature.asc Description: PGP signature ___ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit
Re: [Piglit] [PATCH 1/3] framework/backends/junit.py: restore time for stderr
baker.dyla...@gmail.com writes: > From: Dylan Baker> > This allows time to be fully restored. > --- > framework/backends/junit.py | 12 > framework/tests/junit_backends_tests.py | 22 +- > 2 files changed, 29 insertions(+), 5 deletions(-) > > diff --git a/framework/backends/junit.py b/framework/backends/junit.py > index 11fb09e..ce6a27a 100644 > --- a/framework/backends/junit.py > +++ b/framework/backends/junit.py > @@ -255,6 +255,9 @@ def _load(results_file): > name = name[:-1] > > result.result = test.attrib['status'] > + > +# This is the fallback path, we'll try to overwrite this with the > value > +# in stderr > result.time = results.TimeAttribute(end=float(test.attrib['time'])) > result.err = test.find('system-err').text > I noticed that a few lines above this hunk, there is this: # Take the class name minus the 'piglit.' element, replace junit's '.' # separator with piglit's separator, and join the group and test names The transformation is not reversible, eg: test/foo.bar/baz -> test.foo.bar.baz -> test/foo/bar/baz This doesn't affect my use case, though. Reviewed-by: Mark Janes > @@ -264,6 +267,15 @@ def _load(results_file): > result.command = out[0] > result.out = '\n'.join(out[1:]) > > +# Try to get the values in stderr for time > +if 'time start' in result.err: > +for line in result.err.split('\n'): > +if line.startswith('time start:'): > +result.time.start = float(line[len('time start: '):]) > +elif line.startswith('time end:'): > +result.time.end = float(line[len('time end: '):]) > +break > + > run_result.tests[name] = result > > return run_result > diff --git a/framework/tests/junit_backends_tests.py > b/framework/tests/junit_backends_tests.py > index 96335f3..1a4be0e 100644 > --- a/framework/tests/junit_backends_tests.py > +++ b/framework/tests/junit_backends_tests.py > @@ -47,7 +47,11 @@ _XML = """\ > > time="1.12345"> > this/is/a/command\nThis is stdout > -this is stderr > +this is stderr > + > +time start: 1.0 > +time end: 4.5 > + > > > > @@ -234,11 +238,17 @@ class TestJUnitLoad(utils.StaticDirectory): > nt.assert_is_instance(self.xml().tests[self.testname].result, >status.Status) > > -def test_time(self): > -"""backends.junit._load: Time is loaded correctly.""" > +def test_time_start(self): > +"""backends.junit._load: Time.start is loaded correctly.""" > time = self.xml().tests[self.testname].time > nt.assert_is_instance(time, results.TimeAttribute) > -nt.assert_equal(time.total, 1.12345) > +nt.eq_(time.start, 1.0) > + > +def test_time_end(self): > +"""backends.junit._load: Time.end is loaded correctly.""" > +time = self.xml().tests[self.testname].time > +nt.assert_is_instance(time, results.TimeAttribute) > +nt.eq_(time.end, 4.5) > > def test_command(self): > """backends.junit._load: command is loaded correctly.""" > @@ -253,7 +263,9 @@ class TestJUnitLoad(utils.StaticDirectory): > def test_err(self): > """backends.junit._load: stderr is loaded correctly.""" > test = self.xml().tests[self.testname].err > -nt.assert_equal(test, 'this is stderr') > +nt.eq_( > +test, 'this is stderr\n\ntime start: 1.0\ntime end: 4.5\n > ') > + > > @utils.no_error > def test_load_file(self): > -- > 2.6.1 ___ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit
[Piglit] [PATCH 1/3] framework/backends/junit.py: restore time for stderr
From: Dylan BakerThis allows time to be fully restored. --- framework/backends/junit.py | 12 framework/tests/junit_backends_tests.py | 22 +- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/framework/backends/junit.py b/framework/backends/junit.py index 11fb09e..ce6a27a 100644 --- a/framework/backends/junit.py +++ b/framework/backends/junit.py @@ -255,6 +255,9 @@ def _load(results_file): name = name[:-1] result.result = test.attrib['status'] + +# This is the fallback path, we'll try to overwrite this with the value +# in stderr result.time = results.TimeAttribute(end=float(test.attrib['time'])) result.err = test.find('system-err').text @@ -264,6 +267,15 @@ def _load(results_file): result.command = out[0] result.out = '\n'.join(out[1:]) +# Try to get the values in stderr for time +if 'time start' in result.err: +for line in result.err.split('\n'): +if line.startswith('time start:'): +result.time.start = float(line[len('time start: '):]) +elif line.startswith('time end:'): +result.time.end = float(line[len('time end: '):]) +break + run_result.tests[name] = result return run_result diff --git a/framework/tests/junit_backends_tests.py b/framework/tests/junit_backends_tests.py index 96335f3..1a4be0e 100644 --- a/framework/tests/junit_backends_tests.py +++ b/framework/tests/junit_backends_tests.py @@ -47,7 +47,11 @@ _XML = """\ this/is/a/command\nThis is stdout -this is stderr +this is stderr + +time start: 1.0 +time end: 4.5 + @@ -234,11 +238,17 @@ class TestJUnitLoad(utils.StaticDirectory): nt.assert_is_instance(self.xml().tests[self.testname].result, status.Status) -def test_time(self): -"""backends.junit._load: Time is loaded correctly.""" +def test_time_start(self): +"""backends.junit._load: Time.start is loaded correctly.""" time = self.xml().tests[self.testname].time nt.assert_is_instance(time, results.TimeAttribute) -nt.assert_equal(time.total, 1.12345) +nt.eq_(time.start, 1.0) + +def test_time_end(self): +"""backends.junit._load: Time.end is loaded correctly.""" +time = self.xml().tests[self.testname].time +nt.assert_is_instance(time, results.TimeAttribute) +nt.eq_(time.end, 4.5) def test_command(self): """backends.junit._load: command is loaded correctly.""" @@ -253,7 +263,9 @@ class TestJUnitLoad(utils.StaticDirectory): def test_err(self): """backends.junit._load: stderr is loaded correctly.""" test = self.xml().tests[self.testname].err -nt.assert_equal(test, 'this is stderr') +nt.eq_( +test, 'this is stderr\n\ntime start: 1.0\ntime end: 4.5\n') + @utils.no_error def test_load_file(self): -- 2.6.1 ___ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit