Mercurial > hg
annotate tests/run-tests.py @ 10301:56b50194617f
templates: rename `Last change' column in hgwebdir repository list.
This patch changes column headers in the templates that previously
said `Last change' to `Last modified'. Neither code nor functionality
are changed other than that.
For some time now, I have been annoyed by the fact the `Last change'
column didn't list the age of the youngest changeset in the
repository, or at least tip. It just occurred to me that this is
because the wording is slightly misleading; what the column in fact
lists is when the repository was last *modified*, that is, when
changesets was last added or removed from it.
The word `change' can be understood as referring to the changeset
itself. Using `changed' would be ever so slightly less
amigous. However, the standard nomenclature in this case is
`modification date' and `Last modified', which is incidentally entirely
unambigous. Hence, `Last modified' is the wording used.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Sun, 24 Jan 2010 20:51:53 +0100 |
parents | c437745f50ec |
children | bc9a3bb267fa |
rev | line source |
---|---|
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
2 # |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
3 # run-tests.py - Run a set of tests on Mercurial |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
4 # |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
5 # Copyright 2006 Matt Mackall <mpm@selenic.com> |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
6 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8161
diff
changeset
|
7 # This software may be used and distributed according to the terms of the |
10263 | 8 # GNU General Public License version 2 or any later version. |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
9 |
8674
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
10 # Modifying this script is tricky because it has many modes: |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
11 # - serial (default) vs parallel (-jN, N > 1) |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
12 # - no coverage (default) vs coverage (-c, -C, -s) |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
13 # - temp install (default) vs specific hg script (--with-hg, --local) |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
14 # - tests are a mix of shell scripts and Python scripts |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
15 # |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
16 # If you change this script, it is recommended that you ensure you |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
17 # haven't broken it by running it in various modes with a representative |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
18 # sample of test scripts. For example: |
8843
eb7b247a98ea
kill trailing whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8724
diff
changeset
|
19 # |
8674
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
20 # 1) serial, no coverage, temp install: |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
21 # ./run-tests.py test-s* |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
22 # 2) serial, no coverage, local hg: |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
23 # ./run-tests.py --local test-s* |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
24 # 3) serial, coverage, temp install: |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
25 # ./run-tests.py -c test-s* |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
26 # 4) serial, coverage, local hg: |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
27 # ./run-tests.py -c --local test-s* # unsupported |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
28 # 5) parallel, no coverage, temp install: |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
29 # ./run-tests.py -j2 test-s* |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
30 # 6) parallel, no coverage, local hg: |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
31 # ./run-tests.py -j2 --local test-s* |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
32 # 7) parallel, coverage, temp install: |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
33 # ./run-tests.py -j2 -c test-s* # currently broken |
9899
be574a37a8ae
run-tests: give each child its own tmp dir (issue1911)
Greg Ward <greg@gerg.ca>
parents:
9707
diff
changeset
|
34 # 8) parallel, coverage, local install: |
8674
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
35 # ./run-tests.py -j2 -c --local test-s* # unsupported (and broken) |
9899
be574a37a8ae
run-tests: give each child its own tmp dir (issue1911)
Greg Ward <greg@gerg.ca>
parents:
9707
diff
changeset
|
36 # 9) parallel, custom tmp dir: |
be574a37a8ae
run-tests: give each child its own tmp dir (issue1911)
Greg Ward <greg@gerg.ca>
parents:
9707
diff
changeset
|
37 # ./run-tests.py -j2 --tmpdir /tmp/myhgtests |
8674
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
38 # |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
39 # (You could use any subset of the tests: test-s* happens to match |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
40 # enough that it's worth doing parallel runs, few enough that it |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
41 # completes fairly quickly, includes both shell and Python scripts, and |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
42 # includes some scripts that run daemon processes.) |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
43 |
2571
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
44 import difflib |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
45 import errno |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
46 import optparse |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
47 import os |
8280
0b02d98d44d0
util: always use subprocess
Martin Geisler <mg@lazybytes.net>
parents:
8258
diff
changeset
|
48 import subprocess |
2571
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
49 import shutil |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
50 import signal |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
51 import sys |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
52 import tempfile |
2571
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
53 import time |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
54 |
8280
0b02d98d44d0
util: always use subprocess
Martin Geisler <mg@lazybytes.net>
parents:
8258
diff
changeset
|
55 closefds = os.name == 'posix' |
0b02d98d44d0
util: always use subprocess
Martin Geisler <mg@lazybytes.net>
parents:
8258
diff
changeset
|
56 def Popen4(cmd, bufsize=-1): |
0b02d98d44d0
util: always use subprocess
Martin Geisler <mg@lazybytes.net>
parents:
8258
diff
changeset
|
57 p = subprocess.Popen(cmd, shell=True, bufsize=bufsize, |
0b02d98d44d0
util: always use subprocess
Martin Geisler <mg@lazybytes.net>
parents:
8258
diff
changeset
|
58 close_fds=closefds, |
0b02d98d44d0
util: always use subprocess
Martin Geisler <mg@lazybytes.net>
parents:
8258
diff
changeset
|
59 stdin=subprocess.PIPE, stdout=subprocess.PIPE, |
0b02d98d44d0
util: always use subprocess
Martin Geisler <mg@lazybytes.net>
parents:
8258
diff
changeset
|
60 stderr=subprocess.STDOUT) |
0b02d98d44d0
util: always use subprocess
Martin Geisler <mg@lazybytes.net>
parents:
8258
diff
changeset
|
61 p.fromchild = p.stdout |
0b02d98d44d0
util: always use subprocess
Martin Geisler <mg@lazybytes.net>
parents:
8258
diff
changeset
|
62 p.tochild = p.stdin |
0b02d98d44d0
util: always use subprocess
Martin Geisler <mg@lazybytes.net>
parents:
8258
diff
changeset
|
63 p.childerr = p.stderr |
0b02d98d44d0
util: always use subprocess
Martin Geisler <mg@lazybytes.net>
parents:
8258
diff
changeset
|
64 return p |
0b02d98d44d0
util: always use subprocess
Martin Geisler <mg@lazybytes.net>
parents:
8258
diff
changeset
|
65 |
5685
57d29a45ffbc
Use skipped: instead of hghave: for skipping tests, use this in test-merge-types
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5524
diff
changeset
|
66 # reserved exit code to skip test (used by hghave) |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
4880
diff
changeset
|
67 SKIPPED_STATUS = 80 |
5685
57d29a45ffbc
Use skipped: instead of hghave: for skipping tests, use this in test-merge-types
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5524
diff
changeset
|
68 SKIPPED_PREFIX = 'skipped: ' |
8060
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
69 FAILED_PREFIX = 'hghave check failed: ' |
8096
a110d7a20f3f
run-tests: upper-case global PYTHON variable
Martin Geisler <mg@lazybytes.net>
parents:
8095
diff
changeset
|
70 PYTHON = sys.executable |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
4880
diff
changeset
|
71 |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
72 requiredtools = ["python", "diff", "grep", "unzip", "gunzip", "bunzip2", "sed"] |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
73 |
6366
07c3cd695b48
run-tests.py: Allow environment variables to set jobs/timeout/port.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6343
diff
changeset
|
74 defaults = { |
07c3cd695b48
run-tests.py: Allow environment variables to set jobs/timeout/port.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6343
diff
changeset
|
75 'jobs': ('HGTEST_JOBS', 1), |
07c3cd695b48
run-tests.py: Allow environment variables to set jobs/timeout/port.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6343
diff
changeset
|
76 'timeout': ('HGTEST_TIMEOUT', 180), |
07c3cd695b48
run-tests.py: Allow environment variables to set jobs/timeout/port.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6343
diff
changeset
|
77 'port': ('HGTEST_PORT', 20059), |
07c3cd695b48
run-tests.py: Allow environment variables to set jobs/timeout/port.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6343
diff
changeset
|
78 } |
07c3cd695b48
run-tests.py: Allow environment variables to set jobs/timeout/port.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6343
diff
changeset
|
79 |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
80 def parseargs(): |
8091
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
81 parser = optparse.OptionParser("%prog [options] [tests]") |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
82 parser.add_option("-C", "--annotate", action="store_true", |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
83 help="output files annotated with coverage") |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
84 parser.add_option("--child", type="int", |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
85 help="run as child process, summary to given fd") |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
86 parser.add_option("-c", "--cover", action="store_true", |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
87 help="print a test coverage report") |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
88 parser.add_option("-f", "--first", action="store_true", |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
89 help="exit on the first test failure") |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
90 parser.add_option("-i", "--interactive", action="store_true", |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
91 help="prompt to accept changed output") |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
92 parser.add_option("-j", "--jobs", type="int", |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
93 help="number of jobs to run in parallel" |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
94 " (default: $%s or %d)" % defaults['jobs']) |
9582
a25af3af941c
tests: add -k to test scripts matching keywords
Matt Mackall <mpm@selenic.com>
parents:
9580
diff
changeset
|
95 parser.add_option("-k", "--keywords", |
a25af3af941c
tests: add -k to test scripts matching keywords
Matt Mackall <mpm@selenic.com>
parents:
9580
diff
changeset
|
96 help="run tests matching keywords") |
8091
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
97 parser.add_option("--keep-tmpdir", action="store_true", |
9706
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
98 help="keep temporary directory after running tests") |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
99 parser.add_option("--tmpdir", type="string", |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
100 help="run tests in the given temporary directory" |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
101 " (implies --keep-tmpdir)") |
9707
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
102 parser.add_option("-d", "--debug", action="store_true", |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
103 help="debug mode: write output of test scripts to console" |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
104 " rather than capturing and diff'ing it (disables timeout)") |
8091
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
105 parser.add_option("-R", "--restart", action="store_true", |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
106 help="restart at last error") |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
107 parser.add_option("-p", "--port", type="int", |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
108 help="port on which servers should listen" |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
109 " (default: $%s or %d)" % defaults['port']) |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
110 parser.add_option("-r", "--retest", action="store_true", |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
111 help="retest failed tests") |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
112 parser.add_option("-s", "--cover_stdlib", action="store_true", |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
113 help="print a test coverage report inc. standard libraries") |
9580
25858f9e65e8
run-tests: add --noskips option
Matt Mackall <mpm@selenic.com>
parents:
9408
diff
changeset
|
114 parser.add_option("-S", "--noskips", action="store_true", |
25858f9e65e8
run-tests: add --noskips option
Matt Mackall <mpm@selenic.com>
parents:
9408
diff
changeset
|
115 help="don't report skip tests verbosely") |
8091
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
116 parser.add_option("-t", "--timeout", type="int", |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
117 help="kill errant tests after TIMEOUT seconds" |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
118 " (default: $%s or %d)" % defaults['timeout']) |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
119 parser.add_option("-v", "--verbose", action="store_true", |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
120 help="output verbose messages") |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
121 parser.add_option("-n", "--nodiff", action="store_true", |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
122 help="skip showing test changes") |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
123 parser.add_option("--with-hg", type="string", |
8674
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
124 metavar="HG", |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
125 help="test using specified hg script rather than a " |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
126 "temporary installation") |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
127 parser.add_option("--local", action="store_true", |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
128 help="shortcut for --with-hg=<testdir>/../hg") |
8091
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
129 parser.add_option("--pure", action="store_true", |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
130 help="use pure Python code instead of C extensions") |
9028
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
131 parser.add_option("-3", "--py3k-warnings", action="store_true", |
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
132 help="enable Py3k warnings on Python 2.6+") |
9958
777c1df76ef4
run-tests: add --inotify option to test runner
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9940
diff
changeset
|
133 parser.add_option("--inotify", action="store_true", |
777c1df76ef4
run-tests: add --inotify option to test runner
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9940
diff
changeset
|
134 help="enable inotify extension when running tests") |
9959
b37b060d84c7
run-tests: add a "--blacklist target" option to skip predefined test lists
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9958
diff
changeset
|
135 parser.add_option("--blacklist", action="append", |
10300
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
136 help="skip tests listed in the specified blacklist file") |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
137 |
8091
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
138 for option, default in defaults.items(): |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
139 defaults[option] = int(os.environ.get(*default)) |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
140 parser.set_defaults(**defaults) |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
141 (options, args) = parser.parse_args() |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
142 |
8674
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
143 if options.with_hg: |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
144 if not (os.path.isfile(options.with_hg) and |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
145 os.access(options.with_hg, os.X_OK)): |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
146 parser.error('--with-hg must specify an executable hg script') |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
147 if not os.path.basename(options.with_hg) == 'hg': |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
148 sys.stderr.write('warning: --with-hg should specify an hg script') |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
149 if options.local: |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
150 testdir = os.path.dirname(os.path.realpath(sys.argv[0])) |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
151 hgbin = os.path.join(os.path.dirname(testdir), 'hg') |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
152 if not os.access(hgbin, os.X_OK): |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
153 parser.error('--local specified, but %r not found or not executable' |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
154 % hgbin) |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
155 options.with_hg = hgbin |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
156 |
8095
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
157 options.anycoverage = (options.cover or |
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
158 options.cover_stdlib or |
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
159 options.annotate) |
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
160 |
8674
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
161 if options.anycoverage and options.with_hg: |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
162 # I'm not sure if this is a fundamental limitation or just a |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
163 # bug. But I don't want to waste people's time and energy doing |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
164 # test runs that don't give the results they want. |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
165 parser.error("sorry, coverage options do not work when --with-hg " |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
166 "or --local specified") |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
167 |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
168 global vlog |
8095
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
169 if options.verbose: |
8671
a434c94b48e7
run-tests: show PID if running in parallel mode with -v.
Greg Ward <greg-hg@gerg.ca>
parents:
8651
diff
changeset
|
170 if options.jobs > 1 or options.child is not None: |
a434c94b48e7
run-tests: show PID if running in parallel mode with -v.
Greg Ward <greg-hg@gerg.ca>
parents:
8651
diff
changeset
|
171 pid = "[%d]" % os.getpid() |
a434c94b48e7
run-tests: show PID if running in parallel mode with -v.
Greg Ward <greg-hg@gerg.ca>
parents:
8651
diff
changeset
|
172 else: |
a434c94b48e7
run-tests: show PID if running in parallel mode with -v.
Greg Ward <greg-hg@gerg.ca>
parents:
8651
diff
changeset
|
173 pid = None |
8095
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
174 def vlog(*msg): |
8671
a434c94b48e7
run-tests: show PID if running in parallel mode with -v.
Greg Ward <greg-hg@gerg.ca>
parents:
8651
diff
changeset
|
175 if pid: |
a434c94b48e7
run-tests: show PID if running in parallel mode with -v.
Greg Ward <greg-hg@gerg.ca>
parents:
8651
diff
changeset
|
176 print pid, |
8095
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
177 for m in msg: |
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
178 print m, |
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
179 print |
9707
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
180 sys.stdout.flush() |
8095
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
181 else: |
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
182 vlog = lambda *msg: None |
8091
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
183 |
9394
31203db1b2ac
run-tests: expand --tmpdir and create it if needed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9031
diff
changeset
|
184 if options.tmpdir: |
31203db1b2ac
run-tests: expand --tmpdir and create it if needed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9031
diff
changeset
|
185 options.tmpdir = os.path.expanduser(options.tmpdir) |
31203db1b2ac
run-tests: expand --tmpdir and create it if needed
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9031
diff
changeset
|
186 |
8091
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
187 if options.jobs < 1: |
9408
70bf7f853adc
run-tests: standardize on --foo instead of -f/--foo
Martin Geisler <mg@lazybytes.net>
parents:
9407
diff
changeset
|
188 parser.error('--jobs must be positive') |
8091
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
189 if options.interactive and options.jobs > 1: |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
190 print '(--interactive overrides --jobs)' |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
191 options.jobs = 1 |
9707
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
192 if options.interactive and options.debug: |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
193 parser.error("-i/--interactive and -d/--debug are incompatible") |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
194 if options.debug: |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
195 if options.timeout != defaults['timeout']: |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
196 sys.stderr.write( |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
197 'warning: --timeout option ignored with --debug\n') |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
198 options.timeout = 0 |
9028
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
199 if options.py3k_warnings: |
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
200 if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0): |
9408
70bf7f853adc
run-tests: standardize on --foo instead of -f/--foo
Martin Geisler <mg@lazybytes.net>
parents:
9407
diff
changeset
|
201 parser.error('--py3k-warnings can only be used on Python 2.6+') |
9959
b37b060d84c7
run-tests: add a "--blacklist target" option to skip predefined test lists
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9958
diff
changeset
|
202 if options.blacklist: |
b37b060d84c7
run-tests: add a "--blacklist target" option to skip predefined test lists
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9958
diff
changeset
|
203 blacklist = dict() |
10300
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
204 for filename in options.blacklist: |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
205 try: |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
206 path = os.path.expanduser(os.path.expandvars(filename)) |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
207 f = open(path, "r") |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
208 except IOError, err: |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
209 if err.errno != errno.ENOENT: |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
210 raise |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
211 print "warning: no such blacklist file: %s" % filename |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
212 continue |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
213 |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
214 for line in f.readlines(): |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
215 line = line.strip() |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
216 if line and not line.startswith('#'): |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
217 blacklist[line] = filename |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
218 |
9959
b37b060d84c7
run-tests: add a "--blacklist target" option to skip predefined test lists
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9958
diff
changeset
|
219 options.blacklist = blacklist |
8091
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
220 |
e85cc856d2e1
run-tests: factor out parse_args(). Clarify use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8060
diff
changeset
|
221 return (options, args) |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
222 |
5800
2f597243e1d7
Make run-tests.py --interactive work on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
5524
diff
changeset
|
223 def rename(src, dst): |
2f597243e1d7
Make run-tests.py --interactive work on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
5524
diff
changeset
|
224 """Like os.rename(), trade atomicity and opened files friendliness |
2f597243e1d7
Make run-tests.py --interactive work on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
5524
diff
changeset
|
225 for existing destination support. |
2f597243e1d7
Make run-tests.py --interactive work on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
5524
diff
changeset
|
226 """ |
2f597243e1d7
Make run-tests.py --interactive work on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
5524
diff
changeset
|
227 shutil.copy(src, dst) |
2f597243e1d7
Make run-tests.py --interactive work on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
5524
diff
changeset
|
228 os.remove(src) |
2f597243e1d7
Make run-tests.py --interactive work on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
5524
diff
changeset
|
229 |
2247
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
230 def splitnewlines(text): |
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
231 '''like str.splitlines, but only split on newlines. |
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
232 keep line endings.''' |
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
233 i = 0 |
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
234 lines = [] |
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
235 while True: |
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
236 n = text.find('\n', i) |
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
237 if n == -1: |
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
238 last = text[i:] |
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
239 if last: |
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
240 lines.append(last) |
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
241 return lines |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
242 lines.append(text[i:n + 1]) |
2247
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
243 i = n + 1 |
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
244 |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
245 def parsehghaveoutput(lines): |
8060
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
246 '''Parse hghave log lines. |
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
247 Return tuple of lists (missing, failed): |
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
248 * the missing/unknown features |
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
249 * the features for which existence check failed''' |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
4880
diff
changeset
|
250 missing = [] |
8060
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
251 failed = [] |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
4880
diff
changeset
|
252 for line in lines: |
8060
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
253 if line.startswith(SKIPPED_PREFIX): |
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
254 line = line.splitlines()[0] |
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
255 missing.append(line[len(SKIPPED_PREFIX):]) |
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
256 elif line.startswith(FAILED_PREFIX): |
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
257 line = line.splitlines()[0] |
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
258 failed.append(line[len(FAILED_PREFIX):]) |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
4880
diff
changeset
|
259 |
8060
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
260 return missing, failed |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
4880
diff
changeset
|
261 |
10088
ec8304e66ea5
run-tests.py: Show paths to failing tests, .err and .out
Mads Kiilerich <mads@kiilerich.com>
parents:
10030
diff
changeset
|
262 def showdiff(expected, output, ref, err): |
ec8304e66ea5
run-tests.py: Show paths to failing tests, .err and .out
Mads Kiilerich <mads@kiilerich.com>
parents:
10030
diff
changeset
|
263 for line in difflib.unified_diff(expected, output, ref, err): |
2247
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
264 sys.stdout.write(line) |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
265 |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
266 def findprogram(program): |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
267 """Search PATH for a executable program""" |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
268 for p in os.environ.get('PATH', os.defpath).split(os.pathsep): |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
269 name = os.path.join(p, program) |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
270 if os.access(name, os.X_OK): |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
271 return name |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
272 return None |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
273 |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
274 def checktools(): |
2133
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
275 # Before we go any further, check for pre-requisite tools |
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
276 # stuff from coreutils (cat, rm, etc) are not tested |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
277 for p in requiredtools: |
2133
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
278 if os.name == 'nt': |
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
279 p += '.exe' |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
280 found = findprogram(p) |
2133
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
281 if found: |
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
282 vlog("# Found prerequisite", p, "at", found) |
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
283 else: |
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
284 print "WARNING: Did not find prerequisite tool: "+p |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
285 |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
286 def cleanup(options): |
6208
c88b9e597588
tests: add --keep-tmp to run-tests.py to debug test environment
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
6004
diff
changeset
|
287 if not options.keep_tmpdir: |
8671
a434c94b48e7
run-tests: show PID if running in parallel mode with -v.
Greg Ward <greg-hg@gerg.ca>
parents:
8651
diff
changeset
|
288 vlog("# Cleaning up HGTMP", HGTMP) |
6208
c88b9e597588
tests: add --keep-tmp to run-tests.py to debug test environment
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
6004
diff
changeset
|
289 shutil.rmtree(HGTMP, True) |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
290 |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
291 def usecorrectpython(): |
2570
2264b2b077a1
run-tests.py: make tests use same python interpreter as test harness.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2409
diff
changeset
|
292 # some tests run python interpreter. they must use same |
2264b2b077a1
run-tests.py: make tests use same python interpreter as test harness.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2409
diff
changeset
|
293 # interpreter we use or bad things will happen. |
2264b2b077a1
run-tests.py: make tests use same python interpreter as test harness.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2409
diff
changeset
|
294 exedir, exename = os.path.split(sys.executable) |
2264b2b077a1
run-tests.py: make tests use same python interpreter as test harness.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2409
diff
changeset
|
295 if exename == 'python': |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
296 path = findprogram('python') |
2570
2264b2b077a1
run-tests.py: make tests use same python interpreter as test harness.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2409
diff
changeset
|
297 if os.path.dirname(path) == exedir: |
2264b2b077a1
run-tests.py: make tests use same python interpreter as test harness.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2409
diff
changeset
|
298 return |
2264b2b077a1
run-tests.py: make tests use same python interpreter as test harness.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2409
diff
changeset
|
299 vlog('# Making python executable in test path use correct Python') |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
300 mypython = os.path.join(BINDIR, 'python') |
2570
2264b2b077a1
run-tests.py: make tests use same python interpreter as test harness.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2409
diff
changeset
|
301 try: |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
302 os.symlink(sys.executable, mypython) |
2570
2264b2b077a1
run-tests.py: make tests use same python interpreter as test harness.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2409
diff
changeset
|
303 except AttributeError: |
2264b2b077a1
run-tests.py: make tests use same python interpreter as test harness.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2409
diff
changeset
|
304 # windows fallback |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
305 shutil.copyfile(sys.executable, mypython) |
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
306 shutil.copymode(sys.executable, mypython) |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2989
diff
changeset
|
307 |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
308 def installhg(options): |
2133
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
309 vlog("# Performing temporary installation of HG") |
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
310 installerrs = os.path.join("tests", "install.err") |
7723
a343cd25e425
run-tests: add --pure flag for using pure Python modules
Martin Geisler <mg@daimi.au.dk>
parents:
7529
diff
changeset
|
311 pure = options.pure and "--pure" or "" |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
312 |
5267
b817d17c7ee5
Make run-tests.py work when invoked outside of tests.
Brendan Cully <brendan@kublai.com>
parents:
5251
diff
changeset
|
313 # Run installer in hg root |
8943
09ff905cdc86
run-tests: use os.path.realpath() to find hg's setup.py.
Greg Ward <greg-hg@gerg.ca>
parents:
8843
diff
changeset
|
314 script = os.path.realpath(sys.argv[0]) |
09ff905cdc86
run-tests: use os.path.realpath() to find hg's setup.py.
Greg Ward <greg-hg@gerg.ca>
parents:
8843
diff
changeset
|
315 hgroot = os.path.dirname(os.path.dirname(script)) |
09ff905cdc86
run-tests: use os.path.realpath() to find hg's setup.py.
Greg Ward <greg-hg@gerg.ca>
parents:
8843
diff
changeset
|
316 os.chdir(hgroot) |
9905
95517eb3c9a7
run-tests: work around a distutils bug triggered by 0a8a43b4ca75
Patrick Mezard <pmezard@gmail.com>
parents:
9902
diff
changeset
|
317 nohome = '--home=""' |
95517eb3c9a7
run-tests: work around a distutils bug triggered by 0a8a43b4ca75
Patrick Mezard <pmezard@gmail.com>
parents:
9902
diff
changeset
|
318 if os.name == 'nt': |
95517eb3c9a7
run-tests: work around a distutils bug triggered by 0a8a43b4ca75
Patrick Mezard <pmezard@gmail.com>
parents:
9902
diff
changeset
|
319 # The --home="" trick works only on OS where os.sep == '/' |
95517eb3c9a7
run-tests: work around a distutils bug triggered by 0a8a43b4ca75
Patrick Mezard <pmezard@gmail.com>
parents:
9902
diff
changeset
|
320 # because of a distutils convert_path() fast-path. Avoid it at |
95517eb3c9a7
run-tests: work around a distutils bug triggered by 0a8a43b4ca75
Patrick Mezard <pmezard@gmail.com>
parents:
9902
diff
changeset
|
321 # least on Windows for now, deal with .pydistutils.cfg bugs |
95517eb3c9a7
run-tests: work around a distutils bug triggered by 0a8a43b4ca75
Patrick Mezard <pmezard@gmail.com>
parents:
9902
diff
changeset
|
322 # when they happen. |
95517eb3c9a7
run-tests: work around a distutils bug triggered by 0a8a43b4ca75
Patrick Mezard <pmezard@gmail.com>
parents:
9902
diff
changeset
|
323 nohome = '' |
7723
a343cd25e425
run-tests: add --pure flag for using pure Python modules
Martin Geisler <mg@daimi.au.dk>
parents:
7529
diff
changeset
|
324 cmd = ('%s setup.py %s clean --all' |
7139
bcbba59e233d
run-tests.py: use --prefix instead of --home
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7018
diff
changeset
|
325 ' install --force --prefix="%s" --install-lib="%s"' |
10030
cbc93d8ed46a
run-tests: backout d7c23f4a14c7
Martin Geisler <mg@lazybytes.net>
parents:
10020
diff
changeset
|
326 ' --install-scripts="%s" %s >%s 2>&1' |
cbc93d8ed46a
run-tests: backout d7c23f4a14c7
Martin Geisler <mg@lazybytes.net>
parents:
10020
diff
changeset
|
327 % (sys.executable, pure, INST, PYTHONDIR, BINDIR, nohome, |
9905
95517eb3c9a7
run-tests: work around a distutils bug triggered by 0a8a43b4ca75
Patrick Mezard <pmezard@gmail.com>
parents:
9902
diff
changeset
|
328 installerrs)) |
2133
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
329 vlog("# Running", cmd) |
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
330 if os.system(cmd) == 0: |
8095
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
331 if not options.verbose: |
2133
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
332 os.remove(installerrs) |
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
333 else: |
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
334 f = open(installerrs) |
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
335 for line in f: |
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
336 print line, |
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
337 f.close() |
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
338 sys.exit(1) |
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
339 os.chdir(TESTDIR) |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
340 |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
341 usecorrectpython() |
2570
2264b2b077a1
run-tests.py: make tests use same python interpreter as test harness.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2409
diff
changeset
|
342 |
7172
fb1d7a42663c
Use dummy diffstat in tests and remove older diffstat workaround.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
7144
diff
changeset
|
343 vlog("# Installing dummy diffstat") |
fb1d7a42663c
Use dummy diffstat in tests and remove older diffstat workaround.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
7144
diff
changeset
|
344 f = open(os.path.join(BINDIR, 'diffstat'), 'w') |
fb1d7a42663c
Use dummy diffstat in tests and remove older diffstat workaround.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
7144
diff
changeset
|
345 f.write('#!' + sys.executable + '\n' |
fb1d7a42663c
Use dummy diffstat in tests and remove older diffstat workaround.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
7144
diff
changeset
|
346 'import sys\n' |
fb1d7a42663c
Use dummy diffstat in tests and remove older diffstat workaround.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
7144
diff
changeset
|
347 'files = 0\n' |
fb1d7a42663c
Use dummy diffstat in tests and remove older diffstat workaround.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
7144
diff
changeset
|
348 'for line in sys.stdin:\n' |
fb1d7a42663c
Use dummy diffstat in tests and remove older diffstat workaround.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
7144
diff
changeset
|
349 ' if line.startswith("diff "):\n' |
fb1d7a42663c
Use dummy diffstat in tests and remove older diffstat workaround.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
7144
diff
changeset
|
350 ' files += 1\n' |
fb1d7a42663c
Use dummy diffstat in tests and remove older diffstat workaround.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
7144
diff
changeset
|
351 'sys.stdout.write("files patched: %d\\n" % files)\n') |
fb1d7a42663c
Use dummy diffstat in tests and remove older diffstat workaround.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
7144
diff
changeset
|
352 f.close() |
fb1d7a42663c
Use dummy diffstat in tests and remove older diffstat workaround.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
7144
diff
changeset
|
353 os.chmod(os.path.join(BINDIR, 'diffstat'), 0700) |
fb1d7a42663c
Use dummy diffstat in tests and remove older diffstat workaround.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
7144
diff
changeset
|
354 |
9028
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
355 if options.py3k_warnings and not options.anycoverage: |
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
356 vlog("# Updating hg command to enable Py3k Warnings switch") |
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
357 f = open(os.path.join(BINDIR, 'hg'), 'r') |
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
358 lines = [line.rstrip() for line in f] |
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
359 lines[0] += ' -3' |
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
360 f.close() |
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
361 f = open(os.path.join(BINDIR, 'hg'), 'w') |
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
362 for line in lines: |
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
363 f.write(line + '\n') |
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
364 f.close() |
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
365 |
8095
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
366 if options.anycoverage: |
2144
d3bddedfdbd0
Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents:
2133
diff
changeset
|
367 vlog("# Installing coverage wrapper") |
d3bddedfdbd0
Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents:
2133
diff
changeset
|
368 os.environ['COVERAGE_FILE'] = COVERAGE_FILE |
d3bddedfdbd0
Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents:
2133
diff
changeset
|
369 if os.path.exists(COVERAGE_FILE): |
d3bddedfdbd0
Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents:
2133
diff
changeset
|
370 os.unlink(COVERAGE_FILE) |
d3bddedfdbd0
Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents:
2133
diff
changeset
|
371 # Create a wrapper script to invoke hg via coverage.py |
2146
eb1ed410aa34
run-tests.py: remove trailing white space
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2145
diff
changeset
|
372 os.rename(os.path.join(BINDIR, "hg"), os.path.join(BINDIR, "_hg.py")) |
2144
d3bddedfdbd0
Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents:
2133
diff
changeset
|
373 f = open(os.path.join(BINDIR, 'hg'), 'w') |
d3bddedfdbd0
Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents:
2133
diff
changeset
|
374 f.write('#!' + sys.executable + '\n') |
4633
ff7253a0d1da
Cleanup of whitespace, indentation and line continuation.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4529
diff
changeset
|
375 f.write('import sys, os; os.execv(sys.executable, [sys.executable, ' |
8620
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
376 '"%s", "-x", "-p", "%s"] + sys.argv[1:])\n' % |
4633
ff7253a0d1da
Cleanup of whitespace, indentation and line continuation.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4529
diff
changeset
|
377 (os.path.join(TESTDIR, 'coverage.py'), |
ff7253a0d1da
Cleanup of whitespace, indentation and line continuation.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4529
diff
changeset
|
378 os.path.join(BINDIR, '_hg.py'))) |
2144
d3bddedfdbd0
Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents:
2133
diff
changeset
|
379 f.close() |
d3bddedfdbd0
Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents:
2133
diff
changeset
|
380 os.chmod(os.path.join(BINDIR, 'hg'), 0700) |
8092
c49578c5122f
run-tests: move _hgpath() up so it's not in the middle of the main program.
Greg Ward <greg-hg@gerg.ca>
parents:
8091
diff
changeset
|
381 |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
382 def outputcoverage(options): |
8620
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
383 |
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
384 vlog('# Producing coverage report') |
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
385 os.chdir(PYTHONDIR) |
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
386 |
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
387 def covrun(*args): |
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
388 start = sys.executable, os.path.join(TESTDIR, 'coverage.py') |
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
389 cmd = '"%s" "%s" %s' % (start[0], start[1], ' '.join(args)) |
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
390 vlog('# Running: %s' % cmd) |
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
391 os.system(cmd) |
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
392 |
2145
5bb3cb9e5d13
make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2144
diff
changeset
|
393 omit = [BINDIR, TESTDIR, PYTHONDIR] |
5bb3cb9e5d13
make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2144
diff
changeset
|
394 if not options.cover_stdlib: |
5bb3cb9e5d13
make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2144
diff
changeset
|
395 # Exclude as system paths (ignoring empty strings seen on win) |
2146
eb1ed410aa34
run-tests.py: remove trailing white space
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2145
diff
changeset
|
396 omit += [x for x in sys.path if x != ''] |
2145
5bb3cb9e5d13
make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2144
diff
changeset
|
397 omit = ','.join(omit) |
8620
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
398 |
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
399 covrun('-c') # combine from parallel processes |
8696
73aa0510740d
tests: delete parallel coverage files after combining
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8687
diff
changeset
|
400 for fn in os.listdir(TESTDIR): |
73aa0510740d
tests: delete parallel coverage files after combining
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8687
diff
changeset
|
401 if fn.startswith('.coverage.'): |
73aa0510740d
tests: delete parallel coverage files after combining
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8687
diff
changeset
|
402 os.unlink(os.path.join(TESTDIR, fn)) |
73aa0510740d
tests: delete parallel coverage files after combining
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8687
diff
changeset
|
403 |
8620
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
404 covrun('-i', '-r', '"--omit=%s"' % omit) # report |
2145
5bb3cb9e5d13
make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2144
diff
changeset
|
405 if options.annotate: |
5bb3cb9e5d13
make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2144
diff
changeset
|
406 adir = os.path.join(TESTDIR, 'annotated') |
5bb3cb9e5d13
make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2144
diff
changeset
|
407 if not os.path.isdir(adir): |
5bb3cb9e5d13
make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2144
diff
changeset
|
408 os.mkdir(adir) |
8620
b38f275bb5c2
tests: make coverage run in parallel mode, clean up coverage code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8592
diff
changeset
|
409 covrun('-i', '-a', '"--directory=%s"' % adir, '"--omit=%s"' % omit) |
2144
d3bddedfdbd0
Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents:
2133
diff
changeset
|
410 |
2571
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
411 class Timeout(Exception): |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
412 pass |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
413 |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
414 def alarmed(signum, frame): |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
415 raise Timeout |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
416 |
8116
c11636f0609e
run-tests: fix error when timeout occurs
Simon Heimberg <simohe@besonet.ch>
parents:
8107
diff
changeset
|
417 def run(cmd, options): |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
418 """Run command in a sub-process, capturing the output (stdout and stderr). |
9707
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
419 Return a tuple (exitcode, output). output is None in debug mode.""" |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
420 # TODO: Use subprocess.Popen if we're running on Python 2.4 |
9707
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
421 if options.debug: |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
422 proc = subprocess.Popen(cmd, shell=True) |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
423 ret = proc.wait() |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
424 return (ret, None) |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
425 |
7792
cf427b04d5c0
tests: use same popen strategy for jython as for nt
Frank Wierzbicki <fwierzbicki@gmail.com>
parents:
7785
diff
changeset
|
426 if os.name == 'nt' or sys.platform.startswith('java'): |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
427 tochild, fromchild = os.popen4(cmd) |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
428 tochild.close() |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
429 output = fromchild.read() |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
430 ret = fromchild.close() |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
431 if ret == None: |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
432 ret = 0 |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
433 else: |
7813
076401cf2b63
run-tests.py: avoid using popen2.Popen4 - use subprocess instead
Mads Kiilerich <mads@kiilerich.com>
parents:
7792
diff
changeset
|
434 proc = Popen4(cmd) |
2571
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
435 try: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
436 output = '' |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
437 proc.tochild.close() |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
438 output = proc.fromchild.read() |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
439 ret = proc.wait() |
4880
6403f948bd6b
run-tests: extract correct status when script terminates with exit
Patrick Mezard <pmezard@gmail.com>
parents:
4633
diff
changeset
|
440 if os.WIFEXITED(ret): |
6403f948bd6b
run-tests: extract correct status when script terminates with exit
Patrick Mezard <pmezard@gmail.com>
parents:
4633
diff
changeset
|
441 ret = os.WEXITSTATUS(ret) |
2571
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
442 except Timeout: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
443 vlog('# Process %d timed out - killing it' % proc.pid) |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
444 os.kill(proc.pid, signal.SIGTERM) |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
445 ret = proc.wait() |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
446 if ret == 0: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
447 ret = signal.SIGTERM << 8 |
5078
d27ed83289ee
Add message to test output if a test is aborted due to a timeout.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4881
diff
changeset
|
448 output += ("\n### Abort: timeout after %d seconds.\n" |
d27ed83289ee
Add message to test output if a test is aborted due to a timeout.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4881
diff
changeset
|
449 % options.timeout) |
2247
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
450 return ret, splitnewlines(output) |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
451 |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
452 def runone(options, test, skips, fails): |
2710
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
453 '''tristate output: |
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
454 None -> skipped |
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
455 True -> passed |
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
456 False -> failed''' |
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
457 |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
458 def skip(msg): |
8095
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
459 if not options.verbose: |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
460 skips.append((test, msg)) |
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
461 else: |
10088
ec8304e66ea5
run-tests.py: Show paths to failing tests, .err and .out
Mads Kiilerich <mads@kiilerich.com>
parents:
10030
diff
changeset
|
462 print "\nSkipping %s: %s" % (testpath, msg) |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
463 return None |
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
464 |
6244
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
465 def fail(msg): |
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
466 fails.append((test, msg)) |
8095
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
467 if not options.nodiff: |
10088
ec8304e66ea5
run-tests.py: Show paths to failing tests, .err and .out
Mads Kiilerich <mads@kiilerich.com>
parents:
10030
diff
changeset
|
468 print "\nERROR: %s %s" % (testpath, msg) |
6244
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
469 return None |
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
470 |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
471 vlog("# Test", test) |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
472 |
2989
3091b1153e2c
Clear contents of global hgrc for tests before running each test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2710
diff
changeset
|
473 # create a fresh hgrc |
9031
3b76321aa0de
compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents:
9028
diff
changeset
|
474 hgrc = open(HGRCPATH, 'w+') |
4529
860478527568
run-tests.py: set ui.slash = True
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4387
diff
changeset
|
475 hgrc.write('[ui]\n') |
860478527568
run-tests.py: set ui.slash = True
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4387
diff
changeset
|
476 hgrc.write('slash = True\n') |
5524
453acf64f71f
run-tests.py: add a default --date "0 0" argument to commit et al
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5518
diff
changeset
|
477 hgrc.write('[defaults]\n') |
453acf64f71f
run-tests.py: add a default --date "0 0" argument to commit et al
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5518
diff
changeset
|
478 hgrc.write('backout = -d "0 0"\n') |
453acf64f71f
run-tests.py: add a default --date "0 0" argument to commit et al
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5518
diff
changeset
|
479 hgrc.write('commit = -d "0 0"\n') |
453acf64f71f
run-tests.py: add a default --date "0 0" argument to commit et al
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5518
diff
changeset
|
480 hgrc.write('tag = -d "0 0"\n') |
9958
777c1df76ef4
run-tests: add --inotify option to test runner
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9940
diff
changeset
|
481 if options.inotify: |
777c1df76ef4
run-tests: add --inotify option to test runner
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9940
diff
changeset
|
482 hgrc.write('[extensions]\n') |
777c1df76ef4
run-tests: add --inotify option to test runner
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9940
diff
changeset
|
483 hgrc.write('inotify=\n') |
777c1df76ef4
run-tests: add --inotify option to test runner
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9940
diff
changeset
|
484 hgrc.write('[inotify]\n') |
777c1df76ef4
run-tests: add --inotify option to test runner
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9940
diff
changeset
|
485 hgrc.write('pidfile=%s\n' % DAEMON_PIDS) |
10013
b2e87fde6806
run-tests: --inotify: use inotify.appendpid to append pids to $DAEMON_PIDS
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9959
diff
changeset
|
486 hgrc.write('appendpid=True\n') |
2989
3091b1153e2c
Clear contents of global hgrc for tests before running each test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2710
diff
changeset
|
487 hgrc.close() |
3091b1153e2c
Clear contents of global hgrc for tests before running each test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2710
diff
changeset
|
488 |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
489 err = os.path.join(TESTDIR, test+".err") |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
490 ref = os.path.join(TESTDIR, test+".out") |
4320
f9b61e0fc929
run-tests.py: small cleanup
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4319
diff
changeset
|
491 testpath = os.path.join(TESTDIR, test) |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
492 |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
493 if os.path.exists(err): |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
494 os.remove(err) # Remove any previous output files |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
495 |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
496 # Make a tmp subdirectory to work in |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
497 tmpd = os.path.join(HGTMP, test) |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
498 os.mkdir(tmpd) |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
499 os.chdir(tmpd) |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
500 |
4321
99184c6fd88f
run-tests.py: use coverage.py with "#!/usr/bin/env python" tests
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4320
diff
changeset
|
501 try: |
99184c6fd88f
run-tests.py: use coverage.py with "#!/usr/bin/env python" tests
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4320
diff
changeset
|
502 tf = open(testpath) |
99184c6fd88f
run-tests.py: use coverage.py with "#!/usr/bin/env python" tests
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4320
diff
changeset
|
503 firstline = tf.readline().rstrip() |
99184c6fd88f
run-tests.py: use coverage.py with "#!/usr/bin/env python" tests
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4320
diff
changeset
|
504 tf.close() |
99184c6fd88f
run-tests.py: use coverage.py with "#!/usr/bin/env python" tests
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4320
diff
changeset
|
505 except: |
99184c6fd88f
run-tests.py: use coverage.py with "#!/usr/bin/env python" tests
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4320
diff
changeset
|
506 firstline = '' |
2710
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
507 lctest = test.lower() |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
508 |
4321
99184c6fd88f
run-tests.py: use coverage.py with "#!/usr/bin/env python" tests
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4320
diff
changeset
|
509 if lctest.endswith('.py') or firstline == '#!/usr/bin/env python': |
9028
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
510 py3kswitch = options.py3k_warnings and ' -3' or '' |
bea567ae3ff6
tests: add -3 switch to run-tests.py
Alejandro Santos <alejolp@alejolp.com>
parents:
8943
diff
changeset
|
511 cmd = '%s%s "%s"' % (PYTHON, py3kswitch, testpath) |
2710
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
512 elif lctest.endswith('.bat'): |
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
513 # do not run batch scripts on non-windows |
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
514 if os.name != 'nt': |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
515 return skip("batch script") |
2710
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
516 # To reliably get the error code from batch files on WinXP, |
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
517 # the "cmd /c call" prefix is needed. Grrr |
4320
f9b61e0fc929
run-tests.py: small cleanup
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4319
diff
changeset
|
518 cmd = 'cmd /c call "%s"' % testpath |
2710
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
519 else: |
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
520 # do not run shell scripts on windows |
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
521 if os.name == 'nt': |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
522 return skip("shell script") |
2710
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
523 # do not try to run non-executable programs |
7144
9364c3304ca2
run-tests.py: report missing file as an error
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7139
diff
changeset
|
524 if not os.path.exists(testpath): |
9364c3304ca2
run-tests.py: report missing file as an error
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7139
diff
changeset
|
525 return fail("does not exist") |
9364c3304ca2
run-tests.py: report missing file as an error
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7139
diff
changeset
|
526 elif not os.access(testpath, os.X_OK): |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
527 return skip("not executable") |
4320
f9b61e0fc929
run-tests.py: small cleanup
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4319
diff
changeset
|
528 cmd = '"%s"' % testpath |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
529 |
2571
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
530 if options.timeout > 0: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
531 signal.alarm(options.timeout) |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
532 |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
533 vlog("# Running", cmd) |
8116
c11636f0609e
run-tests: fix error when timeout occurs
Simon Heimberg <simohe@besonet.ch>
parents:
8107
diff
changeset
|
534 ret, out = run(cmd, options) |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
535 vlog("# Ret was:", ret) |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
536 |
2571
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
537 if options.timeout > 0: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
538 signal.alarm(0) |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
539 |
7343
e47dab64be8d
run-tests: allow turning off diff display
Matt Mackall <mpm@selenic.com>
parents:
7214
diff
changeset
|
540 mark = '.' |
e47dab64be8d
run-tests: allow turning off diff display
Matt Mackall <mpm@selenic.com>
parents:
7214
diff
changeset
|
541 |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
4880
diff
changeset
|
542 skipped = (ret == SKIPPED_STATUS) |
9707
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
543 # If we're not in --debug mode and reference output file exists, |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
544 # check test output against it. |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
545 if options.debug: |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
546 refout = None # to match out == None |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
547 elif os.path.exists(ref): |
2213
6f76a479ae51
run-tests.py must print changed test output no matter what exit code is.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2183
diff
changeset
|
548 f = open(ref, "r") |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
549 refout = splitnewlines(f.read()) |
2213
6f76a479ae51
run-tests.py must print changed test output no matter what exit code is.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2183
diff
changeset
|
550 f.close() |
2246
3fd603eb6add
run-tests.py: print diff if reference output not existing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2213
diff
changeset
|
551 else: |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
552 refout = [] |
9707
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
553 |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
4880
diff
changeset
|
554 if skipped: |
7343
e47dab64be8d
run-tests: allow turning off diff display
Matt Mackall <mpm@selenic.com>
parents:
7214
diff
changeset
|
555 mark = 's' |
9707
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
556 if out is None: # debug mode: nothing to parse |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
557 missing = ['unknown'] |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
558 failed = None |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
559 else: |
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
560 missing, failed = parsehghaveoutput(out) |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
4880
diff
changeset
|
561 if not missing: |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
4880
diff
changeset
|
562 missing = ['irrelevant'] |
8060
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
563 if failed: |
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
564 fail("hghave failed checking for %s" % failed[-1]) |
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
565 skipped = False |
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
566 else: |
84d0fe34427b
run-tests: detect when hghave fails to check for a feature and fail test
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7813
diff
changeset
|
567 skip(missing[-1]) |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
568 elif out != refout: |
7343
e47dab64be8d
run-tests: allow turning off diff display
Matt Mackall <mpm@selenic.com>
parents:
7214
diff
changeset
|
569 mark = '!' |
6383
38485d45f947
run-tests.py: Only one fail message when output changed and error code.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6366
diff
changeset
|
570 if ret: |
38485d45f947
run-tests.py: Only one fail message when output changed and error code.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6366
diff
changeset
|
571 fail("output changed and returned error code %d" % ret) |
38485d45f947
run-tests.py: Only one fail message when output changed and error code.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6366
diff
changeset
|
572 else: |
38485d45f947
run-tests.py: Only one fail message when output changed and error code.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6366
diff
changeset
|
573 fail("output changed") |
8095
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
574 if not options.nodiff: |
10088
ec8304e66ea5
run-tests.py: Show paths to failing tests, .err and .out
Mads Kiilerich <mads@kiilerich.com>
parents:
10030
diff
changeset
|
575 showdiff(refout, out, ref, err) |
6383
38485d45f947
run-tests.py: Only one fail message when output changed and error code.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6366
diff
changeset
|
576 ret = 1 |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
4880
diff
changeset
|
577 elif ret: |
7343
e47dab64be8d
run-tests: allow turning off diff display
Matt Mackall <mpm@selenic.com>
parents:
7214
diff
changeset
|
578 mark = '!' |
6244
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
579 fail("returned error code %d" % ret) |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
580 |
8095
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
581 if not options.verbose: |
7343
e47dab64be8d
run-tests: allow turning off diff display
Matt Mackall <mpm@selenic.com>
parents:
7214
diff
changeset
|
582 sys.stdout.write(mark) |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
583 sys.stdout.flush() |
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
584 |
9707
38deec407f8d
run-tests: add "debug" mode: don't capture child output, just show it.
Greg Ward <greg-hg@gerg.ca>
parents:
9706
diff
changeset
|
585 if ret != 0 and not skipped and not options.debug: |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
4880
diff
changeset
|
586 # Save errors to a file for diagnosis |
2247
546c76e5a3e6
run-tests.py: fix handling of newlines.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2246
diff
changeset
|
587 f = open(err, "wb") |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
588 for line in out: |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
589 f.write(line) |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
590 f.close() |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
591 |
2571
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
592 # Kill off any leftover daemon processes |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
593 try: |
9031
3b76321aa0de
compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents:
9028
diff
changeset
|
594 fp = open(DAEMON_PIDS) |
2571
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
595 for line in fp: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
596 try: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
597 pid = int(line) |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
598 except ValueError: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
599 continue |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
600 try: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
601 os.kill(pid, 0) |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
602 vlog('# Killing daemon process %d' % pid) |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
603 os.kill(pid, signal.SIGTERM) |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
604 time.sleep(0.25) |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
605 os.kill(pid, 0) |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
606 vlog('# Daemon process %d is stuck - really killing it' % pid) |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
607 os.kill(pid, signal.SIGKILL) |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
608 except OSError, err: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
609 if err.errno != errno.ESRCH: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
610 raise |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
611 fp.close() |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
612 os.unlink(DAEMON_PIDS) |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
613 except IOError: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
614 pass |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
615 |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
616 os.chdir(TESTDIR) |
6208
c88b9e597588
tests: add --keep-tmp to run-tests.py to debug test environment
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
6004
diff
changeset
|
617 if not options.keep_tmpdir: |
6209
4e8cd15240bf
Replaced tab in run-tests.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6208
diff
changeset
|
618 shutil.rmtree(tmpd, True) |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
4880
diff
changeset
|
619 if skipped: |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
4880
diff
changeset
|
620 return None |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
621 return ret == 0 |
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
622 |
8672
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
623 _hgpath = None |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
624 |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
625 def _gethgpath(): |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
626 """Return the path to the mercurial package that is actually found by |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
627 the current Python interpreter.""" |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
628 global _hgpath |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
629 if _hgpath is not None: |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
630 return _hgpath |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
631 |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
632 cmd = '%s -c "import mercurial; print mercurial.__path__[0]"' |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
633 pipe = os.popen(cmd % PYTHON) |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
634 try: |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
635 _hgpath = pipe.read().strip() |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
636 finally: |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
637 pipe.close() |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
638 return _hgpath |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
639 |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
640 def _checkhglib(verb): |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
641 """Ensure that the 'mercurial' package imported by python is |
8673
a8066f2fd1aa
run-tests: fix _checkhglib() so it's correct when using --with-hg.
Greg Ward <greg-hg@gerg.ca>
parents:
8672
diff
changeset
|
642 the one we expect it to be. If not, print a warning to stderr.""" |
a8066f2fd1aa
run-tests: fix _checkhglib() so it's correct when using --with-hg.
Greg Ward <greg-hg@gerg.ca>
parents:
8672
diff
changeset
|
643 expecthg = os.path.join(PYTHONDIR, 'mercurial') |
8672
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
644 actualhg = _gethgpath() |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
645 if actualhg != expecthg: |
8673
a8066f2fd1aa
run-tests: fix _checkhglib() so it's correct when using --with-hg.
Greg Ward <greg-hg@gerg.ca>
parents:
8672
diff
changeset
|
646 sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n' |
a8066f2fd1aa
run-tests: fix _checkhglib() so it's correct when using --with-hg.
Greg Ward <greg-hg@gerg.ca>
parents:
8672
diff
changeset
|
647 ' (expected %s)\n' |
a8066f2fd1aa
run-tests: fix _checkhglib() so it's correct when using --with-hg.
Greg Ward <greg-hg@gerg.ca>
parents:
8672
diff
changeset
|
648 % (verb, actualhg, expecthg)) |
8672
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
649 |
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
650 def runchildren(options, tests): |
8674
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
651 if INST: |
8107
0eeb4f0a5d21
run-tests: fix -jN broken by 60a9e3cf0cf4
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8097
diff
changeset
|
652 installhg(options) |
8672
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
653 _checkhglib("Testing") |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
654 |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
655 optcopy = dict(options.__dict__) |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
656 optcopy['jobs'] = 1 |
8674
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
657 if optcopy['with_hg'] is None: |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
658 optcopy['with_hg'] = os.path.join(BINDIR, "hg") |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
659 opts = [] |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
660 for opt, value in optcopy.iteritems(): |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
661 name = '--' + opt.replace('_', '-') |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
662 if value is True: |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
663 opts.append(name) |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
664 elif value is not None: |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
665 opts.append(name + '=' + str(value)) |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
666 |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
667 tests.reverse() |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
668 jobs = [[] for j in xrange(options.jobs)] |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
669 while tests: |
8161 | 670 for job in jobs: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
671 if not tests: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
672 break |
8161 | 673 job.append(tests.pop()) |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
674 fps = {} |
8161 | 675 for j, job in enumerate(jobs): |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
676 if not job: |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
677 continue |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
678 rfd, wfd = os.pipe() |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
679 childopts = ['--child=%d' % wfd, '--port=%d' % (options.port + j * 3)] |
9899
be574a37a8ae
run-tests: give each child its own tmp dir (issue1911)
Greg Ward <greg@gerg.ca>
parents:
9707
diff
changeset
|
680 childtmp = os.path.join(HGTMP, 'child%d' % j) |
be574a37a8ae
run-tests: give each child its own tmp dir (issue1911)
Greg Ward <greg@gerg.ca>
parents:
9707
diff
changeset
|
681 childopts += ['--tmpdir', childtmp] |
8096
a110d7a20f3f
run-tests: upper-case global PYTHON variable
Martin Geisler <mg@lazybytes.net>
parents:
8095
diff
changeset
|
682 cmdline = [PYTHON, sys.argv[0]] + opts + childopts + job |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
683 vlog(' '.join(cmdline)) |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
684 fps[os.spawnvp(os.P_NOWAIT, cmdline[0], cmdline)] = os.fdopen(rfd, 'r') |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
685 os.close(wfd) |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
686 failures = 0 |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
687 tested, skipped, failed = 0, 0, 0 |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
688 skips = [] |
6244
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
689 fails = [] |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
690 while fps: |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
691 pid, status = os.wait() |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
692 fp = fps.pop(pid) |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
693 l = fp.read().splitlines() |
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
694 test, skip, fail = map(int, l[:3]) |
6244
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
695 split = -fail or len(l) |
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
696 for s in l[3:split]: |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
697 skips.append(s.split(" ", 1)) |
6244
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
698 for s in l[split:]: |
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
699 fails.append(s.split(" ", 1)) |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
700 tested += test |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
701 skipped += skip |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
702 failed += fail |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
703 vlog('pid %d exited, status %d' % (pid, status)) |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
704 failures |= status |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
705 print |
9580
25858f9e65e8
run-tests: add --noskips option
Matt Mackall <mpm@selenic.com>
parents:
9408
diff
changeset
|
706 if not options.noskips: |
25858f9e65e8
run-tests: add --noskips option
Matt Mackall <mpm@selenic.com>
parents:
9408
diff
changeset
|
707 for s in skips: |
25858f9e65e8
run-tests: add --noskips option
Matt Mackall <mpm@selenic.com>
parents:
9408
diff
changeset
|
708 print "Skipped %s: %s" % (s[0], s[1]) |
6244
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
709 for s in fails: |
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
710 print "Failed %s: %s" % (s[0], s[1]) |
6982
9fc5bf4adbcf
imported patch test-check
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6681
diff
changeset
|
711 |
8672
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
712 _checkhglib("Tested") |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
713 print "# Ran %d tests, %d skipped, %d failed." % ( |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
714 tested, skipped, failed) |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
715 sys.exit(failures != 0) |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
716 |
8672
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
717 def runtests(options, tests): |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
718 global DAEMON_PIDS, HGRCPATH |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
719 DAEMON_PIDS = os.environ["DAEMON_PIDS"] = os.path.join(HGTMP, 'daemon.pids') |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
720 HGRCPATH = os.environ["HGRCPATH"] = os.path.join(HGTMP, '.hgrc') |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
721 |
2258
7e43d68f3900
catch KeyboardInterrupt in run-tests
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2247
diff
changeset
|
722 try: |
8674
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
723 if INST: |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
724 installhg(options) |
8672
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
725 _checkhglib("Testing") |
6982
9fc5bf4adbcf
imported patch test-check
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6681
diff
changeset
|
726 |
2571
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
727 if options.timeout > 0: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
728 try: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
729 signal.signal(signal.SIGALRM, alarmed) |
8651
27cc4fa6722d
run-tests: clarify timeout log message.
Greg Ward <greg-hg@gerg.ca>
parents:
8620
diff
changeset
|
730 vlog('# Running each test with %d second timeout' % |
2571
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
731 options.timeout) |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
732 except AttributeError: |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
733 print 'WARNING: cannot run tests with timeouts' |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
734 options.timeout = 0 |
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2570
diff
changeset
|
735 |
3625 | 736 tested = 0 |
2258
7e43d68f3900
catch KeyboardInterrupt in run-tests
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2247
diff
changeset
|
737 failed = 0 |
2710
e475fe2a6029
run-tests.py: skip tests that should not run.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2705
diff
changeset
|
738 skipped = 0 |
2110
25a8d116ab6a
Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff
changeset
|
739 |
3625 | 740 if options.restart: |
741 orig = list(tests) | |
742 while tests: | |
743 if os.path.exists(tests[0] + ".err"): | |
744 break | |
745 tests.pop(0) | |
746 if not tests: | |
747 print "running all tests" | |
748 tests = orig | |
2133
4334be196f8d
Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents:
2110
diff
changeset
|
749 |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
750 skips = [] |
6244
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
751 fails = [] |
9582
a25af3af941c
tests: add -k to test scripts matching keywords
Matt Mackall <mpm@selenic.com>
parents:
9580
diff
changeset
|
752 |
3625 | 753 for test in tests: |
9959
b37b060d84c7
run-tests: add a "--blacklist target" option to skip predefined test lists
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9958
diff
changeset
|
754 if options.blacklist: |
10300
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
755 filename = options.blacklist.get(test) |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
756 if filename is not None: |
c437745f50ec
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10282
diff
changeset
|
757 skips.append((test, "blacklisted (%s)" % filename)) |
9959
b37b060d84c7
run-tests: add a "--blacklist target" option to skip predefined test lists
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9958
diff
changeset
|
758 skipped += 1 |
b37b060d84c7
run-tests: add a "--blacklist target" option to skip predefined test lists
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9958
diff
changeset
|
759 continue |
b37b060d84c7
run-tests: add a "--blacklist target" option to skip predefined test lists
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9958
diff
changeset
|
760 |
3625 | 761 if options.retest and not os.path.exists(test + ".err"): |
762 skipped += 1 | |
763 continue | |
9582
a25af3af941c
tests: add -k to test scripts matching keywords
Matt Mackall <mpm@selenic.com>
parents:
9580
diff
changeset
|
764 |
a25af3af941c
tests: add -k to test scripts matching keywords
Matt Mackall <mpm@selenic.com>
parents:
9580
diff
changeset
|
765 if options.keywords: |
a25af3af941c
tests: add -k to test scripts matching keywords
Matt Mackall <mpm@selenic.com>
parents:
9580
diff
changeset
|
766 t = open(test).read().lower() + test.lower() |
a25af3af941c
tests: add -k to test scripts matching keywords
Matt Mackall <mpm@selenic.com>
parents:
9580
diff
changeset
|
767 for k in options.keywords.lower().split(): |
a25af3af941c
tests: add -k to test scripts matching keywords
Matt Mackall <mpm@selenic.com>
parents:
9580
diff
changeset
|
768 if k in t: |
a25af3af941c
tests: add -k to test scripts matching keywords
Matt Mackall <mpm@selenic.com>
parents:
9580
diff
changeset
|
769 break |
a25af3af941c
tests: add -k to test scripts matching keywords
Matt Mackall <mpm@selenic.com>
parents:
9580
diff
changeset
|
770 else: |
a25af3af941c
tests: add -k to test scripts matching keywords
Matt Mackall <mpm@selenic.com>
parents:
9580
diff
changeset
|
771 skipped +=1 |
a25af3af941c
tests: add -k to test scripts matching keywords
Matt Mackall <mpm@selenic.com>
parents:
9580
diff
changeset
|
772 continue |
a25af3af941c
tests: add -k to test scripts matching keywords
Matt Mackall <mpm@selenic.com>
parents:
9580
diff
changeset
|
773 |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
774 ret = runone(options, test, skips, fails) |
3625 | 775 if ret is None: |
776 skipped += 1 | |
777 elif not ret: | |
3626 | 778 if options.interactive: |
779 print "Accept this change? [n] ", | |
780 answer = sys.stdin.readline().strip() | |
781 if answer.lower() in "y yes".split(): | |
5800
2f597243e1d7
Make run-tests.py --interactive work on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
5524
diff
changeset
|
782 rename(test + ".err", test + ".out") |
3626 | 783 tested += 1 |
6343
1f9be57a6d6a
tests: teach -i about fails list
Matt Mackall <mpm@selenic.com>
parents:
6244
diff
changeset
|
784 fails.pop() |
3626 | 785 continue |
3625 | 786 failed += 1 |
787 if options.first: | |
788 break | |
789 tested += 1 | |
790 | |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
791 if options.child: |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
792 fp = os.fdopen(options.child, 'w') |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
793 fp.write('%d\n%d\n%d\n' % (tested, skipped, failed)) |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
794 for s in skips: |
5760
0145f9afb0e7
Removed tabs and trailing whitespace in python files
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5685
diff
changeset
|
795 fp.write("%s %s\n" % s) |
6244
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
796 for s in fails: |
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
797 fp.write("%s %s\n" % s) |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
798 fp.close() |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
799 else: |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
800 print |
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
801 for s in skips: |
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
802 print "Skipped %s: %s" % s |
6244
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
803 for s in fails: |
b36774d0fce1
run-tests.py: add a summary of failed tests at the end
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6212
diff
changeset
|
804 print "Failed %s: %s" % s |
8672
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
805 _checkhglib("Tested") |
5470
8374f3f081f2
tests: tidy up reporting of skipped tests
Matt Mackall <mpm@selenic.com>
parents:
5388
diff
changeset
|
806 print "# Ran %d tests, %d skipped, %d failed." % ( |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
807 tested, skipped, failed) |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
808 |
8095
f5428d4ffd97
run-tests: reduce global variables set by parse_args().
Greg Ward <greg-hg@gerg.ca>
parents:
8094
diff
changeset
|
809 if options.anycoverage: |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
810 outputcoverage(options) |
2258
7e43d68f3900
catch KeyboardInterrupt in run-tests
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2247
diff
changeset
|
811 except KeyboardInterrupt: |
7e43d68f3900
catch KeyboardInterrupt in run-tests
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2247
diff
changeset
|
812 failed = True |
7e43d68f3900
catch KeyboardInterrupt in run-tests
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2247
diff
changeset
|
813 print "\ninterrupted!" |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
814 |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
815 if failed: |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
816 sys.exit(1) |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
817 |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
818 def main(): |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
819 (options, args) = parseargs() |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
820 if not options.child: |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
821 os.umask(022) |
8093
70d8f70264c4
run-tests: move bits of main program so it's all at the bottom.
Greg Ward <greg-hg@gerg.ca>
parents:
8092
diff
changeset
|
822 |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
823 checktools() |
8093
70d8f70264c4
run-tests: move bits of main program so it's all at the bottom.
Greg Ward <greg-hg@gerg.ca>
parents:
8092
diff
changeset
|
824 |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
825 # Reset some environment variables to well-known values so that |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
826 # the tests produce repeatable output. |
9931
a0680daed7b2
run-tests: LANGUAGE may make tests fail
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
9707
diff
changeset
|
827 os.environ['LANG'] = os.environ['LC_ALL'] = os.environ['LANGUAGE'] = 'C' |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
828 os.environ['TZ'] = 'GMT' |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
829 os.environ["EMAIL"] = "Foo Bar <foo.bar@example.com>" |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
830 os.environ['CDPATH'] = '' |
9913
e3237af51def
run-tests: always set $COLUMNS, fix running tests under emacs shell
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9899
diff
changeset
|
831 os.environ['COLUMNS'] = '80' |
10154
d4a62b6d4a58
run-tests.py: clears http_proxy for all tests
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
9939
diff
changeset
|
832 os.environ['http_proxy'] = '' |
8093
70d8f70264c4
run-tests: move bits of main program so it's all at the bottom.
Greg Ward <greg-hg@gerg.ca>
parents:
8092
diff
changeset
|
833 |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
834 global TESTDIR, HGTMP, INST, BINDIR, PYTHONDIR, COVERAGE_FILE |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
835 TESTDIR = os.environ["TESTDIR"] = os.getcwd() |
9706
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
836 if options.tmpdir: |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
837 options.keep_tmpdir = True |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
838 tmpdir = options.tmpdir |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
839 if os.path.exists(tmpdir): |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
840 # Meaning of tmpdir has changed since 1.3: we used to create |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
841 # HGTMP inside tmpdir; now HGTMP is tmpdir. So fail if |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
842 # tmpdir already exists. |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
843 sys.exit("error: temp dir %r already exists" % tmpdir) |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
844 |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
845 # Automatically removing tmpdir sounds convenient, but could |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
846 # really annoy anyone in the habit of using "--tmpdir=/tmp" |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
847 # or "--tmpdir=$HOME". |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
848 #vlog("# Removing temp dir", tmpdir) |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
849 #shutil.rmtree(tmpdir) |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
850 os.makedirs(tmpdir) |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
851 else: |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
852 tmpdir = tempfile.mkdtemp('', 'hgtests.') |
f8b4df4b033d
run-tests: make --tmpdir option more useful.
Greg Ward <greg-hg@gerg.ca>
parents:
9582
diff
changeset
|
853 HGTMP = os.environ['HGTMP'] = os.path.realpath(tmpdir) |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
854 DAEMON_PIDS = None |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
855 HGRCPATH = None |
8093
70d8f70264c4
run-tests: move bits of main program so it's all at the bottom.
Greg Ward <greg-hg@gerg.ca>
parents:
8092
diff
changeset
|
856 |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
857 os.environ["HGEDITOR"] = sys.executable + ' -c "import sys; sys.exit(0)"' |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
858 os.environ["HGMERGE"] = "internal:merge" |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
859 os.environ["HGUSER"] = "test" |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
860 os.environ["HGENCODING"] = "ascii" |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
861 os.environ["HGENCODINGMODE"] = "strict" |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
862 os.environ["HGPORT"] = str(options.port) |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
863 os.environ["HGPORT1"] = str(options.port + 1) |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
864 os.environ["HGPORT2"] = str(options.port + 2) |
8093
70d8f70264c4
run-tests: move bits of main program so it's all at the bottom.
Greg Ward <greg-hg@gerg.ca>
parents:
8092
diff
changeset
|
865 |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
866 if options.with_hg: |
8674
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
867 INST = None |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
868 BINDIR = os.path.dirname(os.path.realpath(options.with_hg)) |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
869 |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
870 # This looks redundant with how Python initializes sys.path from |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
871 # the location of the script being executed. Needed because the |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
872 # "hg" specified by --with-hg is not the only Python script |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
873 # executed in the test suite that needs to import 'mercurial' |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
874 # ... which means it's not really redundant at all. |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
875 PYTHONDIR = BINDIR |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
876 else: |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
877 INST = os.path.join(HGTMP, "install") |
8674
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
878 BINDIR = os.environ["BINDIR"] = os.path.join(INST, "bin") |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
879 PYTHONDIR = os.path.join(INST, "lib", "python") |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
880 |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
881 os.environ["BINDIR"] = BINDIR |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
882 os.environ["PYTHON"] = PYTHON |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
883 |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
884 if not options.child: |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
885 path = [BINDIR] + os.environ["PATH"].split(os.pathsep) |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
886 os.environ["PATH"] = os.pathsep.join(path) |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
887 |
8724
6e41d3c5619f
Unbreak run-tests support for out-of-tree extensions
Brendan Cully <brendan@kublai.com>
parents:
8696
diff
changeset
|
888 # Include TESTDIR in PYTHONPATH so that out-of-tree extensions |
6e41d3c5619f
Unbreak run-tests support for out-of-tree extensions
Brendan Cully <brendan@kublai.com>
parents:
8696
diff
changeset
|
889 # can run .../tests/run-tests.py test-foo where test-foo |
6e41d3c5619f
Unbreak run-tests support for out-of-tree extensions
Brendan Cully <brendan@kublai.com>
parents:
8696
diff
changeset
|
890 # adds an extension to HGRC |
6e41d3c5619f
Unbreak run-tests support for out-of-tree extensions
Brendan Cully <brendan@kublai.com>
parents:
8696
diff
changeset
|
891 pypath = [PYTHONDIR, TESTDIR] |
8687
78ab2a12b4d9
run-tests: don't replace PYTHONPATH, just augment it.
Greg Ward <greg-hg@gerg.ca>
parents:
8674
diff
changeset
|
892 # We have to augment PYTHONPATH, rather than simply replacing |
78ab2a12b4d9
run-tests: don't replace PYTHONPATH, just augment it.
Greg Ward <greg-hg@gerg.ca>
parents:
8674
diff
changeset
|
893 # it, in case external libraries are only available via current |
78ab2a12b4d9
run-tests: don't replace PYTHONPATH, just augment it.
Greg Ward <greg-hg@gerg.ca>
parents:
8674
diff
changeset
|
894 # PYTHONPATH. (In particular, the Subversion bindings on OS X |
78ab2a12b4d9
run-tests: don't replace PYTHONPATH, just augment it.
Greg Ward <greg-hg@gerg.ca>
parents:
8674
diff
changeset
|
895 # are in /opt/subversion.) |
8724
6e41d3c5619f
Unbreak run-tests support for out-of-tree extensions
Brendan Cully <brendan@kublai.com>
parents:
8696
diff
changeset
|
896 oldpypath = os.environ.get('PYTHONPATH') |
6e41d3c5619f
Unbreak run-tests support for out-of-tree extensions
Brendan Cully <brendan@kublai.com>
parents:
8696
diff
changeset
|
897 if oldpypath: |
6e41d3c5619f
Unbreak run-tests support for out-of-tree extensions
Brendan Cully <brendan@kublai.com>
parents:
8696
diff
changeset
|
898 pypath.append(oldpypath) |
6e41d3c5619f
Unbreak run-tests support for out-of-tree extensions
Brendan Cully <brendan@kublai.com>
parents:
8696
diff
changeset
|
899 os.environ['PYTHONPATH'] = os.pathsep.join(pypath) |
8674
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
900 |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
901 COVERAGE_FILE = os.path.join(TESTDIR, ".coverage") |
8093
70d8f70264c4
run-tests: move bits of main program so it's all at the bottom.
Greg Ward <greg-hg@gerg.ca>
parents:
8092
diff
changeset
|
902 |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
903 if len(args) == 0: |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
904 args = os.listdir(".") |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
905 args.sort() |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
906 |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
907 tests = [] |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
908 for test in args: |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
909 if (test.startswith("test-") and '~' not in test and |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
910 ('.' not in test or test.endswith('.py') or |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
911 test.endswith('.bat'))): |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
912 tests.append(test) |
8592
cc22b4168879
runtest: do not start testing when there is no test
Simon Heimberg <simohe@besonet.ch>
parents:
8397
diff
changeset
|
913 if not tests: |
cc22b4168879
runtest: do not start testing when there is no test
Simon Heimberg <simohe@besonet.ch>
parents:
8397
diff
changeset
|
914 print "# Ran 0 tests, 0 skipped, 0 failed." |
cc22b4168879
runtest: do not start testing when there is no test
Simon Heimberg <simohe@besonet.ch>
parents:
8397
diff
changeset
|
915 return |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
916 |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
917 vlog("# Using TESTDIR", TESTDIR) |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
918 vlog("# Using HGTMP", HGTMP) |
8674
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
919 vlog("# Using PATH", os.environ["PATH"]) |
0941ee76489e
run-tests: redefine --with-hg so it takes the 'hg' script to run.
Greg Ward <greg-hg@gerg.ca>
parents:
8673
diff
changeset
|
920 vlog("# Using PYTHONPATH", os.environ["PYTHONPATH"]) |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
921 |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
922 try: |
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
923 if len(tests) > 1 and options.jobs > 1: |
8672
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
924 runchildren(options, tests) |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
925 else: |
8672
d6b243731763
run-tests: factor out _checkhglib() to check import path of 'mercurial'.
Greg Ward <greg-hg@gerg.ca>
parents:
8671
diff
changeset
|
926 runtests(options, tests) |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
927 finally: |
8097
eea3c1a8fba8
run-tests: removed some underscores (coding style)
Martin Geisler <mg@lazybytes.net>
parents:
8096
diff
changeset
|
928 cleanup(options) |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5383
diff
changeset
|
929 |
8094
60a9e3cf0cf4
run-tests: factor out main(); reduce use of globals a bit.
Greg Ward <greg-hg@gerg.ca>
parents:
8093
diff
changeset
|
930 main() |