[PATCH 010 of 179 tests-refactor] run-tests: capture execution results in a TestResult class
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Wed May 7 15:39:55 CDT 2014
On 05/02/2014 11:37 AM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1397940625 25200
> # Sat Apr 19 13:50:25 2014 -0700
> # Branch stable
> # Node ID 22f12dcef025b280eb1b8f22280167f562ebc46d
> # Parent b56fd9035cad3f850b8e921a4177b007659ffef6
> run-tests: capture execution results in a TestResult class
>
> Some implementation details of test execution still live outside of
> Test. These include determining what a result means and cleaning up
> after the test.
>
> To move to the world where more of this logic can live inside Test or a
> derived object, the logic for test execution needs to be refactored.
> Specifically, exception trapping and opportunities for result processing
> need to be moved into Test.
>
> This patch starts the process by establishing a TestResult class for
> holding the results of a test execution. In order to actually use this
> class, exception trapping and execution time recording needed to be
> moved into Test.run().
>
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -556,20 +556,37 @@ class Test(object):
> os.mkdir(self._testtmp)
>
> self._setreplacements(count)
>
> def run(self):
> env = self._getenv()
> createhgrc(env['HGRCPATH'], self._options)
>
> + result = TestResult()
> + starttime = time.time()
> +
> + def updateduration():
> + result.duration = time.time() - starttime
Not sure why you need this closure here (#ihateclosure)
> +
> try:
> - return self._run(self._replacements, env)
> - finally:
> - killdaemons(env['DAEMON_PIDS'])
> + ret, out = self._run(self._replacements, env)
> + updateduration()
> + result.ret = ret
> + result.out = out
> + except KeyboardInterrupt:
> + updateduration()
> + result.interrupted = True
> + except Exception, e:
> + updateduration()
> + result.exception = e
And not sure why you call it in tree different place instead of once. at
the ends.
Note: This is the end of my review path. Will look at the other 10 when
those will be queued.
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list