Open Bug 1649576 Opened 4 years ago Updated 4 years ago

run xpcshell self-tests in parallel

Categories

(Testing :: General, enhancement)

enhancement

Tracking

(Not tracked)

ASSIGNED

People

(Reporter: froydnj, Assigned: glandium)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

This requires moving each test to a separate file so mach python-test will actually run everything in parallel. I have a hacky proof-of-concept patch.

There is waaaaaay too much duplication in this patch for this to be an
actual, landable patch, but it can be a useful starting point for
discussion -- or for somebody to tell me I'm a n00b at Python unit
testing and there is a better way to do this.

All of these files were almost entirely machine created; the process goes like:

  1. Put the "header" of selftest.py -- everything before the first test
    function into a file, call it template.
  2. Put the __main__ invocation in a file, call it main.
  3. Run:
for name in $(grep 'def test' selftest.py |perl -p -e 's/\(self\)://' | f 2 |perl -p -e 's/test//')
do
  cat template > selftest-${name}.py; echo "[selftest-${name}.py]
skip-if = python == 3" >> python.ini
done

to create the initial files.
4) Run:

for name in $(grep 'def test' selftest.py |perl -p -e 's/\(self\)://' | f 2 |perl -p -e 's/test//')
do
  sed -n -e "/def test${name}(self):/,/^    [d@]/p" selftest.py|sed '$d' >> selftest-${name}.py
done

to pull out the individual functions for the tests and append them to
the correct file.
5) Massage any @unittest decorators into place.
6) Append main onto every new test file, which is left as an exercise
for the reader.
7) Remove all tests from selftest.py.

This change cuts time for overall mach python-test -j12 --subsuite default
in about half on my machine, mostly because whatever test framework is
running has terrible overhead. But that's about 20s faster, so seems
mostly worth it.

Assignee: nobody → nfroyd
Status: NEW → ASSIGNED
Attachment #9160476 - Attachment is obsolete: true
Assignee: nfroyd → mh+mozilla
Depends on: 1614626

Work in progress. Works on Linux and Mac, times out on Windows.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: