run-tests: collect aggregate code coverage
Before this patch, every Python process during a code coverage run was
writing coverage data to the same file. I'm not sure if the coverage
package even tries to obtain a lock on the file. But what I do know is
there was some last write wins leading to loss of code coverage data, at
least with -j > 1.
This patch changes the code coverage mechanism to be multiple process
safe. The mechanism for initializing code coverage via sitecustomize.py
has been tweaked so each Python process will produce a separate coverage
data file on disk. Unless two processes generate the same random value,
there are no race conditions writing to the same file. At the end of the
test run, we combine all written files into an aggregate report.
On my machine, running the full test suite produces a little over
20,000 coverage files consuming ~350 MB. As you can imagine, it takes
several seconds to load and merge these coverage files. But when it is
done, you have an accurate picture of the aggregate code coverage for the
entire test suite, which is ~60% line coverage.
$ cat >> $HGRCPATH <<EOF
> [extensions]
> rebase=
>
> [phases]
> publish=False
>
> [alias]
> tglog = log -G --template "{rev}: '{desc}' {branches}\n"
> EOF
$ hg init a
$ cd a
$ echo c1 > c1
$ hg ci -Am c1
adding c1
$ echo c2 > c2
$ hg ci -Am c2
adding c2
$ echo l1 > l1
$ hg ci -Am l1
adding l1
$ hg up -q -C 1
$ echo r1 > r1
$ hg ci -Am r1
adding r1
created new head
$ echo r2 > r2
$ hg ci -Am r2
adding r2
$ hg tglog
@ 4: 'r2'
|
o 3: 'r1'
|
| o 2: 'l1'
|/
o 1: 'c2'
|
o 0: 'c1'
Rebase with no arguments - single revision in source branch:
$ hg up -q -C 2
$ hg rebase
rebasing 2:87c180a611f2 "l1"
saved backup bundle to $TESTTMP/a/.hg/strip-backup/87c180a611f2-a5be192d-backup.hg (glob)
$ hg tglog
@ 4: 'l1'
|
o 3: 'r2'
|
o 2: 'r1'
|
o 1: 'c2'
|
o 0: 'c1'
$ cd ..
$ hg init b
$ cd b
$ echo c1 > c1
$ hg ci -Am c1
adding c1
$ echo c2 > c2
$ hg ci -Am c2
adding c2
$ echo l1 > l1
$ hg ci -Am l1
adding l1
$ echo l2 > l2
$ hg ci -Am l2
adding l2
$ hg up -q -C 1
$ echo r1 > r1
$ hg ci -Am r1
adding r1
created new head
$ hg tglog
@ 4: 'r1'
|
| o 3: 'l2'
| |
| o 2: 'l1'
|/
o 1: 'c2'
|
o 0: 'c1'
Rebase with no arguments - single revision in target branch:
$ hg up -q -C 3
$ hg rebase
rebasing 2:87c180a611f2 "l1"
rebasing 3:1ac923b736ef "l2"
saved backup bundle to $TESTTMP/b/.hg/strip-backup/87c180a611f2-b980535c-backup.hg (glob)
$ hg tglog
@ 4: 'l2'
|
o 3: 'l1'
|
o 2: 'r1'
|
o 1: 'c2'
|
o 0: 'c1'
$ cd ..