Patchwork [4,of,4] test-worker: exercise more about "killworkers" situation

login
register
mail settings
Submitter Jun Wu
Date May 3, 2017, 12:09 a.m.
Message ID <b21e9ded40fdc3ce2d66.1493770178@x1c>
Download mbox | patch
Permalink /patch/20373/
State Accepted
Headers show

Comments

Jun Wu - May 3, 2017, 12:09 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1492906385 25200
#      Sat Apr 22 17:13:05 2017 -0700
# Node ID b21e9ded40fdc3ce2d6671b361879dd16b7ae9b3
# Parent  32b59b65cc97898ceee090e695904e2c1e431d41
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r b21e9ded40fd
test-worker: exercise more about "killworkers" situation

This patch adds some sleep and increases numcpus to exercise the
"killworkers" situation. So race conditions could be discovered more easily,
if someone changes worker.py incorrectly. Currently worker.py should be free
of such issues.

Patch

diff --git a/tests/test-worker.t b/tests/test-worker.t
--- a/tests/test-worker.t
+++ b/tests/test-worker.t
@@ -3,4 +3,5 @@  Test UI worker interaction
   $ cat > t.py <<EOF
   > from __future__ import absolute_import, print_function
+  > import time
   > from mercurial import (
   >     cmdutil,
@@ -23,4 +24,5 @@  Test UI worker interaction
   >         ui.status('run\n')
   >         yield 1, arg
+  >     time.sleep(0.1) # easier to trigger killworkers code path
   > functable = {
   >     'abort': abort,
@@ -75,11 +77,11 @@  Run tests without worker by forcing a lo
 Known exception should be caught, but printed if --traceback is enabled
 
-  $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=2' \
-  > test 100000.0 abort
+  $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=8' \
+  > test 100000.0 abort 2>&1
   start
   abort: known exception
   [255]
 
-  $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=2' \
+  $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=8' \
   > test 100000.0 abort --traceback 2>&1 | egrep '^(SystemExit|Abort)'
   Abort: known exception
@@ -88,5 +90,5 @@  Known exception should be caught, but pr
 Traceback must be printed for unknown exceptions
 
-  $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=2' \
+  $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=8' \
   > test 100000.0 exc 2>&1 | grep '^Exception'
   Exception: unknown exception