Opened 19 months ago

Closed 4 months ago

Last modified 4 months 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 Changed 19 months ago by Adam Johnson

Has patch: set

comment:2 Changed 19 months ago by Mariusz Felisiak

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 Changed 18 months ago by Ahmad A. Hussein

Triage Stage: AcceptedReady for checkin

Patch looks good

comment:4 Changed 18 months ago by Mariusz Felisiak

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

comment:5 Changed 18 months ago by Sergey Fedoseev

Cc: Sergey Fedoseev added

What about this?

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

comment:6 Changed 18 months ago by Adam Johnson

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 Changed 5 months ago by Mariusz Felisiak

Needs tests: set

comment:8 Changed 5 months ago by Sergey Fedoseev

Cc: Sergey Fedoseev removed

comment:9 Changed 5 months ago by Adam Johnson

Patch needs improvement: unset

comment:10 Changed 5 months ago by Adam Johnson

Patch needs improvement: set

comment:11 Changed 5 months ago by Adam Johnson

Needs tests: unset

comment:12 Changed 4 months ago by Mariusz Felisiak

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:13 Changed 4 months ago by Mariusz Felisiak <felisiak.mariusz@…>

In 7e38a8d6:

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

comment:14 Changed 4 months ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In ae89daf4:

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

comment:15 Changed 4 months ago by Mariusz Felisiak <felisiak.mariusz@…>

In c2a5735d:

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

comment:16 Changed 4 months ago by Mariusz Felisiak <felisiak.mariusz@…>

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