Opened 5 years ago

Closed 3 years ago

Last modified 3 years ago

#31621 closed New feature (fixed)

Add "--parallel=auto" option to the "test" command.

Reported by: Adam Johnson Owned by: Adam Johnson
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The --parallel flag to test is used as a binary "on" to mean "on all cores." But it also tries to parse the value after it as a number. This is annoying as there's no easy way to alias it as "on", since when adding a test name afterwards it is parsed as an integer:

$ python manage.py test --parallel example.core.tests.test_a
usage: manage.py test [-h] [--noinput] [--failfast] ...
manage.py test: error: argument --parallel: invalid int value: 'example.core.tests.test_a'

Pytest's xdist plugin supports the value "auto" to mean "all cores." I suggest we copy that.

Change History (16)

comment:1 by Adam Johnson, 4 years ago

Has patch: set

comment:2 by Mariusz Felisiak, 4 years ago

Owner: changed from nobody to Adam Johnson
Summary: Add ability to specify "all cores" to "test --parallel"Add "--parallel=auto" option to the "test" command.
Triage Stage: UnreviewedAccepted
Type: Cleanup/optimizationNew feature

comment:3 by Ahmad A. Hussein, 4 years ago

Triage Stage: AcceptedReady for checkin

Patch looks good

comment:4 by Mariusz Felisiak, 4 years ago

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

comment:5 by Sergey Fedoseev, 4 years ago

Cc: Sergey Fedoseev added

What about this?

$ python manage.py test --parallel -- example.core.tests.test_a

comment:6 by Adam Johnson, 4 years ago

That works. However if you use it in e.g. an alias with alias test='python manage.py test --parallel --', then you can no longer pass extra flags.

comment:7 by Mariusz Felisiak, 3 years ago

Needs tests: set

comment:8 by Sergey Fedoseev, 3 years ago

Cc: Sergey Fedoseev removed

comment:9 by Adam Johnson, 3 years ago

Patch needs improvement: unset

comment:10 by Adam Johnson, 3 years ago

Patch needs improvement: set

comment:11 by Adam Johnson, 3 years ago

Needs tests: unset

comment:12 by Mariusz Felisiak, 3 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:13 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In 7e38a8d6:

Refs #31621 -- Added more tests for test --parallel option.

comment:14 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In ae89daf4:

Fixed #31621 -- Added support for '--parallel auto' to test management command.

comment:15 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In c2a5735d:

Refs #31621 -- Added more tests for test --parallel option.

comment:16 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In 36714be8:

Refs #31621 -- Fixed handling --parallel option in test management command and runtests.py.

Regression in ae89daf46f83a7b39d599d289624c3377bfa4ab1.
Thanks Tim Graham for the report.

Note: See TracTickets for help on using tickets.
Back to Top