Skip to content

Commit

Permalink
testing: Run in parallel mode by default.
Browse files Browse the repository at this point in the history
This commit changes the backend testing framework to run
in parallel mode which is same as --processes=4. If --coverage
is supplied, we enforce serial mode, --processes=1, because
coverage is not compatible with parallel mode at the moment.
  • Loading branch information
umairwaheed authored and timabbott committed May 4, 2017
1 parent 37a8a43 commit 6b1c530
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 5 additions & 4 deletions docs/testing-with-django.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ or just done things that are kind of unique in Zulip.
## Running tests

Our tests live in `zerver/tests/`. You can run them with
`./tools/test-backend`. It generally takes about a minute to run
the entire test suite. When you are in iterative mode, you
can run individual tests or individual modules, following the
dotted.test.name convention below:
`./tools/test-backend`. The tests run in parallel using multiple
threads in your development environment, and can finish in under 30s
on a fast machine. When you are in iterative mode, you can run
individual tests or individual modules, following the dotted.test.name
convention below:

cd /srv/zulip
./tools/test-backend zerver.tests.test_queue_worker.WorkerTest
Expand Down
12 changes: 9 additions & 3 deletions tools/test-backend
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ if __name__ == "__main__":
dest="fatal_errors", help="Continue past test failures to run all tests")
parser.add_option('--coverage', dest='coverage',
action="store_true",
default=False, help='Compute test coverage.')
default=False,
help='Compute test coverage. Enforces processes=1.')
parser.add_option('--verbose-coverage', dest='verbose_coverage',
action="store_true",
default=False, help='Enable verbose print of coverage report.')
Expand All @@ -160,9 +161,9 @@ if __name__ == "__main__":
type="int",
callback=allow_positive_int,
action='callback',
default=1,
default=4,
help='Specify the number of processes to run the '
'tests in. Default is 1.')
'tests in. Default is 4.')
parser.add_option('--profile', dest='profile',
action="store_true",
default=False, help='Profile test runtime.')
Expand Down Expand Up @@ -195,6 +196,11 @@ if __name__ == "__main__":
"test-backend was run. Implies --nonfatal-errors."))

(options, args) = parser.parse_args()
if options.coverage:
# Currently coverage doesn't work with parallel mode, so when
# coverage parameter is supplied we enfore serial mode.
print("Disabling parallel mode because coverage isn't supported.")
options.processes = 1

zerver_test_dir = 'zerver/tests/'

Expand Down

0 comments on commit 6b1c530

Please sign in to comment.