[PATCH] run-tests: skip threading for a single test (issue5040)

Matt Harbison mharbison72 at gmail.com
Wed Jan 13 23:09:52 CST 2016


On Wed, 13 Jan 2016 23:44:58 -0500, timeless <timeless at mozdev.org> wrote:

> # HG changeset patch
> # User timeless <timeless at mozdev.org>
> # Date 1452744890 0
> #      Thu Jan 14 04:14:50 2016 +0000
> # Node ID 1c38b20de0cfd66cebd881400a7e9c0c197dbe8e
> # Parent  5dcadc6c5aed543c0dfaf54890c0b8c19555360a
> run-tests: skip threading for a single test (issue5040)
>
> This version backs out 50e621fe0362 and implements it in
> a more consistent manner.

Works for me, thanks.

Windows didn't like the test you added though.  (I was a little surprised  
that `kill` was available on Windows.)  I don't have time to look at it  
tonight:

--- c:/Users/Matt/Projects/hg/tests/test-run-tests.t
+++ c:/Users/Matt/Projects/hg/tests/test-run-tests.t.err
@@ -623,8 +623,8 @@
    >   touch tasks/$TASK
    > }
    $ rtt --runs-per-test=200
+  rm: cannot remove directory `tasks/': Is a directory
    $ ls tasks
-  * (glob)
    $ rtt --loop
    $ ls tasks
    * (glob)


> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -1442,6 +1442,8 @@
>          executes on its own thread. Tests actually spawn new processes,  
> so
>          state mutation should not be an issue.
> +        If there is only one job, it will use the main thread.
> +
>          whitelist and blacklist denote tests that have been whitelisted  
> and
>          blacklisted, respectively. These arguments don't belong in  
> TestSuite.
>          Instead, whitelist and blacklist should be handled by the thing  
> that
> @@ -1558,45 +1560,44 @@
>              statthread.start()
>         try:
> -            if len(tests) == 1:
> -                test = tests.pop(0)
> -                test.run(result)
> -            else:
> -                while tests or running:
> -                    if not done.empty() or running == self._jobs or not  
> tests:
> -                        try:
> -                            done.get(True, 1)
> -                            running -= 1
> -                            if result and result.shouldStop:
> -                                stoppedearly = True
> -                                break
> -                        except queue.Empty:
> -                            continue
> -                    if tests and not running == self._jobs:
> -                        test = tests.pop(0)
> -                        if self._loop:
> -                            if getattr(test, 'should_reload', False):
> -                                num_tests[0] += 1
> -                                tests.append(
> -                                    self._loadtest(test.name,  
> num_tests[0]))
> -                            else:
> -                                tests.append(test)
> +            while tests or running:
> +                if not done.empty() or running == self._jobs or not  
> tests:
> +                    try:
> +                        done.get(True, 1)
> +                        running -= 1
> +                        if result and result.shouldStop:
> +                            stoppedearly = True
> +                            break
> +                    except queue.Empty:
> +                        continue
> +                if tests and not running == self._jobs:
> +                    test = tests.pop(0)
> +                    if self._loop:
> +                        if getattr(test, 'should_reload', False):
> +                            num_tests[0] += 1
> +                            tests.append(
> +                                self._loadtest(test.name, num_tests[0]))
> +                        else:
> +                            tests.append(test)
> +                    if self._jobs == 1:
> +                        job(test, result)
> +                    else:
>                          t = threading.Thread(target=job, name=test.name,
>                                               args=(test, result))
>                          t.start()
> -                        running += 1
> +                    running += 1
> -                # If we stop early we still need to wait on started  
> tests to
> -                # finish. Otherwise, there is a race between the test  
> completing
> -                # and the test's cleanup code running. This could  
> result in the
> -                # test reporting incorrect.
> -                if stoppedearly:
> -                    while running:
> -                        try:
> -                            done.get(True, 1)
> -                            running -= 1
> -                        except queue.Empty:
> -                            continue
> +            # If we stop early we still need to wait on started tests to
> +            # finish. Otherwise, there is a race between the test  
> completing
> +            # and the test's cleanup code running. This could result in  
> the
> +            # test reporting incorrect.
> +            if stoppedearly:
> +                while running:
> +                    try:
> +                        done.get(True, 1)
> +                        running -= 1
> +                    except queue.Empty:
> +                        continue
>          except KeyboardInterrupt:
>              for test in runtests:
>                  test.abort()
> diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
> --- a/tests/test-run-tests.t
> +++ b/tests/test-run-tests.t
> @@ -607,6 +607,29 @@
> #endif
> +test runs-per-test and loop
> +
> +  $ mkdir tasks
> +  $ echo "  $ touch `pwd`/tasks/\$\$" > test-loop-child.t
> +  $ rtt() {
> +  >   rm tasks/* 2> /dev/null
> +  >   $TESTDIR/run-tests.py -l test-loop-child.t $1 2> /dev/null >  
> /dev/null &
> +  >   sleep 1
> +  >   kill %1; wait > /dev/null 2> /dev/null
> +  >   TASK=`ls tasks | head -1`
> +  >   rm tasks/$TASK
> +  >   TASK=`ls tasks | head -1`
> +  >   rm tasks/* 2> /dev/null
> +  >   touch tasks/$TASK
> +  > }
> +  $ rtt --runs-per-test=200
> +  $ ls tasks
> +  * (glob)
> +  $ rtt --loop
> +  $ ls tasks
> +  * (glob)
> +  $ rm -rf tasks
> +
>  backslash on end of line with glob matching is handled properly
>   $ cat > test-glob-backslash.t << EOF
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list