Mercurial > hg > hg-git
annotate tests/run-tests.py @ 1063:c249de74742b
compat: use config registrar if available
author | Kevin Bullock <kbullock@ringworld.org> |
---|---|
date | Wed, 01 Nov 2017 20:05:44 -0500 (2017-11-02) |
parents | e085b381e8e2 |
children |
rev | line source |
---|---|
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
2 # |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 # run-tests.py - Run a set of tests on Mercurial |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 # |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 # Copyright 2006 Matt Mackall <mpm@selenic.com> |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 # |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 # This software may be used and distributed according to the terms of the |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
8 # GNU General Public License version 2 or any later version. |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
10 # Modifying this script is tricky because it has many modes: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
11 # - serial (default) vs parallel (-jN, N > 1) |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
12 # - no coverage (default) vs coverage (-c, -C, -s) |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
13 # - temp install (default) vs specific hg script (--with-hg, --local) |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
14 # - tests are a mix of shell scripts and Python scripts |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
15 # |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
16 # If you change this script, it is recommended that you ensure you |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
17 # haven't broken it by running it in various modes with a representative |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
18 # sample of test scripts. For example: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
19 # |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
20 # 1) serial, no coverage, temp install: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
21 # ./run-tests.py test-s* |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
22 # 2) serial, no coverage, local hg: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
23 # ./run-tests.py --local test-s* |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
24 # 3) serial, coverage, temp install: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
25 # ./run-tests.py -c test-s* |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
26 # 4) serial, coverage, local hg: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
27 # ./run-tests.py -c --local test-s* # unsupported |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
28 # 5) parallel, no coverage, temp install: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
29 # ./run-tests.py -j2 test-s* |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
30 # 6) parallel, no coverage, local hg: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
31 # ./run-tests.py -j2 --local test-s* |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
32 # 7) parallel, coverage, temp install: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
33 # ./run-tests.py -j2 -c test-s* # currently broken |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
34 # 8) parallel, coverage, local install: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
35 # ./run-tests.py -j2 -c --local test-s* # unsupported (and broken) |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
36 # 9) parallel, custom tmp dir: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
37 # ./run-tests.py -j2 --tmpdir /tmp/myhgtests |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
38 # 10) parallel, pure, tests that call run-tests: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
39 # ./run-tests.py --pure `grep -l run-tests.py *.t` |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
40 # |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
41 # (You could use any subset of the tests: test-s* happens to match |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
42 # enough that it's worth doing parallel runs, few enough that it |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
43 # completes fairly quickly, includes both shell and Python scripts, and |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
44 # includes some scripts that run daemon processes.) |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
45 |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
46 from __future__ import absolute_import, print_function |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
47 |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 import difflib |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
49 import distutils.version as version |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 import errno |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
51 import json |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 import optparse |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 import os |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
54 import random |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
55 import re |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
56 import shutil |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
57 import signal |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
58 import socket |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
59 import subprocess |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
60 import sys |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
61 import sysconfig |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
62 import tempfile |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
63 import threading |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
64 import time |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
65 import unittest |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
66 import xml.dom.minidom as minidom |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
67 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
68 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
69 import Queue as queue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
70 except ImportError: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
71 import queue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
72 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
73 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
74 import shlex |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
75 shellquote = shlex.quote |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
76 except (ImportError, AttributeError): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
77 import pipes |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
78 shellquote = pipes.quote |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
79 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
80 if os.environ.get('RTUNICODEPEDANTRY', False): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
81 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
82 reload(sys) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
83 sys.setdefaultencoding("undefined") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
84 except NameError: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
85 pass |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
86 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
87 origenviron = os.environ.copy() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
88 osenvironb = getattr(os, 'environb', os.environ) |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
89 processlock = threading.Lock() |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
90 |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
91 pygmentspresent = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
92 # ANSI color is unsupported prior to Windows 10 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
93 if os.name != 'nt': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
94 try: # is pygments installed |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
95 import pygments |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
96 import pygments.lexers as lexers |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
97 import pygments.lexer as lexer |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
98 import pygments.formatters as formatters |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
99 import pygments.token as token |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
100 import pygments.style as style |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
101 pygmentspresent = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
102 difflexer = lexers.DiffLexer() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
103 terminal256formatter = formatters.Terminal256Formatter() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
104 except ImportError: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
105 pass |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
106 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
107 if pygmentspresent: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
108 class TestRunnerStyle(style.Style): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
109 default_style = "" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
110 skipped = token.string_to_tokentype("Token.Generic.Skipped") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
111 failed = token.string_to_tokentype("Token.Generic.Failed") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
112 skippedname = token.string_to_tokentype("Token.Generic.SName") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
113 failedname = token.string_to_tokentype("Token.Generic.FName") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
114 styles = { |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
115 skipped: '#e5e5e5', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
116 skippedname: '#00ffff', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
117 failed: '#7f0000', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
118 failedname: '#ff0000', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
119 } |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
120 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
121 class TestRunnerLexer(lexer.RegexLexer): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
122 tokens = { |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
123 'root': [ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
124 (r'^Skipped', token.Generic.Skipped, 'skipped'), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
125 (r'^Failed ', token.Generic.Failed, 'failed'), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
126 (r'^ERROR: ', token.Generic.Failed, 'failed'), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
127 ], |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
128 'skipped': [ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
129 (r'[\w-]+\.(t|py)', token.Generic.SName), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
130 (r':.*', token.Generic.Skipped), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
131 ], |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
132 'failed': [ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
133 (r'[\w-]+\.(t|py)', token.Generic.FName), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
134 (r'(:| ).*', token.Generic.Failed), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
135 ] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
136 } |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
137 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
138 runnerformatter = formatters.Terminal256Formatter(style=TestRunnerStyle) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
139 runnerlexer = TestRunnerLexer() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
140 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
141 if sys.version_info > (3, 5, 0): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
142 PYTHON3 = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
143 xrange = range # we use xrange in one place, and we'd rather not use range |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
144 def _bytespath(p): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
145 if p is None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
146 return p |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
147 return p.encode('utf-8') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
148 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
149 def _strpath(p): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
150 if p is None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
151 return p |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
152 return p.decode('utf-8') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
153 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
154 elif sys.version_info >= (3, 0, 0): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
155 print('%s is only supported on Python 3.5+ and 2.7, not %s' % |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
156 (sys.argv[0], '.'.join(str(v) for v in sys.version_info[:3]))) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
157 sys.exit(70) # EX_SOFTWARE from `man 3 sysexit` |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
158 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
159 PYTHON3 = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
160 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
161 # In python 2.x, path operations are generally done using |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
162 # bytestrings by default, so we don't have to do any extra |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
163 # fiddling there. We define the wrapper functions anyway just to |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
164 # help keep code consistent between platforms. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
165 def _bytespath(p): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
166 return p |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
167 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
168 _strpath = _bytespath |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
169 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
170 # For Windows support |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
171 wifexited = getattr(os, "WIFEXITED", lambda x: False) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
172 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
173 # Whether to use IPv6 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
174 def checksocketfamily(name, port=20058): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
175 """return true if we can listen on localhost using family=name |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
176 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
177 name should be either 'AF_INET', or 'AF_INET6'. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
178 port being used is okay - EADDRINUSE is considered as successful. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
179 """ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
180 family = getattr(socket, name, None) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
181 if family is None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
182 return False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
183 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
184 s = socket.socket(family, socket.SOCK_STREAM) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
185 s.bind(('localhost', port)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
186 s.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
187 return True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
188 except socket.error as exc: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
189 if exc.errno == errno.EADDRINUSE: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
190 return True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
191 elif exc.errno in (errno.EADDRNOTAVAIL, errno.EPROTONOSUPPORT): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
192 return False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
193 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
194 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
195 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
196 return False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
197 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
198 # useipv6 will be set by parseargs |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
199 useipv6 = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
200 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
201 def checkportisavailable(port): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
202 """return true if a port seems free to bind on localhost""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
203 if useipv6: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
204 family = socket.AF_INET6 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
205 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
206 family = socket.AF_INET |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
207 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
208 s = socket.socket(family, socket.SOCK_STREAM) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
209 s.bind(('localhost', port)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
210 s.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
211 return True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
212 except socket.error as exc: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
213 if exc.errno not in (errno.EADDRINUSE, errno.EADDRNOTAVAIL, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
214 errno.EPROTONOSUPPORT): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
215 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
216 return False |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
217 |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
218 closefds = os.name == 'posix' |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
219 def Popen4(cmd, wd, timeout, env=None): |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
220 processlock.acquire() |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
221 p = subprocess.Popen(cmd, shell=True, bufsize=-1, cwd=wd, env=env, |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
222 close_fds=closefds, |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
223 stdin=subprocess.PIPE, stdout=subprocess.PIPE, |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
224 stderr=subprocess.STDOUT) |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
225 processlock.release() |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
226 |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
227 p.fromchild = p.stdout |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
228 p.tochild = p.stdin |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
229 p.childerr = p.stderr |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
230 |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
231 p.timeout = False |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
232 if timeout: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
233 def t(): |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
234 start = time.time() |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
235 while time.time() - start < timeout and p.returncode is None: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
236 time.sleep(.1) |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
237 p.timeout = True |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
238 if p.returncode is None: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
239 terminate(p) |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
240 threading.Thread(target=t).start() |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
241 |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
242 return p |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
243 |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
244 PYTHON = _bytespath(sys.executable.replace('\\', '/')) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
245 IMPL_PATH = b'PYTHONPATH' |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
246 if 'java' in sys.platform: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
247 IMPL_PATH = b'JYTHONPATH' |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
248 |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
249 defaults = { |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
250 'jobs': ('HGTEST_JOBS', 1), |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
251 'timeout': ('HGTEST_TIMEOUT', 180), |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
252 'slowtimeout': ('HGTEST_SLOWTIMEOUT', 500), |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
253 'port': ('HGTEST_PORT', 20059), |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
254 'shell': ('HGTEST_SHELL', 'sh'), |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
255 } |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
256 |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
257 def canonpath(path): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
258 return os.path.realpath(os.path.expanduser(path)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
259 |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
260 def parselistfiles(files, listtype, warn=True): |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
261 entries = dict() |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
262 for filename in files: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
263 try: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
264 path = os.path.expanduser(os.path.expandvars(filename)) |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
265 f = open(path, "rb") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
266 except IOError as err: |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
267 if err.errno != errno.ENOENT: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
268 raise |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
269 if warn: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
270 print("warning: no such %s file: %s" % (listtype, filename)) |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
271 continue |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
272 |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
273 for line in f.readlines(): |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
274 line = line.split(b'#', 1)[0].strip() |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
275 if line: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
276 entries[line] = filename |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
277 |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
278 f.close() |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
279 return entries |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
280 |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
281 def parsettestcases(path): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
282 """read a .t test file, return a set of test case names |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
283 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
284 If path does not exist, return an empty set. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
285 """ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
286 cases = set() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
287 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
288 with open(path, 'rb') as f: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
289 for l in f: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
290 if l.startswith(b'#testcases '): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
291 cases.update(l[11:].split()) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
292 except IOError as ex: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
293 if ex.errno != errno.ENOENT: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
294 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
295 return cases |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
296 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
297 def getparser(): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
298 """Obtain the OptionParser used by the CLI.""" |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
299 parser = optparse.OptionParser("%prog [options] [tests]") |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
300 |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
301 # keep these sorted |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
302 parser.add_option("--blacklist", action="append", |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
303 help="skip tests listed in the specified blacklist file") |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
304 parser.add_option("--whitelist", action="append", |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
305 help="always run tests listed in the specified whitelist file") |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
306 parser.add_option("--test-list", action="append", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
307 help="read tests to run from the specified file") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
308 parser.add_option("--changed", type="string", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
309 help="run tests that are changed in parent rev or working directory") |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
310 parser.add_option("-C", "--annotate", action="store_true", |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
311 help="output files annotated with coverage") |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
312 parser.add_option("-c", "--cover", action="store_true", |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
313 help="print a test coverage report") |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
314 parser.add_option("--color", choices=["always", "auto", "never"], |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
315 default=os.environ.get('HGRUNTESTSCOLOR', 'auto'), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
316 help="colorisation: always|auto|never (default: auto)") |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
317 parser.add_option("-d", "--debug", action="store_true", |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
318 help="debug mode: write output of test scripts to console" |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
319 " rather than capturing and diffing it (disables timeout)") |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
320 parser.add_option("-f", "--first", action="store_true", |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
321 help="exit on the first test failure") |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
322 parser.add_option("-H", "--htmlcov", action="store_true", |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
323 help="create an HTML report of the coverage of the files") |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
324 parser.add_option("-i", "--interactive", action="store_true", |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
325 help="prompt to accept changed output") |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
326 parser.add_option("-j", "--jobs", type="int", |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
327 help="number of jobs to run in parallel" |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
328 " (default: $%s or %d)" % defaults['jobs']) |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
329 parser.add_option("--keep-tmpdir", action="store_true", |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
330 help="keep temporary directory after running tests") |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
331 parser.add_option("-k", "--keywords", |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
332 help="run tests matching keywords") |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
333 parser.add_option("--list-tests", action="store_true", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
334 help="list tests instead of running them") |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
335 parser.add_option("-l", "--local", action="store_true", |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
336 help="shortcut for --with-hg=<testdir>/../hg, " |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
337 "and --with-chg=<testdir>/../contrib/chg/chg if --chg is set") |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
338 parser.add_option("--loop", action="store_true", |
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
339 help="loop tests repeatedly") |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
340 parser.add_option("--runs-per-test", type="int", dest="runs_per_test", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
341 help="run each test N times (default=1)", default=1) |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
342 parser.add_option("-n", "--nodiff", action="store_true", |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
343 help="skip showing test changes") |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
344 parser.add_option("--outputdir", type="string", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
345 help="directory to write error logs to (default=test directory)") |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
346 parser.add_option("-p", "--port", type="int", |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
347 help="port on which servers should listen" |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
348 " (default: $%s or %d)" % defaults['port']) |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
349 parser.add_option("--compiler", type="string", |
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
350 help="compiler to build with") |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
351 parser.add_option("--pure", action="store_true", |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
352 help="use pure Python code instead of C extensions") |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
353 parser.add_option("-R", "--restart", action="store_true", |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
354 help="restart at last error") |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
355 parser.add_option("-r", "--retest", action="store_true", |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
356 help="retest failed tests") |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
357 parser.add_option("-S", "--noskips", action="store_true", |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
358 help="don't report skip tests verbosely") |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
359 parser.add_option("--shell", type="string", |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
360 help="shell to use (default: $%s or %s)" % defaults['shell']) |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
361 parser.add_option("-t", "--timeout", type="int", |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
362 help="kill errant tests after TIMEOUT seconds" |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
363 " (default: $%s or %d)" % defaults['timeout']) |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
364 parser.add_option("--slowtimeout", type="int", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
365 help="kill errant slow tests after SLOWTIMEOUT seconds" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
366 " (default: $%s or %d)" % defaults['slowtimeout']) |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
367 parser.add_option("--time", action="store_true", |
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
368 help="time how long each test takes") |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
369 parser.add_option("--json", action="store_true", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
370 help="store test result data in 'report.json' file") |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
371 parser.add_option("--tmpdir", type="string", |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
372 help="run tests in the given temporary directory" |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
373 " (implies --keep-tmpdir)") |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
374 parser.add_option("-v", "--verbose", action="store_true", |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
375 help="output verbose messages") |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
376 parser.add_option("--xunit", type="string", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
377 help="record xunit results at specified path") |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
378 parser.add_option("--view", type="string", |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
379 help="external diff viewer") |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
380 parser.add_option("--with-hg", type="string", |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
381 metavar="HG", |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
382 help="test using specified hg script rather than a " |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
383 "temporary installation") |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
384 parser.add_option("--chg", action="store_true", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
385 help="install and use chg wrapper in place of hg") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
386 parser.add_option("--with-chg", metavar="CHG", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
387 help="use specified chg wrapper in place of hg") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
388 parser.add_option("--ipv6", action="store_true", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
389 help="prefer IPv6 to IPv4 for network related tests") |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
390 parser.add_option("-3", "--py3k-warnings", action="store_true", |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
391 help="enable Py3k warnings on Python 2.7+") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
392 # This option should be deleted once test-check-py3-compat.t and other |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
393 # Python 3 tests run with Python 3. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
394 parser.add_option("--with-python3", metavar="PYTHON3", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
395 help="Python 3 interpreter (if running under Python 2)" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
396 " (TEMPORARY)") |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
397 parser.add_option('--extra-config-opt', action="append", |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
398 help='set the given config opt in the test hgrc') |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
399 parser.add_option('--random', action="store_true", |
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
400 help='run tests in random order') |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
401 parser.add_option('--profile-runner', action='store_true', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
402 help='run statprof on run-tests') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
403 parser.add_option('--allow-slow-tests', action='store_true', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
404 help='allow extremely slow tests') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
405 parser.add_option('--showchannels', action='store_true', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
406 help='show scheduling channels') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
407 parser.add_option('--known-good-rev', type="string", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
408 metavar="known_good_rev", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
409 help=("Automatically bisect any failures using this " |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
410 "revision as a known-good revision.")) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
411 parser.add_option('--bisect-repo', type="string", |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
412 metavar='bisect_repo', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
413 help=("Path of a repo to bisect. Use together with " |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
414 "--known-good-rev")) |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
415 |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
416 for option, (envvar, default) in defaults.items(): |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
417 defaults[option] = type(default)(os.environ.get(envvar, default)) |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
418 parser.set_defaults(**defaults) |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
419 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
420 return parser |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
421 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
422 def parseargs(args, parser): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
423 """Parse arguments with our OptionParser and validate results.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
424 (options, args) = parser.parse_args(args) |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
425 |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
426 # jython is always pure |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
427 if 'java' in sys.platform or '__pypy__' in sys.modules: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
428 options.pure = True |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
429 |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
430 if options.with_hg: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
431 options.with_hg = canonpath(_bytespath(options.with_hg)) |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
432 if not (os.path.isfile(options.with_hg) and |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
433 os.access(options.with_hg, os.X_OK)): |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
434 parser.error('--with-hg must specify an executable hg script') |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
435 if os.path.basename(options.with_hg) not in [b'hg', b'hg.exe']: |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
436 sys.stderr.write('warning: --with-hg should specify an hg script\n') |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
437 if options.local: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
438 testdir = os.path.dirname(_bytespath(canonpath(sys.argv[0]))) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
439 reporootdir = os.path.dirname(testdir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
440 pathandattrs = [(b'hg', 'with_hg')] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
441 if options.chg: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
442 pathandattrs.append((b'contrib/chg/chg', 'with_chg')) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
443 for relpath, attr in pathandattrs: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
444 binpath = os.path.join(reporootdir, relpath) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
445 if os.name != 'nt' and not os.access(binpath, os.X_OK): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
446 parser.error('--local specified, but %r not found or ' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
447 'not executable' % binpath) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
448 setattr(options, attr, binpath) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
449 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
450 if (options.chg or options.with_chg) and os.name == 'nt': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
451 parser.error('chg does not work on %s' % os.name) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
452 if options.with_chg: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
453 options.chg = False # no installation to temporary location |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
454 options.with_chg = canonpath(_bytespath(options.with_chg)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
455 if not (os.path.isfile(options.with_chg) and |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
456 os.access(options.with_chg, os.X_OK)): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
457 parser.error('--with-chg must specify a chg executable') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
458 if options.chg and options.with_hg: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
459 # chg shares installation location with hg |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
460 parser.error('--chg does not work when --with-hg is specified ' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
461 '(use --with-chg instead)') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
462 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
463 if options.color == 'always' and not pygmentspresent: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
464 sys.stderr.write('warning: --color=always ignored because ' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
465 'pygments is not installed\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
466 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
467 if options.bisect_repo and not options.known_good_rev: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
468 parser.error("--bisect-repo cannot be used without --known-good-rev") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
469 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
470 global useipv6 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
471 if options.ipv6: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
472 useipv6 = checksocketfamily('AF_INET6') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
473 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
474 # only use IPv6 if IPv4 is unavailable and IPv6 is available |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
475 useipv6 = ((not checksocketfamily('AF_INET')) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
476 and checksocketfamily('AF_INET6')) |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
477 |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
478 options.anycoverage = options.cover or options.annotate or options.htmlcov |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
479 if options.anycoverage: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
480 try: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
481 import coverage |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
482 covver = version.StrictVersion(coverage.__version__).version |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
483 if covver < (3, 3): |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
484 parser.error('coverage options require coverage 3.3 or later') |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
485 except ImportError: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
486 parser.error('coverage options now require the coverage package') |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
487 |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
488 if options.anycoverage and options.local: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
489 # this needs some path mangling somewhere, I guess |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
490 parser.error("sorry, coverage options do not work when --local " |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
491 "is specified") |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
492 |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
493 if options.anycoverage and options.with_hg: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
494 parser.error("sorry, coverage options do not work when --with-hg " |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
495 "is specified") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
496 |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
497 global verbose |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
498 if options.verbose: |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
499 verbose = '' |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
500 |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
501 if options.tmpdir: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
502 options.tmpdir = canonpath(options.tmpdir) |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
503 |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
504 if options.jobs < 1: |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
505 parser.error('--jobs must be positive') |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
506 if options.interactive and options.debug: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
507 parser.error("-i/--interactive and -d/--debug are incompatible") |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
508 if options.debug: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
509 if options.timeout != defaults['timeout']: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
510 sys.stderr.write( |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
511 'warning: --timeout option ignored with --debug\n') |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
512 if options.slowtimeout != defaults['slowtimeout']: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
513 sys.stderr.write( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
514 'warning: --slowtimeout option ignored with --debug\n') |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
515 options.timeout = 0 |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
516 options.slowtimeout = 0 |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
517 if options.py3k_warnings: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
518 if PYTHON3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
519 parser.error( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
520 '--py3k-warnings can only be used on Python 2.7') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
521 if options.with_python3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
522 if PYTHON3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
523 parser.error('--with-python3 cannot be used when executing with ' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
524 'Python 3') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
525 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
526 options.with_python3 = canonpath(options.with_python3) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
527 # Verify Python3 executable is acceptable. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
528 proc = subprocess.Popen([options.with_python3, b'--version'], |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
529 stdout=subprocess.PIPE, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
530 stderr=subprocess.STDOUT) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
531 out, _err = proc.communicate() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
532 ret = proc.wait() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
533 if ret != 0: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
534 parser.error('could not determine version of python 3') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
535 if not out.startswith('Python '): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
536 parser.error('unexpected output from python3 --version: %s' % |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
537 out) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
538 vers = version.LooseVersion(out[len('Python '):]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
539 if vers < version.LooseVersion('3.5.0'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
540 parser.error('--with-python3 version must be 3.5.0 or greater; ' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
541 'got %s' % out) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
542 |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
543 if options.blacklist: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
544 options.blacklist = parselistfiles(options.blacklist, 'blacklist') |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
545 if options.whitelist: |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
546 options.whitelisted = parselistfiles(options.whitelist, 'whitelist') |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
547 else: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
548 options.whitelisted = {} |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
549 |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
550 if options.showchannels: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
551 options.nodiff = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
552 |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
553 return (options, args) |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
554 |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
555 def rename(src, dst): |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
556 """Like os.rename(), trade atomicity and opened files friendliness |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
557 for existing destination support. |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
558 """ |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
559 shutil.copy(src, dst) |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
560 os.remove(src) |
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
561 |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
562 _unified_diff = difflib.unified_diff |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
563 if PYTHON3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
564 import functools |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
565 _unified_diff = functools.partial(difflib.diff_bytes, difflib.unified_diff) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
566 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
567 def getdiff(expected, output, ref, err): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
568 servefail = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
569 lines = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
570 for line in _unified_diff(expected, output, ref, err): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
571 if line.startswith(b'+++') or line.startswith(b'---'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
572 line = line.replace(b'\\', b'/') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
573 if line.endswith(b' \n'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
574 line = line[:-2] + b'\n' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
575 lines.append(line) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
576 if not servefail and line.startswith( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
577 b'+ abort: child process failed to start'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
578 servefail = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
579 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
580 return servefail, lines |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
581 |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
582 verbose = False |
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
583 def vlog(*msg): |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
584 """Log only when in verbose mode.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
585 if verbose is False: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
586 return |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
587 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
588 return log(*msg) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
589 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
590 # Bytes that break XML even in a CDATA block: control characters 0-31 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
591 # sans \t, \n and \r |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
592 CDATA_EVIL = re.compile(br"[\000-\010\013\014\016-\037]") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
593 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
594 # Match feature conditionalized output lines in the form, capturing the feature |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
595 # list in group 2, and the preceeding line output in group 1: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
596 # |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
597 # output..output (feature !)\n |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
598 optline = re.compile(b'(.*) \((.+?) !\)\n$') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
599 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
600 def cdatasafe(data): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
601 """Make a string safe to include in a CDATA block. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
602 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
603 Certain control characters are illegal in a CDATA block, and |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
604 there's no way to include a ]]> in a CDATA either. This function |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
605 replaces illegal bytes with ? and adds a space between the ]] so |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
606 that it won't break the CDATA block. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
607 """ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
608 return CDATA_EVIL.sub(b'?', data).replace(b']]>', b'] ]>') |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
609 |
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
610 def log(*msg): |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
611 """Log something to stdout. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
612 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
613 Arguments are strings to print. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
614 """ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
615 with iolock: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
616 if verbose: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
617 print(verbose, end=' ') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
618 for m in msg: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
619 print(m, end=' ') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
620 print() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
621 sys.stdout.flush() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
622 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
623 def highlightdiff(line, color): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
624 if not color: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
625 return line |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
626 assert pygmentspresent |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
627 return pygments.highlight(line.decode('latin1'), difflexer, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
628 terminal256formatter).encode('latin1') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
629 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
630 def highlightmsg(msg, color): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
631 if not color: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
632 return msg |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
633 assert pygmentspresent |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
634 return pygments.highlight(msg, runnerlexer, runnerformatter) |
32
4ee030a94d79
Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
635 |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
636 def terminate(proc): |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
637 """Terminate subprocess""" |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
638 vlog('# Terminating process %d' % proc.pid) |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
639 try: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
640 proc.terminate() |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
641 except OSError: |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
642 pass |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
643 |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
644 def killdaemons(pidfile): |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
645 import killdaemons as killmod |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
646 return killmod.killdaemons(pidfile, tryhard=False, remove=True, |
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
647 logfn=vlog) |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
648 |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
649 class Test(unittest.TestCase): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
650 """Encapsulates a single, runnable test. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
651 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
652 While this class conforms to the unittest.TestCase API, it differs in that |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
653 instances need to be instantiated manually. (Typically, unittest.TestCase |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
654 classes are instantiated automatically by scanning modules.) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
655 """ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
656 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
657 # Status code reserved for skipped tests (used by hghave). |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
658 SKIPPED_STATUS = 80 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
659 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
660 def __init__(self, path, outputdir, tmpdir, keeptmpdir=False, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
661 debug=False, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
662 timeout=None, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
663 startport=None, extraconfigopts=None, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
664 py3kwarnings=False, shell=None, hgcommand=None, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
665 slowtimeout=None, usechg=False, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
666 useipv6=False): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
667 """Create a test from parameters. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
668 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
669 path is the full path to the file defining the test. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
670 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
671 tmpdir is the main temporary directory to use for this test. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
672 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
673 keeptmpdir determines whether to keep the test's temporary directory |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
674 after execution. It defaults to removal (False). |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
675 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
676 debug mode will make the test execute verbosely, with unfiltered |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
677 output. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
678 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
679 timeout controls the maximum run time of the test. It is ignored when |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
680 debug is True. See slowtimeout for tests with #require slow. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
681 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
682 slowtimeout overrides timeout if the test has #require slow. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
683 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
684 startport controls the starting port number to use for this test. Each |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
685 test will reserve 3 port numbers for execution. It is the caller's |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
686 responsibility to allocate a non-overlapping port range to Test |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
687 instances. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
688 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
689 extraconfigopts is an iterable of extra hgrc config options. Values |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
690 must have the form "key=value" (something understood by hgrc). Values |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
691 of the form "foo.key=value" will result in "[foo] key=value". |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
692 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
693 py3kwarnings enables Py3k warnings. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
694 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
695 shell is the shell to execute tests in. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
696 """ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
697 if timeout is None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
698 timeout = defaults['timeout'] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
699 if startport is None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
700 startport = defaults['port'] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
701 if slowtimeout is None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
702 slowtimeout = defaults['slowtimeout'] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
703 self.path = path |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
704 self.bname = os.path.basename(path) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
705 self.name = _strpath(self.bname) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
706 self._testdir = os.path.dirname(path) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
707 self._outputdir = outputdir |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
708 self._tmpname = os.path.basename(path) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
709 self.errpath = os.path.join(self._outputdir, b'%s.err' % self.bname) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
710 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
711 self._threadtmp = tmpdir |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
712 self._keeptmpdir = keeptmpdir |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
713 self._debug = debug |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
714 self._timeout = timeout |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
715 self._slowtimeout = slowtimeout |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
716 self._startport = startport |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
717 self._extraconfigopts = extraconfigopts or [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
718 self._py3kwarnings = py3kwarnings |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
719 self._shell = _bytespath(shell) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
720 self._hgcommand = hgcommand or b'hg' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
721 self._usechg = usechg |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
722 self._useipv6 = useipv6 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
723 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
724 self._aborted = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
725 self._daemonpids = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
726 self._finished = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
727 self._ret = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
728 self._out = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
729 self._skipped = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
730 self._testtmp = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
731 self._chgsockdir = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
732 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
733 self._refout = self.readrefout() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
734 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
735 def readrefout(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
736 """read reference output""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
737 # If we're not in --debug mode and reference output file exists, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
738 # check test output against it. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
739 if self._debug: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
740 return None # to match "out is None" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
741 elif os.path.exists(self.refpath): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
742 with open(self.refpath, 'rb') as f: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
743 return f.read().splitlines(True) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
744 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
745 return [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
746 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
747 # needed to get base class __repr__ running |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
748 @property |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
749 def _testMethodName(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
750 return self.name |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
751 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
752 def __str__(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
753 return self.name |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
754 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
755 def shortDescription(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
756 return self.name |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
757 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
758 def setUp(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
759 """Tasks to perform before run().""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
760 self._finished = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
761 self._ret = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
762 self._out = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
763 self._skipped = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
764 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
765 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
766 os.mkdir(self._threadtmp) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
767 except OSError as e: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
768 if e.errno != errno.EEXIST: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
769 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
770 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
771 name = self._tmpname |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
772 self._testtmp = os.path.join(self._threadtmp, name) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
773 os.mkdir(self._testtmp) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
774 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
775 # Remove any previous output files. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
776 if os.path.exists(self.errpath): |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
777 try: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
778 os.remove(self.errpath) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
779 except OSError as e: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
780 # We might have raced another test to clean up a .err |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
781 # file, so ignore ENOENT when removing a previous .err |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
782 # file. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
783 if e.errno != errno.ENOENT: |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
784 raise |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
785 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
786 if self._usechg: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
787 self._chgsockdir = os.path.join(self._threadtmp, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
788 b'%s.chgsock' % name) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
789 os.mkdir(self._chgsockdir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
790 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
791 def run(self, result): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
792 """Run this test and report results against a TestResult instance.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
793 # This function is extremely similar to unittest.TestCase.run(). Once |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
794 # we require Python 2.7 (or at least its version of unittest), this |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
795 # function can largely go away. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
796 self._result = result |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
797 result.startTest(self) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
798 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
799 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
800 self.setUp() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
801 except (KeyboardInterrupt, SystemExit): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
802 self._aborted = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
803 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
804 except Exception: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
805 result.addError(self, sys.exc_info()) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
806 return |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
807 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
808 success = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
809 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
810 self.runTest() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
811 except KeyboardInterrupt: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
812 self._aborted = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
813 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
814 except unittest.SkipTest as e: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
815 result.addSkip(self, str(e)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
816 # The base class will have already counted this as a |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
817 # test we "ran", but we want to exclude skipped tests |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
818 # from those we count towards those run. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
819 result.testsRun -= 1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
820 except self.failureException as e: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
821 # This differs from unittest in that we don't capture |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
822 # the stack trace. This is for historical reasons and |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
823 # this decision could be revisited in the future, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
824 # especially for PythonTest instances. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
825 if result.addFailure(self, str(e)): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
826 success = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
827 except Exception: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
828 result.addError(self, sys.exc_info()) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
829 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
830 success = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
831 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
832 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
833 self.tearDown() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
834 except (KeyboardInterrupt, SystemExit): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
835 self._aborted = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
836 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
837 except Exception: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
838 result.addError(self, sys.exc_info()) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
839 success = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
840 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
841 if success: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
842 result.addSuccess(self) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
843 finally: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
844 result.stopTest(self, interrupted=self._aborted) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
845 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
846 def runTest(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
847 """Run this test instance. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
848 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
849 This will return a tuple describing the result of the test. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
850 """ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
851 env = self._getenv() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
852 self._genrestoreenv(env) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
853 self._daemonpids.append(env['DAEMON_PIDS']) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
854 self._createhgrc(env['HGRCPATH']) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
855 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
856 vlog('# Test', self.name) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
857 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
858 ret, out = self._run(env) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
859 self._finished = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
860 self._ret = ret |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
861 self._out = out |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
862 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
863 def describe(ret): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
864 if ret < 0: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
865 return 'killed by signal: %d' % -ret |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
866 return 'returned error code %d' % ret |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
867 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
868 self._skipped = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
869 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
870 if ret == self.SKIPPED_STATUS: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
871 if out is None: # Debug mode, nothing to parse. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
872 missing = ['unknown'] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
873 failed = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
874 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
875 missing, failed = TTest.parsehghaveoutput(out) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
876 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
877 if not missing: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
878 missing = ['skipped'] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
879 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
880 if failed: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
881 self.fail('hg have failed checking for %s' % failed[-1]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
882 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
883 self._skipped = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
884 raise unittest.SkipTest(missing[-1]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
885 elif ret == 'timeout': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
886 self.fail('timed out') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
887 elif ret is False: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
888 self.fail('no result code from test') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
889 elif out != self._refout: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
890 # Diff generation may rely on written .err file. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
891 if (ret != 0 or out != self._refout) and not self._skipped \ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
892 and not self._debug: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
893 f = open(self.errpath, 'wb') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
894 for line in out: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
895 f.write(line) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
896 f.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
897 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
898 # The result object handles diff calculation for us. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
899 if self._result.addOutputMismatch(self, ret, out, self._refout): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
900 # change was accepted, skip failing |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
901 return |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
902 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
903 if ret: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
904 msg = 'output changed and ' + describe(ret) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
905 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
906 msg = 'output changed' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
907 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
908 self.fail(msg) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
909 elif ret: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
910 self.fail(describe(ret)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
911 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
912 def tearDown(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
913 """Tasks to perform after run().""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
914 for entry in self._daemonpids: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
915 killdaemons(entry) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
916 self._daemonpids = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
917 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
918 if self._keeptmpdir: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
919 log('\nKeeping testtmp dir: %s\nKeeping threadtmp dir: %s' % |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
920 (self._testtmp.decode('utf-8'), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
921 self._threadtmp.decode('utf-8'))) |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
922 else: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
923 shutil.rmtree(self._testtmp, True) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
924 shutil.rmtree(self._threadtmp, True) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
925 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
926 if self._usechg: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
927 # chgservers will stop automatically after they find the socket |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
928 # files are deleted |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
929 shutil.rmtree(self._chgsockdir, True) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
930 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
931 if (self._ret != 0 or self._out != self._refout) and not self._skipped \ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
932 and not self._debug and self._out: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
933 f = open(self.errpath, 'wb') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
934 for line in self._out: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
935 f.write(line) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
936 f.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
937 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
938 vlog("# Ret was:", self._ret, '(%s)' % self.name) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
939 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
940 def _run(self, env): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
941 # This should be implemented in child classes to run tests. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
942 raise unittest.SkipTest('unknown test type') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
943 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
944 def abort(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
945 """Terminate execution of this test.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
946 self._aborted = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
947 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
948 def _portmap(self, i): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
949 offset = b'' if i == 0 else b'%d' % i |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
950 return (br':%d\b' % (self._startport + i), b':$HGPORT%s' % offset) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
951 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
952 def _getreplacements(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
953 """Obtain a mapping of text replacements to apply to test output. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
954 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
955 Test output needs to be normalized so it can be compared to expected |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
956 output. This function defines how some of that normalization will |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
957 occur. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
958 """ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
959 r = [ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
960 # This list should be parallel to defineport in _getenv |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
961 self._portmap(0), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
962 self._portmap(1), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
963 self._portmap(2), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
964 (br'(?m)^(saved backup bundle to .*\.hg)( \(glob\))?$', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
965 br'\1 (glob)'), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
966 (br'([^0-9])%s' % re.escape(self._localip()), br'\1$LOCALIP'), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
967 (br'\bHG_TXNID=TXN:[a-f0-9]{40}\b', br'HG_TXNID=TXN:$ID$'), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
968 ] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
969 r.append((self._escapepath(self._testtmp), b'$TESTTMP')) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
970 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
971 return r |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
972 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
973 def _escapepath(self, p): |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
974 if os.name == 'nt': |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
975 return ( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
976 (b''.join(c.isalpha() and b'[%s%s]' % (c.lower(), c.upper()) or |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
977 c in b'/\\' and br'[/\\]' or c.isdigit() and c or b'\\' + c |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
978 for c in p)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
979 ) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
980 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
981 return re.escape(p) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
982 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
983 def _localip(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
984 if self._useipv6: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
985 return b'::1' |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
986 else: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
987 return b'127.0.0.1' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
988 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
989 def _genrestoreenv(self, testenv): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
990 """Generate a script that can be used by tests to restore the original |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
991 environment.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
992 # Put the restoreenv script inside self._threadtmp |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
993 scriptpath = os.path.join(self._threadtmp, b'restoreenv.sh') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
994 testenv['HGTEST_RESTOREENV'] = scriptpath |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
995 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
996 # Only restore environment variable names that the shell allows |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
997 # us to export. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
998 name_regex = re.compile('^[a-zA-Z][a-zA-Z0-9_]*$') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
999 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1000 # Do not restore these variables; otherwise tests would fail. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1001 reqnames = {'PYTHON', 'TESTDIR', 'TESTTMP'} |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1002 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1003 with open(scriptpath, 'w') as envf: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1004 for name, value in origenviron.items(): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1005 if not name_regex.match(name): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1006 # Skip environment variables with unusual names not |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1007 # allowed by most shells. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1008 continue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1009 if name in reqnames: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1010 continue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1011 envf.write('%s=%s\n' % (name, shellquote(value))) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1012 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1013 for name in testenv: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1014 if name in origenviron or name in reqnames: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1015 continue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1016 envf.write('unset %s\n' % (name,)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1017 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1018 def _getenv(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1019 """Obtain environment variables to use during test execution.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1020 def defineport(i): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1021 offset = '' if i == 0 else '%s' % i |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1022 env["HGPORT%s" % offset] = '%s' % (self._startport + i) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1023 env = os.environ.copy() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1024 env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1025 env['HGEMITWARNINGS'] = '1' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1026 env['TESTTMP'] = self._testtmp |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1027 env['HOME'] = self._testtmp |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1028 # This number should match portneeded in _getport |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1029 for port in xrange(3): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1030 # This list should be parallel to _portmap in _getreplacements |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1031 defineport(port) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1032 env["HGRCPATH"] = os.path.join(self._threadtmp, b'.hgrc') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1033 env["DAEMON_PIDS"] = os.path.join(self._threadtmp, b'daemon.pids') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1034 env["HGEDITOR"] = ('"' + sys.executable + '"' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1035 + ' -c "import sys; sys.exit(0)"') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1036 env["HGMERGE"] = "internal:merge" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1037 env["HGUSER"] = "test" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1038 env["HGENCODING"] = "ascii" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1039 env["HGENCODINGMODE"] = "strict" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1040 env['HGIPV6'] = str(int(self._useipv6)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1041 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1042 # LOCALIP could be ::1 or 127.0.0.1. Useful for tests that require raw |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1043 # IP addresses. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1044 env['LOCALIP'] = self._localip() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1045 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1046 # Reset some environment variables to well-known values so that |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1047 # the tests produce repeatable output. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1048 env['LANG'] = env['LC_ALL'] = env['LANGUAGE'] = 'C' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1049 env['TZ'] = 'GMT' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1050 env["EMAIL"] = "Foo Bar <foo.bar@example.com>" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1051 env['COLUMNS'] = '80' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1052 env['TERM'] = 'xterm' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1053 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1054 for k in ('HG HGPROF CDPATH GREP_OPTIONS http_proxy no_proxy ' + |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1055 'HGPLAIN HGPLAINEXCEPT EDITOR VISUAL PAGER ' + |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1056 'NO_PROXY CHGDEBUG').split(): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1057 if k in env: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1058 del env[k] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1059 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1060 # unset env related to hooks |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1061 for k in env.keys(): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1062 if k.startswith('HG_'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1063 del env[k] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1064 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1065 if self._usechg: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1066 env['CHGSOCKNAME'] = os.path.join(self._chgsockdir, b'server') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1067 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1068 return env |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1069 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1070 def _createhgrc(self, path): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1071 """Create an hgrc file for this test.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1072 hgrc = open(path, 'wb') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1073 hgrc.write(b'[ui]\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1074 hgrc.write(b'slash = True\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1075 hgrc.write(b'interactive = False\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1076 hgrc.write(b'mergemarkers = detailed\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1077 hgrc.write(b'promptecho = True\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1078 hgrc.write(b'[defaults]\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1079 hgrc.write(b'[devel]\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1080 hgrc.write(b'all-warnings = true\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1081 hgrc.write(b'default-date = 0 0\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1082 hgrc.write(b'[largefiles]\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1083 hgrc.write(b'usercache = %s\n' % |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1084 (os.path.join(self._testtmp, b'.cache/largefiles'))) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1085 hgrc.write(b'[web]\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1086 hgrc.write(b'address = localhost\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1087 hgrc.write(b'ipv6 = %s\n' % str(self._useipv6).encode('ascii')) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1088 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1089 for opt in self._extraconfigopts: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1090 section, key = opt.split('.', 1) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1091 assert '=' in key, ('extra config opt %s must ' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1092 'have an = for assignment' % opt) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1093 hgrc.write(b'[%s]\n%s\n' % (section, key)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1094 hgrc.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1095 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1096 def fail(self, msg): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1097 # unittest differentiates between errored and failed. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1098 # Failed is denoted by AssertionError (by default at least). |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1099 raise AssertionError(msg) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1100 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1101 def _runcommand(self, cmd, env, normalizenewlines=False): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1102 """Run command in a sub-process, capturing the output (stdout and |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1103 stderr). |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1104 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1105 Return a tuple (exitcode, output). output is None in debug mode. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1106 """ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1107 if self._debug: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1108 proc = subprocess.Popen(cmd, shell=True, cwd=self._testtmp, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1109 env=env) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1110 ret = proc.wait() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1111 return (ret, None) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1112 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1113 proc = Popen4(cmd, self._testtmp, self._timeout, env) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1114 def cleanup(): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1115 terminate(proc) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1116 ret = proc.wait() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1117 if ret == 0: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1118 ret = signal.SIGTERM << 8 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1119 killdaemons(env['DAEMON_PIDS']) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1120 return ret |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1121 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1122 output = '' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1123 proc.tochild.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1124 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1125 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1126 output = proc.fromchild.read() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1127 except KeyboardInterrupt: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1128 vlog('# Handling keyboard interrupt') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1129 cleanup() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1130 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1131 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1132 ret = proc.wait() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1133 if wifexited(ret): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1134 ret = os.WEXITSTATUS(ret) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1135 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1136 if proc.timeout: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1137 ret = 'timeout' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1138 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1139 if ret: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1140 killdaemons(env['DAEMON_PIDS']) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1141 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1142 for s, r in self._getreplacements(): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1143 output = re.sub(s, r, output) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1144 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1145 if normalizenewlines: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1146 output = output.replace('\r\n', '\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1147 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1148 return ret, output.splitlines(True) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1149 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1150 class PythonTest(Test): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1151 """A Python-based test.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1152 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1153 @property |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1154 def refpath(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1155 return os.path.join(self._testdir, b'%s.out' % self.bname) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1156 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1157 def _run(self, env): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1158 py3kswitch = self._py3kwarnings and b' -3' or b'' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1159 cmd = b'%s%s "%s"' % (PYTHON, py3kswitch, self.path) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1160 vlog("# Running", cmd) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1161 normalizenewlines = os.name == 'nt' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1162 result = self._runcommand(cmd, env, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1163 normalizenewlines=normalizenewlines) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1164 if self._aborted: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1165 raise KeyboardInterrupt() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1166 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1167 return result |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1168 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1169 # Some glob patterns apply only in some circumstances, so the script |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1170 # might want to remove (glob) annotations that otherwise should be |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1171 # retained. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1172 checkcodeglobpats = [ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1173 # On Windows it looks like \ doesn't require a (glob), but we know |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1174 # better. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1175 re.compile(br'^pushing to \$TESTTMP/.*[^)]$'), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1176 re.compile(br'^moving \S+/.*[^)]$'), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1177 re.compile(br'^pulling from \$TESTTMP/.*[^)]$'), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1178 # Not all platforms have 127.0.0.1 as loopback (though most do), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1179 # so we always glob that too. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1180 re.compile(br'.*\$LOCALIP.*$'), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1181 ] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1182 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1183 bchr = chr |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1184 if PYTHON3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1185 bchr = lambda x: bytes([x]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1186 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1187 class TTest(Test): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1188 """A "t test" is a test backed by a .t file.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1189 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1190 SKIPPED_PREFIX = b'skipped: ' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1191 FAILED_PREFIX = b'hghave check failed: ' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1192 NEEDESCAPE = re.compile(br'[\x00-\x08\x0b-\x1f\x7f-\xff]').search |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1193 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1194 ESCAPESUB = re.compile(br'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1195 ESCAPEMAP = dict((bchr(i), br'\x%02x' % i) for i in range(256)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1196 ESCAPEMAP.update({b'\\': b'\\\\', b'\r': br'\r'}) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1197 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1198 def __init__(self, path, *args, **kwds): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1199 # accept an extra "case" parameter |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1200 case = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1201 if 'case' in kwds: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1202 case = kwds.pop('case') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1203 self._case = case |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1204 self._allcases = parsettestcases(path) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1205 super(TTest, self).__init__(path, *args, **kwds) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1206 if case: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1207 self.name = '%s (case %s)' % (self.name, _strpath(case)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1208 self.errpath = b'%s.%s.err' % (self.errpath[:-4], case) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1209 self._tmpname += b'-%s' % case |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1210 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1211 @property |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1212 def refpath(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1213 return os.path.join(self._testdir, self.bname) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1214 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1215 def _run(self, env): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1216 f = open(self.path, 'rb') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1217 lines = f.readlines() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1218 f.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1219 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1220 # .t file is both reference output and the test input, keep reference |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1221 # output updated with the the test input. This avoids some race |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1222 # conditions where the reference output does not match the actual test. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1223 if self._refout is not None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1224 self._refout = lines |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1225 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1226 salt, script, after, expected = self._parsetest(lines) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1227 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1228 # Write out the generated script. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1229 fname = b'%s.sh' % self._testtmp |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1230 f = open(fname, 'wb') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1231 for l in script: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1232 f.write(l) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1233 f.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1234 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1235 cmd = b'%s "%s"' % (self._shell, fname) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1236 vlog("# Running", cmd) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1237 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1238 exitcode, output = self._runcommand(cmd, env) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1239 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1240 if self._aborted: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1241 raise KeyboardInterrupt() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1242 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1243 # Do not merge output if skipped. Return hghave message instead. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1244 # Similarly, with --debug, output is None. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1245 if exitcode == self.SKIPPED_STATUS or output is None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1246 return exitcode, output |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1247 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1248 return self._processoutput(exitcode, output, salt, after, expected) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1249 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1250 def _hghave(self, reqs): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1251 # TODO do something smarter when all other uses of hghave are gone. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1252 runtestdir = os.path.abspath(os.path.dirname(_bytespath(__file__))) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1253 tdir = runtestdir.replace(b'\\', b'/') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1254 proc = Popen4(b'%s -c "%s/hghave %s"' % |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1255 (self._shell, tdir, b' '.join(reqs)), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1256 self._testtmp, 0, self._getenv()) |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
1257 stdout, stderr = proc.communicate() |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
1258 ret = proc.wait() |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
1259 if wifexited(ret): |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
1260 ret = os.WEXITSTATUS(ret) |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
1261 if ret == 2: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1262 print(stdout.decode('utf-8')) |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
1263 sys.exit(1) |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1264 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1265 if ret != 0: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1266 return False, stdout |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1267 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1268 if b'slow' in reqs: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1269 self._timeout = self._slowtimeout |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1270 return True, None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1271 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1272 def _iftest(self, args): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1273 # implements "#if" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1274 reqs = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1275 for arg in args: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1276 if arg.startswith(b'no-') and arg[3:] in self._allcases: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1277 if arg[3:] == self._case: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1278 return False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1279 elif arg in self._allcases: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1280 if arg != self._case: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1281 return False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1282 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1283 reqs.append(arg) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1284 return self._hghave(reqs)[0] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1285 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1286 def _parsetest(self, lines): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1287 # We generate a shell script which outputs unique markers to line |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1288 # up script results with our source. These markers include input |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1289 # line number and the last return code. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1290 salt = b"SALT%d" % time.time() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1291 def addsalt(line, inpython): |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
1292 if inpython: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1293 script.append(b'%s %d 0\n' % (salt, line)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1294 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1295 script.append(b'echo %s %d $?\n' % (salt, line)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1296 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1297 script = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1298 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1299 # After we run the shell script, we re-unify the script output |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1300 # with non-active parts of the source, with synchronization by our |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1301 # SALT line number markers. The after table contains the non-active |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1302 # components, ordered by line number. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1303 after = {} |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1304 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1305 # Expected shell script output. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1306 expected = {} |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1307 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1308 pos = prepos = -1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1309 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1310 # True or False when in a true or false conditional section |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1311 skipping = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1312 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1313 # We keep track of whether or not we're in a Python block so we |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1314 # can generate the surrounding doctest magic. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1315 inpython = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1316 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1317 if self._debug: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1318 script.append(b'set -x\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1319 if self._hgcommand != b'hg': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1320 script.append(b'alias hg="%s"\n' % self._hgcommand) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1321 if os.getenv('MSYSTEM'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1322 script.append(b'alias pwd="pwd -W"\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1323 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1324 n = 0 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1325 for n, l in enumerate(lines): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1326 if not l.endswith(b'\n'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1327 l += b'\n' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1328 if l.startswith(b'#require'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1329 lsplit = l.split() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1330 if len(lsplit) < 2 or lsplit[0] != b'#require': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1331 after.setdefault(pos, []).append(' !!! invalid #require\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1332 haveresult, message = self._hghave(lsplit[1:]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1333 if not haveresult: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1334 script = [b'echo "%s"\nexit 80\n' % message] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1335 break |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1336 after.setdefault(pos, []).append(l) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1337 elif l.startswith(b'#if'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1338 lsplit = l.split() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1339 if len(lsplit) < 2 or lsplit[0] != b'#if': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1340 after.setdefault(pos, []).append(' !!! invalid #if\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1341 if skipping is not None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1342 after.setdefault(pos, []).append(' !!! nested #if\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1343 skipping = not self._iftest(lsplit[1:]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1344 after.setdefault(pos, []).append(l) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1345 elif l.startswith(b'#else'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1346 if skipping is None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1347 after.setdefault(pos, []).append(' !!! missing #if\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1348 skipping = not skipping |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1349 after.setdefault(pos, []).append(l) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1350 elif l.startswith(b'#endif'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1351 if skipping is None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1352 after.setdefault(pos, []).append(' !!! missing #if\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1353 skipping = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1354 after.setdefault(pos, []).append(l) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1355 elif skipping: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1356 after.setdefault(pos, []).append(l) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1357 elif l.startswith(b' >>> '): # python inlines |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1358 after.setdefault(pos, []).append(l) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1359 prepos = pos |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1360 pos = n |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1361 if not inpython: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1362 # We've just entered a Python block. Add the header. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1363 inpython = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1364 addsalt(prepos, False) # Make sure we report the exit code. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1365 script.append(b'%s -m heredoctest <<EOF\n' % PYTHON) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1366 addsalt(n, True) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1367 script.append(l[2:]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1368 elif l.startswith(b' ... '): # python inlines |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1369 after.setdefault(prepos, []).append(l) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1370 script.append(l[2:]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1371 elif l.startswith(b' $ '): # commands |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1372 if inpython: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1373 script.append(b'EOF\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1374 inpython = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1375 after.setdefault(pos, []).append(l) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1376 prepos = pos |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1377 pos = n |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1378 addsalt(n, False) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1379 cmd = l[4:].split() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1380 if len(cmd) == 2 and cmd[0] == b'cd': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1381 l = b' $ cd %s || exit 1\n' % cmd[1] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1382 script.append(l[4:]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1383 elif l.startswith(b' > '): # continuations |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1384 after.setdefault(prepos, []).append(l) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1385 script.append(l[4:]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1386 elif l.startswith(b' '): # results |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1387 # Queue up a list of expected results. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1388 expected.setdefault(pos, []).append(l[2:]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1389 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1390 if inpython: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1391 script.append(b'EOF\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1392 inpython = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1393 # Non-command/result. Queue up for merged output. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1394 after.setdefault(pos, []).append(l) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1395 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1396 if inpython: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1397 script.append(b'EOF\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1398 if skipping is not None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1399 after.setdefault(pos, []).append(' !!! missing #endif\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1400 addsalt(n + 1, False) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1401 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1402 return salt, script, after, expected |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1403 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1404 def _processoutput(self, exitcode, output, salt, after, expected): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1405 # Merge the script output back into a unified test. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1406 warnonly = 1 # 1: not yet; 2: yes; 3: for sure not |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1407 if exitcode != 0: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1408 warnonly = 3 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1409 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1410 pos = -1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1411 postout = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1412 for l in output: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1413 lout, lcmd = l, None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1414 if salt in l: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1415 lout, lcmd = l.split(salt, 1) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1416 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1417 while lout: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1418 if not lout.endswith(b'\n'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1419 lout += b' (no-eol)\n' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1420 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1421 # Find the expected output at the current position. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1422 els = [None] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1423 if expected.get(pos, None): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1424 els = expected[pos] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1425 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1426 i = 0 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1427 optional = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1428 while i < len(els): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1429 el = els[i] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1430 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1431 r = self.linematch(el, lout) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1432 if isinstance(r, str): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1433 if r == '+glob': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1434 lout = el[:-1] + ' (glob)\n' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1435 r = '' # Warn only this line. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1436 elif r == '-glob': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1437 lout = ''.join(el.rsplit(' (glob)', 1)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1438 r = '' # Warn only this line. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1439 elif r == "retry": |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1440 postout.append(b' ' + el) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1441 els.pop(i) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1442 break |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1443 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1444 log('\ninfo, unknown linematch result: %r\n' % r) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1445 r = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1446 if r: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1447 els.pop(i) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1448 break |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1449 if el: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1450 if el.endswith(b" (?)\n"): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1451 optional.append(i) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1452 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1453 m = optline.match(el) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1454 if m: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1455 conditions = [ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1456 c for c in m.group(2).split(b' ')] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1457 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1458 if not self._iftest(conditions): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1459 optional.append(i) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1460 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1461 i += 1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1462 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1463 if r: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1464 if r == "retry": |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1465 continue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1466 # clean up any optional leftovers |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1467 for i in optional: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1468 postout.append(b' ' + els[i]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1469 for i in reversed(optional): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1470 del els[i] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1471 postout.append(b' ' + el) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1472 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1473 if self.NEEDESCAPE(lout): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1474 lout = TTest._stringescape(b'%s (esc)\n' % |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1475 lout.rstrip(b'\n')) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1476 postout.append(b' ' + lout) # Let diff deal with it. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1477 if r != '': # If line failed. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1478 warnonly = 3 # for sure not |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1479 elif warnonly == 1: # Is "not yet" and line is warn only. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1480 warnonly = 2 # Yes do warn. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1481 break |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1482 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1483 # clean up any optional leftovers |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1484 while expected.get(pos, None): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1485 el = expected[pos].pop(0) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1486 if el: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1487 if not el.endswith(b" (?)\n"): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1488 m = optline.match(el) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1489 if m: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1490 conditions = [c for c in m.group(2).split(b' ')] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1491 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1492 if self._iftest(conditions): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1493 # Don't append as optional line |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1494 continue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1495 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1496 continue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1497 postout.append(b' ' + el) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1498 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1499 if lcmd: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1500 # Add on last return code. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1501 ret = int(lcmd.split()[1]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1502 if ret != 0: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1503 postout.append(b' [%d]\n' % ret) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1504 if pos in after: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1505 # Merge in non-active test bits. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1506 postout += after.pop(pos) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1507 pos = int(lcmd.split()[0]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1508 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1509 if pos in after: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1510 postout += after.pop(pos) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1511 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1512 if warnonly == 2: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1513 exitcode = False # Set exitcode to warned. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1514 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1515 return exitcode, postout |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1516 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1517 @staticmethod |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1518 def rematch(el, l): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1519 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1520 # use \Z to ensure that the regex matches to the end of the string |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1521 if os.name == 'nt': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1522 return re.match(el + br'\r?\n\Z', l) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1523 return re.match(el + br'\n\Z', l) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1524 except re.error: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1525 # el is an invalid regex |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1526 return False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1527 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1528 @staticmethod |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1529 def globmatch(el, l): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1530 # The only supported special characters are * and ? plus / which also |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1531 # matches \ on windows. Escaping of these characters is supported. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1532 if el + b'\n' == l: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1533 if os.altsep: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1534 # matching on "/" is not needed for this line |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1535 for pat in checkcodeglobpats: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1536 if pat.match(el): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1537 return True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1538 return b'-glob' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1539 return True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1540 el = el.replace(b'$LOCALIP', b'*') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1541 i, n = 0, len(el) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1542 res = b'' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1543 while i < n: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1544 c = el[i:i + 1] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1545 i += 1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1546 if c == b'\\' and i < n and el[i:i + 1] in b'*?\\/': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1547 res += el[i - 1:i + 1] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1548 i += 1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1549 elif c == b'*': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1550 res += b'.*' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1551 elif c == b'?': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1552 res += b'.' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1553 elif c == b'/' and os.altsep: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1554 res += b'[/\\\\]' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1555 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1556 res += re.escape(c) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1557 return TTest.rematch(res, l) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1558 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1559 def linematch(self, el, l): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1560 retry = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1561 if el == l: # perfect match (fast) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1562 return True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1563 if el: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1564 if el.endswith(b" (?)\n"): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1565 retry = "retry" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1566 el = el[:-5] + b"\n" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1567 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1568 m = optline.match(el) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1569 if m: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1570 conditions = [c for c in m.group(2).split(b' ')] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1571 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1572 el = m.group(1) + b"\n" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1573 if not self._iftest(conditions): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1574 retry = "retry" # Not required by listed features |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1575 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1576 if el.endswith(b" (esc)\n"): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1577 if PYTHON3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1578 el = el[:-7].decode('unicode_escape') + '\n' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1579 el = el.encode('utf-8') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1580 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1581 el = el[:-7].decode('string-escape') + '\n' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1582 if el == l or os.name == 'nt' and el[:-1] + b'\r\n' == l: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1583 return True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1584 if el.endswith(b" (re)\n"): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1585 return TTest.rematch(el[:-6], l) or retry |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1586 if el.endswith(b" (glob)\n"): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1587 # ignore '(glob)' added to l by 'replacements' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1588 if l.endswith(b" (glob)\n"): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1589 l = l[:-8] + b"\n" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1590 return TTest.globmatch(el[:-8], l) or retry |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1591 if os.altsep and l.replace(b'\\', b'/') == el: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1592 return b'+glob' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1593 return retry |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1594 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1595 @staticmethod |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1596 def parsehghaveoutput(lines): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1597 '''Parse hghave log lines. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1598 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1599 Return tuple of lists (missing, failed): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1600 * the missing/unknown features |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1601 * the features for which existence check failed''' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1602 missing = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1603 failed = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1604 for line in lines: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1605 if line.startswith(TTest.SKIPPED_PREFIX): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1606 line = line.splitlines()[0] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1607 missing.append(line[len(TTest.SKIPPED_PREFIX):].decode('utf-8')) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1608 elif line.startswith(TTest.FAILED_PREFIX): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1609 line = line.splitlines()[0] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1610 failed.append(line[len(TTest.FAILED_PREFIX):].decode('utf-8')) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1611 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1612 return missing, failed |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1613 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1614 @staticmethod |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1615 def _escapef(m): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1616 return TTest.ESCAPEMAP[m.group(0)] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1617 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1618 @staticmethod |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1619 def _stringescape(s): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1620 return TTest.ESCAPESUB(TTest._escapef, s) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1621 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1622 iolock = threading.RLock() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1623 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1624 class TestResult(unittest._TextTestResult): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1625 """Holds results when executing via unittest.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1626 # Don't worry too much about accessing the non-public _TextTestResult. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1627 # It is relatively common in Python testing tools. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1628 def __init__(self, options, *args, **kwargs): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1629 super(TestResult, self).__init__(*args, **kwargs) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1630 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1631 self._options = options |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1632 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1633 # unittest.TestResult didn't have skipped until 2.7. We need to |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1634 # polyfill it. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1635 self.skipped = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1636 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1637 # We have a custom "ignored" result that isn't present in any Python |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1638 # unittest implementation. It is very similar to skipped. It may make |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1639 # sense to map it into skip some day. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1640 self.ignored = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1641 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1642 self.times = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1643 self._firststarttime = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1644 # Data stored for the benefit of generating xunit reports. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1645 self.successes = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1646 self.faildata = {} |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1647 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1648 if options.color == 'auto': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1649 self.color = pygmentspresent and self.stream.isatty() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1650 elif options.color == 'never': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1651 self.color = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1652 else: # 'always', for testing purposes |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1653 self.color = pygmentspresent |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1654 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1655 def addFailure(self, test, reason): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1656 self.failures.append((test, reason)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1657 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1658 if self._options.first: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1659 self.stop() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1660 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1661 with iolock: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1662 if reason == "timed out": |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1663 self.stream.write('t') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1664 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1665 if not self._options.nodiff: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1666 self.stream.write('\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1667 # Exclude the '\n' from highlighting to lex correctly |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1668 formatted = 'ERROR: %s output changed\n' % test |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1669 self.stream.write(highlightmsg(formatted, self.color)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1670 self.stream.write('!') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1671 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1672 self.stream.flush() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1673 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1674 def addSuccess(self, test): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1675 with iolock: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1676 super(TestResult, self).addSuccess(test) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1677 self.successes.append(test) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1678 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1679 def addError(self, test, err): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1680 super(TestResult, self).addError(test, err) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1681 if self._options.first: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1682 self.stop() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1683 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1684 # Polyfill. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1685 def addSkip(self, test, reason): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1686 self.skipped.append((test, reason)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1687 with iolock: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1688 if self.showAll: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1689 self.stream.writeln('skipped %s' % reason) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1690 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1691 self.stream.write('s') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1692 self.stream.flush() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1693 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1694 def addIgnore(self, test, reason): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1695 self.ignored.append((test, reason)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1696 with iolock: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1697 if self.showAll: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1698 self.stream.writeln('ignored %s' % reason) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1699 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1700 if reason not in ('not retesting', "doesn't match keyword"): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1701 self.stream.write('i') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1702 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1703 self.testsRun += 1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1704 self.stream.flush() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1705 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1706 def addOutputMismatch(self, test, ret, got, expected): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1707 """Record a mismatch in test output for a particular test.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1708 if self.shouldStop: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1709 # don't print, some other test case already failed and |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1710 # printed, we're just stale and probably failed due to our |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1711 # temp dir getting cleaned up. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1712 return |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1713 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1714 accepted = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1715 lines = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1716 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1717 with iolock: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1718 if self._options.nodiff: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1719 pass |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1720 elif self._options.view: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1721 v = self._options.view |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1722 if PYTHON3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1723 v = _bytespath(v) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1724 os.system(b"%s %s %s" % |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1725 (v, test.refpath, test.errpath)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1726 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1727 servefail, lines = getdiff(expected, got, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1728 test.refpath, test.errpath) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1729 if servefail: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1730 raise test.failureException( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1731 'server failed to start (HGPORT=%s)' % test._startport) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1732 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1733 self.stream.write('\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1734 for line in lines: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1735 line = highlightdiff(line, self.color) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1736 if PYTHON3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1737 self.stream.flush() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1738 self.stream.buffer.write(line) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1739 self.stream.buffer.flush() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1740 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1741 self.stream.write(line) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1742 self.stream.flush() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1743 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1744 # handle interactive prompt without releasing iolock |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1745 if self._options.interactive: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1746 if test.readrefout() != expected: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1747 self.stream.write( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1748 'Reference output has changed (run again to prompt ' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1749 'changes)') |
674
0b33ab75e3cb
tests: upgrade run-tests.py
Siddharth Agarwal <sid0@fb.com>
parents:
492
diff
changeset
|
1750 else: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1751 self.stream.write('Accept this change? [n] ') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1752 answer = sys.stdin.readline().strip() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1753 if answer.lower() in ('y', 'yes'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1754 if test.path.endswith(b'.t'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1755 rename(test.errpath, test.path) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1756 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1757 rename(test.errpath, '%s.out' % test.path) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1758 accepted = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1759 if not accepted: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1760 self.faildata[test.name] = b''.join(lines) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1761 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1762 return accepted |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1763 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1764 def startTest(self, test): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1765 super(TestResult, self).startTest(test) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1766 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1767 # os.times module computes the user time and system time spent by |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1768 # child's processes along with real elapsed time taken by a process. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1769 # This module has one limitation. It can only work for Linux user |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1770 # and not for Windows. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1771 test.started = os.times() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1772 if self._firststarttime is None: # thread racy but irrelevant |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1773 self._firststarttime = test.started[4] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1774 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1775 def stopTest(self, test, interrupted=False): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1776 super(TestResult, self).stopTest(test) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1777 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1778 test.stopped = os.times() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1779 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1780 starttime = test.started |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1781 endtime = test.stopped |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1782 origin = self._firststarttime |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1783 self.times.append((test.name, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1784 endtime[2] - starttime[2], # user space CPU time |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1785 endtime[3] - starttime[3], # sys space CPU time |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1786 endtime[4] - starttime[4], # real time |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1787 starttime[4] - origin, # start date in run context |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1788 endtime[4] - origin, # end date in run context |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1789 )) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1790 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1791 if interrupted: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1792 with iolock: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1793 self.stream.writeln('INTERRUPTED: %s (after %d seconds)' % ( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1794 test.name, self.times[-1][3])) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1795 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1796 class TestSuite(unittest.TestSuite): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1797 """Custom unittest TestSuite that knows how to execute Mercurial tests.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1798 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1799 def __init__(self, testdir, jobs=1, whitelist=None, blacklist=None, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1800 retest=False, keywords=None, loop=False, runs_per_test=1, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1801 loadtest=None, showchannels=False, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1802 *args, **kwargs): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1803 """Create a new instance that can run tests with a configuration. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1804 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1805 testdir specifies the directory where tests are executed from. This |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1806 is typically the ``tests`` directory from Mercurial's source |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1807 repository. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1808 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1809 jobs specifies the number of jobs to run concurrently. Each test |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1810 executes on its own thread. Tests actually spawn new processes, so |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1811 state mutation should not be an issue. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1812 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1813 If there is only one job, it will use the main thread. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1814 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1815 whitelist and blacklist denote tests that have been whitelisted and |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1816 blacklisted, respectively. These arguments don't belong in TestSuite. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1817 Instead, whitelist and blacklist should be handled by the thing that |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1818 populates the TestSuite with tests. They are present to preserve |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1819 backwards compatible behavior which reports skipped tests as part |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1820 of the results. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1821 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1822 retest denotes whether to retest failed tests. This arguably belongs |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1823 outside of TestSuite. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1824 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1825 keywords denotes key words that will be used to filter which tests |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1826 to execute. This arguably belongs outside of TestSuite. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1827 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1828 loop denotes whether to loop over tests forever. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1829 """ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1830 super(TestSuite, self).__init__(*args, **kwargs) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1831 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1832 self._jobs = jobs |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1833 self._whitelist = whitelist |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1834 self._blacklist = blacklist |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1835 self._retest = retest |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1836 self._keywords = keywords |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1837 self._loop = loop |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1838 self._runs_per_test = runs_per_test |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1839 self._loadtest = loadtest |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1840 self._showchannels = showchannels |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1841 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1842 def run(self, result): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1843 # We have a number of filters that need to be applied. We do this |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1844 # here instead of inside Test because it makes the running logic for |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1845 # Test simpler. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1846 tests = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1847 num_tests = [0] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1848 for test in self._tests: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1849 def get(): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1850 num_tests[0] += 1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1851 if getattr(test, 'should_reload', False): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1852 return self._loadtest(test, num_tests[0]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1853 return test |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1854 if not os.path.exists(test.path): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1855 result.addSkip(test, "Doesn't exist") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1856 continue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1857 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1858 if not (self._whitelist and test.bname in self._whitelist): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1859 if self._blacklist and test.bname in self._blacklist: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1860 result.addSkip(test, 'blacklisted') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1861 continue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1862 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1863 if self._retest and not os.path.exists(test.errpath): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1864 result.addIgnore(test, 'not retesting') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1865 continue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1866 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1867 if self._keywords: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1868 f = open(test.path, 'rb') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1869 t = f.read().lower() + test.bname.lower() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1870 f.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1871 ignored = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1872 for k in self._keywords.lower().split(): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1873 if k not in t: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1874 result.addIgnore(test, "doesn't match keyword") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1875 ignored = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1876 break |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1877 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1878 if ignored: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1879 continue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1880 for _ in xrange(self._runs_per_test): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1881 tests.append(get()) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1882 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1883 runtests = list(tests) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1884 done = queue.Queue() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1885 running = 0 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1886 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1887 channels = [""] * self._jobs |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1888 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1889 def job(test, result): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1890 for n, v in enumerate(channels): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1891 if not v: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1892 channel = n |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1893 break |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
1894 else: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1895 raise ValueError('Could not find output channel') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1896 channels[channel] = "=" + test.name[5:].split(".")[0] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1897 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1898 test(result) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1899 done.put(None) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1900 except KeyboardInterrupt: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1901 pass |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1902 except: # re-raises |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1903 done.put(('!', test, 'run-test raised an error, see traceback')) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1904 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1905 finally: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1906 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1907 channels[channel] = '' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1908 except IndexError: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1909 pass |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1910 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1911 def stat(): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1912 count = 0 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1913 while channels: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1914 d = '\n%03s ' % count |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1915 for n, v in enumerate(channels): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1916 if v: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1917 d += v[0] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1918 channels[n] = v[1:] or '.' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1919 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1920 d += ' ' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1921 d += ' ' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1922 with iolock: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1923 sys.stdout.write(d + ' ') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1924 sys.stdout.flush() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1925 for x in xrange(10): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1926 if channels: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1927 time.sleep(.1) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1928 count += 1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1929 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1930 stoppedearly = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1931 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1932 if self._showchannels: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1933 statthread = threading.Thread(target=stat, name="stat") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1934 statthread.start() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1935 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1936 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1937 while tests or running: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1938 if not done.empty() or running == self._jobs or not tests: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1939 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1940 done.get(True, 1) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1941 running -= 1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1942 if result and result.shouldStop: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1943 stoppedearly = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1944 break |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1945 except queue.Empty: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1946 continue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1947 if tests and not running == self._jobs: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1948 test = tests.pop(0) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1949 if self._loop: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1950 if getattr(test, 'should_reload', False): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1951 num_tests[0] += 1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1952 tests.append( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1953 self._loadtest(test, num_tests[0])) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1954 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1955 tests.append(test) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1956 if self._jobs == 1: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1957 job(test, result) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1958 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1959 t = threading.Thread(target=job, name=test.name, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1960 args=(test, result)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1961 t.start() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1962 running += 1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1963 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1964 # If we stop early we still need to wait on started tests to |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1965 # finish. Otherwise, there is a race between the test completing |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1966 # and the test's cleanup code running. This could result in the |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1967 # test reporting incorrect. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1968 if stoppedearly: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1969 while running: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1970 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1971 done.get(True, 1) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1972 running -= 1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1973 except queue.Empty: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1974 continue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1975 except KeyboardInterrupt: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1976 for test in runtests: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1977 test.abort() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1978 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1979 channels = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1980 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1981 return result |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1982 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1983 # Save the most recent 5 wall-clock runtimes of each test to a |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1984 # human-readable text file named .testtimes. Tests are sorted |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1985 # alphabetically, while times for each test are listed from oldest to |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1986 # newest. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1987 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1988 def loadtimes(outputdir): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1989 times = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1990 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1991 with open(os.path.join(outputdir, b'.testtimes-')) as fp: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1992 for line in fp: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1993 ts = line.split() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1994 times.append((ts[0], [float(t) for t in ts[1:]])) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1995 except IOError as err: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1996 if err.errno != errno.ENOENT: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1997 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1998 return times |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
1999 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2000 def savetimes(outputdir, result): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2001 saved = dict(loadtimes(outputdir)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2002 maxruns = 5 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2003 skipped = set([str(t[0]) for t in result.skipped]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2004 for tdata in result.times: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2005 test, real = tdata[0], tdata[3] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2006 if test not in skipped: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2007 ts = saved.setdefault(test, []) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2008 ts.append(real) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2009 ts[:] = ts[-maxruns:] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2010 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2011 fd, tmpname = tempfile.mkstemp(prefix=b'.testtimes', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2012 dir=outputdir, text=True) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2013 with os.fdopen(fd, 'w') as fp: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2014 for name, ts in sorted(saved.items()): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2015 fp.write('%s %s\n' % (name, ' '.join(['%.3f' % (t,) for t in ts]))) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2016 timepath = os.path.join(outputdir, b'.testtimes') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2017 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2018 os.unlink(timepath) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2019 except OSError: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2020 pass |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2021 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2022 os.rename(tmpname, timepath) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2023 except OSError: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2024 pass |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2025 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2026 class TextTestRunner(unittest.TextTestRunner): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2027 """Custom unittest test runner that uses appropriate settings.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2028 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2029 def __init__(self, runner, *args, **kwargs): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2030 super(TextTestRunner, self).__init__(*args, **kwargs) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2031 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2032 self._runner = runner |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2033 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2034 def listtests(self, test): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2035 result = TestResult(self._runner.options, self.stream, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2036 self.descriptions, 0) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2037 test = sorted(test, key=lambda t: t.name) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2038 for t in test: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2039 print(t.name) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2040 result.addSuccess(t) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2041 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2042 if self._runner.options.xunit: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2043 with open(self._runner.options.xunit, "wb") as xuf: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2044 self._writexunit(result, xuf) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2045 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2046 if self._runner.options.json: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2047 jsonpath = os.path.join(self._runner._outputdir, b'report.json') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2048 with open(jsonpath, 'w') as fp: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2049 self._writejson(result, fp) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2050 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2051 return result |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2052 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2053 def run(self, test): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2054 result = TestResult(self._runner.options, self.stream, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2055 self.descriptions, self.verbosity) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2056 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2057 test(result) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2058 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2059 failed = len(result.failures) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2060 skipped = len(result.skipped) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2061 ignored = len(result.ignored) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2062 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2063 with iolock: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2064 self.stream.writeln('') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2065 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2066 if not self._runner.options.noskips: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2067 for test, msg in result.skipped: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2068 formatted = 'Skipped %s: %s\n' % (test.name, msg) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2069 self.stream.write(highlightmsg(formatted, result.color)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2070 for test, msg in result.failures: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2071 formatted = 'Failed %s: %s\n' % (test.name, msg) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2072 self.stream.write(highlightmsg(formatted, result.color)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2073 for test, msg in result.errors: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2074 self.stream.writeln('Errored %s: %s' % (test.name, msg)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2075 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2076 if self._runner.options.xunit: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2077 with open(self._runner.options.xunit, "wb") as xuf: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2078 self._writexunit(result, xuf) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2079 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2080 if self._runner.options.json: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2081 jsonpath = os.path.join(self._runner._outputdir, b'report.json') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2082 with open(jsonpath, 'w') as fp: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2083 self._writejson(result, fp) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2084 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2085 self._runner._checkhglib('Tested') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2086 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2087 savetimes(self._runner._outputdir, result) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2088 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2089 if failed and self._runner.options.known_good_rev: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2090 self._bisecttests(t for t, m in result.failures) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2091 self.stream.writeln( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2092 '# Ran %d tests, %d skipped, %d failed.' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2093 % (result.testsRun, skipped + ignored, failed)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2094 if failed: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2095 self.stream.writeln('python hash seed: %s' % |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2096 os.environ['PYTHONHASHSEED']) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2097 if self._runner.options.time: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2098 self.printtimes(result.times) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2099 self.stream.flush() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2100 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2101 return result |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2102 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2103 def _bisecttests(self, tests): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2104 bisectcmd = ['hg', 'bisect'] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2105 bisectrepo = self._runner.options.bisect_repo |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2106 if bisectrepo: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2107 bisectcmd.extend(['-R', os.path.abspath(bisectrepo)]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2108 def pread(args): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2109 env = os.environ.copy() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2110 env['HGPLAIN'] = '1' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2111 p = subprocess.Popen(args, stderr=subprocess.STDOUT, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2112 stdout=subprocess.PIPE, env=env) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2113 data = p.stdout.read() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2114 p.wait() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2115 return data |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2116 for test in tests: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2117 pread(bisectcmd + ['--reset']), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2118 pread(bisectcmd + ['--bad', '.']) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2119 pread(bisectcmd + ['--good', self._runner.options.known_good_rev]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2120 # TODO: we probably need to forward more options |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2121 # that alter hg's behavior inside the tests. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2122 opts = '' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2123 withhg = self._runner.options.with_hg |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2124 if withhg: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2125 opts += ' --with-hg=%s ' % shellquote(_strpath(withhg)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2126 rtc = '%s %s %s %s' % (sys.executable, sys.argv[0], opts, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2127 test) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2128 data = pread(bisectcmd + ['--command', rtc]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2129 m = re.search( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2130 (br'\nThe first (?P<goodbad>bad|good) revision ' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2131 br'is:\nchangeset: +\d+:(?P<node>[a-f0-9]+)\n.*\n' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2132 br'summary: +(?P<summary>[^\n]+)\n'), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2133 data, (re.MULTILINE | re.DOTALL)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2134 if m is None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2135 self.stream.writeln( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2136 'Failed to identify failure point for %s' % test) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2137 continue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2138 dat = m.groupdict() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2139 verb = 'broken' if dat['goodbad'] == 'bad' else 'fixed' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2140 self.stream.writeln( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2141 '%s %s by %s (%s)' % ( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2142 test, verb, dat['node'], dat['summary'])) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2143 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2144 def printtimes(self, times): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2145 # iolock held by run |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2146 self.stream.writeln('# Producing time report') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2147 times.sort(key=lambda t: (t[3])) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2148 cols = '%7.3f %7.3f %7.3f %7.3f %7.3f %s' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2149 self.stream.writeln('%-7s %-7s %-7s %-7s %-7s %s' % |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2150 ('start', 'end', 'cuser', 'csys', 'real', 'Test')) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2151 for tdata in times: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2152 test = tdata[0] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2153 cuser, csys, real, start, end = tdata[1:6] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2154 self.stream.writeln(cols % (start, end, cuser, csys, real, test)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2155 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2156 @staticmethod |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2157 def _writexunit(result, outf): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2158 # See http://llg.cubic.org/docs/junit/ for a reference. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2159 timesd = dict((t[0], t[3]) for t in result.times) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2160 doc = minidom.Document() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2161 s = doc.createElement('testsuite') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2162 s.setAttribute('name', 'run-tests') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2163 s.setAttribute('tests', str(result.testsRun)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2164 s.setAttribute('errors', "0") # TODO |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2165 s.setAttribute('failures', str(len(result.failures))) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2166 s.setAttribute('skipped', str(len(result.skipped) + |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2167 len(result.ignored))) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2168 doc.appendChild(s) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2169 for tc in result.successes: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2170 t = doc.createElement('testcase') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2171 t.setAttribute('name', tc.name) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2172 tctime = timesd.get(tc.name) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2173 if tctime is not None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2174 t.setAttribute('time', '%.3f' % tctime) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2175 s.appendChild(t) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2176 for tc, err in sorted(result.faildata.items()): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2177 t = doc.createElement('testcase') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2178 t.setAttribute('name', tc) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2179 tctime = timesd.get(tc) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2180 if tctime is not None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2181 t.setAttribute('time', '%.3f' % tctime) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2182 # createCDATASection expects a unicode or it will |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2183 # convert using default conversion rules, which will |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2184 # fail if string isn't ASCII. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2185 err = cdatasafe(err).decode('utf-8', 'replace') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2186 cd = doc.createCDATASection(err) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2187 # Use 'failure' here instead of 'error' to match errors = 0, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2188 # failures = len(result.failures) in the testsuite element. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2189 failelem = doc.createElement('failure') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2190 failelem.setAttribute('message', 'output changed') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2191 failelem.setAttribute('type', 'output-mismatch') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2192 failelem.appendChild(cd) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2193 t.appendChild(failelem) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2194 s.appendChild(t) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2195 for tc, message in result.skipped: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2196 # According to the schema, 'skipped' has no attributes. So store |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2197 # the skip message as a text node instead. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2198 t = doc.createElement('testcase') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2199 t.setAttribute('name', tc.name) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2200 binmessage = message.encode('utf-8') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2201 message = cdatasafe(binmessage).decode('utf-8', 'replace') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2202 cd = doc.createCDATASection(message) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2203 skipelem = doc.createElement('skipped') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2204 skipelem.appendChild(cd) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2205 t.appendChild(skipelem) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2206 s.appendChild(t) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2207 outf.write(doc.toprettyxml(indent=' ', encoding='utf-8')) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2208 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2209 @staticmethod |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2210 def _writejson(result, outf): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2211 timesd = {} |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2212 for tdata in result.times: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2213 test = tdata[0] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2214 timesd[test] = tdata[1:] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2215 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2216 outcome = {} |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2217 groups = [('success', ((tc, None) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2218 for tc in result.successes)), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2219 ('failure', result.failures), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2220 ('skip', result.skipped)] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2221 for res, testcases in groups: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2222 for tc, __ in testcases: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2223 if tc.name in timesd: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2224 diff = result.faildata.get(tc.name, b'') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2225 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2226 diff = diff.decode('unicode_escape') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2227 except UnicodeDecodeError as e: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2228 diff = '%r decoding diff, sorry' % e |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2229 tres = {'result': res, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2230 'time': ('%0.3f' % timesd[tc.name][2]), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2231 'cuser': ('%0.3f' % timesd[tc.name][0]), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2232 'csys': ('%0.3f' % timesd[tc.name][1]), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2233 'start': ('%0.3f' % timesd[tc.name][3]), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2234 'end': ('%0.3f' % timesd[tc.name][4]), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2235 'diff': diff, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2236 } |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2237 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2238 # blacklisted test |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2239 tres = {'result': res} |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2240 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2241 outcome[tc.name] = tres |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2242 jsonout = json.dumps(outcome, sort_keys=True, indent=4, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2243 separators=(',', ': ')) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2244 outf.writelines(("testreport =", jsonout)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2245 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2246 class TestRunner(object): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2247 """Holds context for executing tests. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2248 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2249 Tests rely on a lot of state. This object holds it for them. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2250 """ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2251 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2252 # Programs required to run tests. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2253 REQUIREDTOOLS = [ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2254 b'diff', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2255 b'grep', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2256 b'unzip', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2257 b'gunzip', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2258 b'bunzip2', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2259 b'sed', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2260 ] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2261 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2262 # Maps file extensions to test class. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2263 TESTTYPES = [ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2264 (b'.py', PythonTest), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2265 (b'.t', TTest), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2266 ] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2267 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2268 def __init__(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2269 self.options = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2270 self._hgroot = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2271 self._testdir = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2272 self._outputdir = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2273 self._hgtmp = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2274 self._installdir = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2275 self._bindir = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2276 self._tmpbinddir = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2277 self._pythondir = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2278 self._coveragefile = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2279 self._createdfiles = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2280 self._hgcommand = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2281 self._hgpath = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2282 self._portoffset = 0 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2283 self._ports = {} |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2284 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2285 def run(self, args, parser=None): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2286 """Run the test suite.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2287 oldmask = os.umask(0o22) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2288 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2289 parser = parser or getparser() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2290 options, args = parseargs(args, parser) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2291 # positional arguments are paths to test files to run, so |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2292 # we make sure they're all bytestrings |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2293 args = [_bytespath(a) for a in args] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2294 if options.test_list is not None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2295 for listfile in options.test_list: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2296 with open(listfile, 'rb') as f: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2297 args.extend(t for t in f.read().splitlines() if t) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2298 self.options = options |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2299 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2300 self._checktools() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2301 testdescs = self.findtests(args) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2302 if options.profile_runner: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2303 import statprof |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2304 statprof.start() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2305 result = self._run(testdescs) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2306 if options.profile_runner: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2307 statprof.stop() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2308 statprof.display() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2309 return result |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2310 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2311 finally: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2312 os.umask(oldmask) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2313 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2314 def _run(self, testdescs): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2315 if self.options.random: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2316 random.shuffle(testdescs) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2317 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2318 # keywords for slow tests |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2319 slow = {b'svn': 10, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2320 b'cvs': 10, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2321 b'hghave': 10, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2322 b'largefiles-update': 10, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2323 b'run-tests': 10, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2324 b'corruption': 10, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2325 b'race': 10, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2326 b'i18n': 10, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2327 b'check': 100, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2328 b'gendoc': 100, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2329 b'contrib-perf': 200, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2330 } |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2331 perf = {} |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2332 def sortkey(f): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2333 # run largest tests first, as they tend to take the longest |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2334 f = f['path'] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2335 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2336 return perf[f] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2337 except KeyError: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2338 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2339 val = -os.stat(f).st_size |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2340 except OSError as e: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2341 if e.errno != errno.ENOENT: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2342 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2343 perf[f] = -1e9 # file does not exist, tell early |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2344 return -1e9 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2345 for kw, mul in slow.items(): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2346 if kw in f: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2347 val *= mul |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2348 if f.endswith(b'.py'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2349 val /= 10.0 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2350 perf[f] = val / 1000.0 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2351 return perf[f] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2352 testdescs.sort(key=sortkey) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2353 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2354 self._testdir = osenvironb[b'TESTDIR'] = getattr( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2355 os, 'getcwdb', os.getcwd)() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2356 if self.options.outputdir: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2357 self._outputdir = canonpath(_bytespath(self.options.outputdir)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2358 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2359 self._outputdir = self._testdir |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2360 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2361 if 'PYTHONHASHSEED' not in os.environ: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2362 # use a random python hash seed all the time |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2363 # we do the randomness ourself to know what seed is used |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2364 os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2365 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2366 if self.options.tmpdir: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2367 self.options.keep_tmpdir = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2368 tmpdir = _bytespath(self.options.tmpdir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2369 if os.path.exists(tmpdir): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2370 # Meaning of tmpdir has changed since 1.3: we used to create |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2371 # HGTMP inside tmpdir; now HGTMP is tmpdir. So fail if |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2372 # tmpdir already exists. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2373 print("error: temp dir %r already exists" % tmpdir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2374 return 1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2375 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2376 # Automatically removing tmpdir sounds convenient, but could |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2377 # really annoy anyone in the habit of using "--tmpdir=/tmp" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2378 # or "--tmpdir=$HOME". |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2379 #vlog("# Removing temp dir", tmpdir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2380 #shutil.rmtree(tmpdir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2381 os.makedirs(tmpdir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2382 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2383 d = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2384 if os.name == 'nt': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2385 # without this, we get the default temp dir location, but |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2386 # in all lowercase, which causes troubles with paths (issue3490) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2387 d = osenvironb.get(b'TMP', None) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2388 tmpdir = tempfile.mkdtemp(b'', b'hgtests.', d) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2389 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2390 self._hgtmp = osenvironb[b'HGTMP'] = ( |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2391 os.path.realpath(tmpdir)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2392 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2393 if self.options.with_hg: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2394 self._installdir = None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2395 whg = self.options.with_hg |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2396 self._bindir = os.path.dirname(os.path.realpath(whg)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2397 assert isinstance(self._bindir, bytes) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2398 self._hgcommand = os.path.basename(whg) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2399 self._tmpbindir = os.path.join(self._hgtmp, b'install', b'bin') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2400 os.makedirs(self._tmpbindir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2401 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2402 # This looks redundant with how Python initializes sys.path from |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2403 # the location of the script being executed. Needed because the |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2404 # "hg" specified by --with-hg is not the only Python script |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2405 # executed in the test suite that needs to import 'mercurial' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2406 # ... which means it's not really redundant at all. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2407 self._pythondir = self._bindir |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2408 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2409 self._installdir = os.path.join(self._hgtmp, b"install") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2410 self._bindir = os.path.join(self._installdir, b"bin") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2411 self._hgcommand = b'hg' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2412 self._tmpbindir = self._bindir |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2413 self._pythondir = os.path.join(self._installdir, b"lib", b"python") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2414 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2415 # set CHGHG, then replace "hg" command by "chg" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2416 chgbindir = self._bindir |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2417 if self.options.chg or self.options.with_chg: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2418 osenvironb[b'CHGHG'] = os.path.join(self._bindir, self._hgcommand) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2419 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2420 osenvironb.pop(b'CHGHG', None) # drop flag for hghave |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2421 if self.options.chg: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2422 self._hgcommand = b'chg' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2423 elif self.options.with_chg: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2424 chgbindir = os.path.dirname(os.path.realpath(self.options.with_chg)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2425 self._hgcommand = os.path.basename(self.options.with_chg) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2426 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2427 osenvironb[b"BINDIR"] = self._bindir |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2428 osenvironb[b"PYTHON"] = PYTHON |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2429 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2430 if self.options.with_python3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2431 osenvironb[b'PYTHON3'] = self.options.with_python3 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2432 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2433 fileb = _bytespath(__file__) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2434 runtestdir = os.path.abspath(os.path.dirname(fileb)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2435 osenvironb[b'RUNTESTDIR'] = runtestdir |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2436 if PYTHON3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2437 sepb = _bytespath(os.pathsep) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2438 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2439 sepb = os.pathsep |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2440 path = [self._bindir, runtestdir] + osenvironb[b"PATH"].split(sepb) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2441 if os.path.islink(__file__): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2442 # test helper will likely be at the end of the symlink |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2443 realfile = os.path.realpath(fileb) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2444 realdir = os.path.abspath(os.path.dirname(realfile)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2445 path.insert(2, realdir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2446 if chgbindir != self._bindir: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2447 path.insert(1, chgbindir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2448 if self._testdir != runtestdir: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2449 path = [self._testdir] + path |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2450 if self._tmpbindir != self._bindir: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2451 path = [self._tmpbindir] + path |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2452 osenvironb[b"PATH"] = sepb.join(path) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2453 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2454 # Include TESTDIR in PYTHONPATH so that out-of-tree extensions |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2455 # can run .../tests/run-tests.py test-foo where test-foo |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2456 # adds an extension to HGRC. Also include run-test.py directory to |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2457 # import modules like heredoctest. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2458 pypath = [self._pythondir, self._testdir, runtestdir] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2459 # We have to augment PYTHONPATH, rather than simply replacing |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2460 # it, in case external libraries are only available via current |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2461 # PYTHONPATH. (In particular, the Subversion bindings on OS X |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2462 # are in /opt/subversion.) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2463 oldpypath = osenvironb.get(IMPL_PATH) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2464 if oldpypath: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2465 pypath.append(oldpypath) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2466 osenvironb[IMPL_PATH] = sepb.join(pypath) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2467 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2468 if self.options.pure: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2469 os.environ["HGTEST_RUN_TESTS_PURE"] = "--pure" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2470 os.environ["HGMODULEPOLICY"] = "py" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2471 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2472 if self.options.allow_slow_tests: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2473 os.environ["HGTEST_SLOW"] = "slow" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2474 elif 'HGTEST_SLOW' in os.environ: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2475 del os.environ['HGTEST_SLOW'] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2476 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2477 self._coveragefile = os.path.join(self._testdir, b'.coverage') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2478 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2479 vlog("# Using TESTDIR", self._testdir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2480 vlog("# Using RUNTESTDIR", osenvironb[b'RUNTESTDIR']) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2481 vlog("# Using HGTMP", self._hgtmp) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2482 vlog("# Using PATH", os.environ["PATH"]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2483 vlog("# Using", IMPL_PATH, osenvironb[IMPL_PATH]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2484 vlog("# Writing to directory", self._outputdir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2485 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2486 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2487 return self._runtests(testdescs) or 0 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2488 finally: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2489 time.sleep(.1) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2490 self._cleanup() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2491 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2492 def findtests(self, args): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2493 """Finds possible test files from arguments. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2494 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2495 If you wish to inject custom tests into the test harness, this would |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2496 be a good function to monkeypatch or override in a derived class. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2497 """ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2498 if not args: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2499 if self.options.changed: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2500 proc = Popen4('hg st --rev "%s" -man0 .' % |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2501 self.options.changed, None, 0) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2502 stdout, stderr = proc.communicate() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2503 args = stdout.strip(b'\0').split(b'\0') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2504 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2505 args = os.listdir(b'.') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2506 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2507 tests = [] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2508 for t in args: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2509 if not (os.path.basename(t).startswith(b'test-') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2510 and (t.endswith(b'.py') or t.endswith(b'.t'))): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2511 continue |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2512 if t.endswith(b'.t'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2513 # .t file may contain multiple test cases |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2514 cases = sorted(parsettestcases(t)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2515 if cases: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2516 tests += [{'path': t, 'case': c} for c in sorted(cases)] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2517 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2518 tests.append({'path': t}) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2519 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2520 tests.append({'path': t}) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2521 return tests |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2522 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2523 def _runtests(self, testdescs): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2524 def _reloadtest(test, i): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2525 # convert a test back to its description dict |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2526 desc = {'path': test.path} |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2527 case = getattr(test, '_case', None) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2528 if case: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2529 desc['case'] = case |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2530 return self._gettest(desc, i) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2531 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2532 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2533 if self.options.restart: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2534 orig = list(testdescs) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2535 while testdescs: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2536 desc = testdescs[0] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2537 # desc['path'] is a relative path |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2538 if 'case' in desc: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2539 errpath = b'%s.%s.err' % (desc['path'], desc['case']) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2540 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2541 errpath = b'%s.err' % desc['path'] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2542 errpath = os.path.join(self._outputdir, errpath) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2543 if os.path.exists(errpath): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2544 break |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2545 testdescs.pop(0) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2546 if not testdescs: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2547 print("running all tests") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2548 testdescs = orig |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2549 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2550 tests = [self._gettest(d, i) for i, d in enumerate(testdescs)] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2551 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2552 failed = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2553 kws = self.options.keywords |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2554 if kws is not None and PYTHON3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2555 kws = kws.encode('utf-8') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2556 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2557 suite = TestSuite(self._testdir, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2558 jobs=self.options.jobs, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2559 whitelist=self.options.whitelisted, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2560 blacklist=self.options.blacklist, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2561 retest=self.options.retest, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2562 keywords=kws, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2563 loop=self.options.loop, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2564 runs_per_test=self.options.runs_per_test, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2565 showchannels=self.options.showchannels, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2566 tests=tests, loadtest=_reloadtest) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2567 verbosity = 1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2568 if self.options.verbose: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2569 verbosity = 2 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2570 runner = TextTestRunner(self, verbosity=verbosity) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2571 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2572 if self.options.list_tests: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2573 result = runner.listtests(suite) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2574 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2575 if self._installdir: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2576 self._installhg() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2577 self._checkhglib("Testing") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2578 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2579 self._usecorrectpython() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2580 if self.options.chg: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2581 assert self._installdir |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2582 self._installchg() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2583 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2584 result = runner.run(suite) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2585 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2586 if result.failures: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2587 failed = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2588 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2589 if self.options.anycoverage: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2590 self._outputcoverage() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2591 except KeyboardInterrupt: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2592 failed = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2593 print("\ninterrupted!") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2594 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2595 if failed: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2596 return 1 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2597 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2598 def _getport(self, count): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2599 port = self._ports.get(count) # do we have a cached entry? |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2600 if port is None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2601 portneeded = 3 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2602 # above 100 tries we just give up and let test reports failure |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2603 for tries in xrange(100): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2604 allfree = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2605 port = self.options.port + self._portoffset |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2606 for idx in xrange(portneeded): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2607 if not checkportisavailable(port + idx): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2608 allfree = False |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2609 break |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2610 self._portoffset += portneeded |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2611 if allfree: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2612 break |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2613 self._ports[count] = port |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2614 return port |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2615 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2616 def _gettest(self, testdesc, count): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2617 """Obtain a Test by looking at its filename. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2618 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2619 Returns a Test instance. The Test may not be runnable if it doesn't |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2620 map to a known type. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2621 """ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2622 path = testdesc['path'] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2623 lctest = path.lower() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2624 testcls = Test |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2625 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2626 for ext, cls in self.TESTTYPES: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2627 if lctest.endswith(ext): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2628 testcls = cls |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2629 break |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2630 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2631 refpath = os.path.join(self._testdir, path) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2632 tmpdir = os.path.join(self._hgtmp, b'child%d' % count) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2633 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2634 # extra keyword parameters. 'case' is used by .t tests |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2635 kwds = dict((k, testdesc[k]) for k in ['case'] if k in testdesc) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2636 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2637 t = testcls(refpath, self._outputdir, tmpdir, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2638 keeptmpdir=self.options.keep_tmpdir, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2639 debug=self.options.debug, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2640 timeout=self.options.timeout, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2641 startport=self._getport(count), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2642 extraconfigopts=self.options.extra_config_opt, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2643 py3kwarnings=self.options.py3k_warnings, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2644 shell=self.options.shell, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2645 hgcommand=self._hgcommand, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2646 usechg=bool(self.options.with_chg or self.options.chg), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2647 useipv6=useipv6, **kwds) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2648 t.should_reload = True |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2649 return t |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2650 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2651 def _cleanup(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2652 """Clean up state from this test invocation.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2653 if self.options.keep_tmpdir: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2654 return |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2655 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2656 vlog("# Cleaning up HGTMP", self._hgtmp) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2657 shutil.rmtree(self._hgtmp, True) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2658 for f in self._createdfiles: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2659 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2660 os.remove(f) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2661 except OSError: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2662 pass |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2663 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2664 def _usecorrectpython(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2665 """Configure the environment to use the appropriate Python in tests.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2666 # Tests must use the same interpreter as us or bad things will happen. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2667 pyexename = sys.platform == 'win32' and b'python.exe' or b'python' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2668 if getattr(os, 'symlink', None): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2669 vlog("# Making python executable in test path a symlink to '%s'" % |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2670 sys.executable) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2671 mypython = os.path.join(self._tmpbindir, pyexename) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2672 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2673 if os.readlink(mypython) == sys.executable: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2674 return |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2675 os.unlink(mypython) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2676 except OSError as err: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2677 if err.errno != errno.ENOENT: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2678 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2679 if self._findprogram(pyexename) != sys.executable: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2680 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2681 os.symlink(sys.executable, mypython) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2682 self._createdfiles.append(mypython) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2683 except OSError as err: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2684 # child processes may race, which is harmless |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2685 if err.errno != errno.EEXIST: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2686 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2687 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2688 exedir, exename = os.path.split(sys.executable) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2689 vlog("# Modifying search path to find %s as %s in '%s'" % |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2690 (exename, pyexename, exedir)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2691 path = os.environ['PATH'].split(os.pathsep) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2692 while exedir in path: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2693 path.remove(exedir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2694 os.environ['PATH'] = os.pathsep.join([exedir] + path) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2695 if not self._findprogram(pyexename): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2696 print("WARNING: Cannot find %s in search path" % pyexename) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2697 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2698 def _installhg(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2699 """Install hg into the test environment. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2700 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2701 This will also configure hg with the appropriate testing settings. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2702 """ |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2703 vlog("# Performing temporary installation of HG") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2704 installerrs = os.path.join(self._hgtmp, b"install.err") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2705 compiler = '' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2706 if self.options.compiler: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2707 compiler = '--compiler ' + self.options.compiler |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2708 if self.options.pure: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2709 pure = b"--pure" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2710 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2711 pure = b"" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2712 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2713 # Run installer in hg root |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2714 script = os.path.realpath(sys.argv[0]) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2715 exe = sys.executable |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2716 if PYTHON3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2717 compiler = _bytespath(compiler) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2718 script = _bytespath(script) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2719 exe = _bytespath(exe) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2720 hgroot = os.path.dirname(os.path.dirname(script)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2721 self._hgroot = hgroot |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2722 os.chdir(hgroot) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2723 nohome = b'--home=""' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2724 if os.name == 'nt': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2725 # The --home="" trick works only on OS where os.sep == '/' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2726 # because of a distutils convert_path() fast-path. Avoid it at |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2727 # least on Windows for now, deal with .pydistutils.cfg bugs |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2728 # when they happen. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2729 nohome = b'' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2730 cmd = (b'%(exe)s setup.py %(pure)s clean --all' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2731 b' build %(compiler)s --build-base="%(base)s"' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2732 b' install --force --prefix="%(prefix)s"' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2733 b' --install-lib="%(libdir)s"' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2734 b' --install-scripts="%(bindir)s" %(nohome)s >%(logfile)s 2>&1' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2735 % {b'exe': exe, b'pure': pure, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2736 b'compiler': compiler, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2737 b'base': os.path.join(self._hgtmp, b"build"), |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2738 b'prefix': self._installdir, b'libdir': self._pythondir, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2739 b'bindir': self._bindir, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2740 b'nohome': nohome, b'logfile': installerrs}) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2741 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2742 # setuptools requires install directories to exist. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2743 def makedirs(p): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2744 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2745 os.makedirs(p) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2746 except OSError as e: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2747 if e.errno != errno.EEXIST: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2748 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2749 makedirs(self._pythondir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2750 makedirs(self._bindir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2751 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2752 vlog("# Running", cmd) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2753 if os.system(cmd) == 0: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2754 if not self.options.verbose: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2755 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2756 os.remove(installerrs) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2757 except OSError as e: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2758 if e.errno != errno.ENOENT: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2759 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2760 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2761 f = open(installerrs, 'rb') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2762 for line in f: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2763 if PYTHON3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2764 sys.stdout.buffer.write(line) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2765 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2766 sys.stdout.write(line) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2767 f.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2768 sys.exit(1) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2769 os.chdir(self._testdir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2770 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2771 self._usecorrectpython() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2772 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2773 if self.options.py3k_warnings and not self.options.anycoverage: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2774 vlog("# Updating hg command to enable Py3k Warnings switch") |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2775 f = open(os.path.join(self._bindir, 'hg'), 'rb') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2776 lines = [line.rstrip() for line in f] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2777 lines[0] += ' -3' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2778 f.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2779 f = open(os.path.join(self._bindir, 'hg'), 'wb') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2780 for line in lines: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2781 f.write(line + '\n') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2782 f.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2783 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2784 hgbat = os.path.join(self._bindir, b'hg.bat') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2785 if os.path.isfile(hgbat): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2786 # hg.bat expects to be put in bin/scripts while run-tests.py |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2787 # installation layout put it in bin/ directly. Fix it |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2788 f = open(hgbat, 'rb') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2789 data = f.read() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2790 f.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2791 if b'"%~dp0..\python" "%~dp0hg" %*' in data: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2792 data = data.replace(b'"%~dp0..\python" "%~dp0hg" %*', |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2793 b'"%~dp0python" "%~dp0hg" %*') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2794 f = open(hgbat, 'wb') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2795 f.write(data) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2796 f.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2797 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2798 print('WARNING: cannot fix hg.bat reference to python.exe') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2799 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2800 if self.options.anycoverage: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2801 custom = os.path.join(self._testdir, 'sitecustomize.py') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2802 target = os.path.join(self._pythondir, 'sitecustomize.py') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2803 vlog('# Installing coverage trigger to %s' % target) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2804 shutil.copyfile(custom, target) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2805 rc = os.path.join(self._testdir, '.coveragerc') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2806 vlog('# Installing coverage rc to %s' % rc) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2807 os.environ['COVERAGE_PROCESS_START'] = rc |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2808 covdir = os.path.join(self._installdir, '..', 'coverage') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2809 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2810 os.mkdir(covdir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2811 except OSError as e: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2812 if e.errno != errno.EEXIST: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2813 raise |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2814 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2815 os.environ['COVERAGE_DIR'] = covdir |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2816 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2817 def _checkhglib(self, verb): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2818 """Ensure that the 'mercurial' package imported by python is |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2819 the one we expect it to be. If not, print a warning to stderr.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2820 if ((self._bindir == self._pythondir) and |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2821 (self._bindir != self._tmpbindir)): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2822 # The pythondir has been inferred from --with-hg flag. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2823 # We cannot expect anything sensible here. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2824 return |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2825 expecthg = os.path.join(self._pythondir, b'mercurial') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2826 actualhg = self._gethgpath() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2827 if os.path.abspath(actualhg) != os.path.abspath(expecthg): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2828 sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2829 ' (expected %s)\n' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2830 % (verb, actualhg, expecthg)) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2831 def _gethgpath(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2832 """Return the path to the mercurial package that is actually found by |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2833 the current Python interpreter.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2834 if self._hgpath is not None: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2835 return self._hgpath |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2836 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2837 cmd = b'%s -c "import mercurial; print (mercurial.__path__[0])"' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2838 cmd = cmd % PYTHON |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2839 if PYTHON3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2840 cmd = _strpath(cmd) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2841 pipe = os.popen(cmd) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2842 try: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2843 self._hgpath = _bytespath(pipe.read().strip()) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2844 finally: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2845 pipe.close() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2846 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2847 return self._hgpath |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2848 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2849 def _installchg(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2850 """Install chg into the test environment""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2851 vlog('# Performing temporary installation of CHG') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2852 assert os.path.dirname(self._bindir) == self._installdir |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2853 assert self._hgroot, 'must be called after _installhg()' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2854 cmd = (b'"%(make)s" clean install PREFIX="%(prefix)s"' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2855 % {b'make': 'make', # TODO: switch by option or environment? |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2856 b'prefix': self._installdir}) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2857 cwd = os.path.join(self._hgroot, b'contrib', b'chg') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2858 vlog("# Running", cmd) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2859 proc = subprocess.Popen(cmd, shell=True, cwd=cwd, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2860 stdin=subprocess.PIPE, stdout=subprocess.PIPE, |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2861 stderr=subprocess.STDOUT) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2862 out, _err = proc.communicate() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2863 if proc.returncode != 0: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2864 if PYTHON3: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2865 sys.stdout.buffer.write(out) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2866 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2867 sys.stdout.write(out) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2868 sys.exit(1) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2869 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2870 def _outputcoverage(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2871 """Produce code coverage output.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2872 import coverage |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2873 coverage = coverage.coverage |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2874 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2875 vlog('# Producing coverage report') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2876 # chdir is the easiest way to get short, relative paths in the |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2877 # output. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2878 os.chdir(self._hgroot) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2879 covdir = os.path.join(self._installdir, '..', 'coverage') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2880 cov = coverage(data_file=os.path.join(covdir, 'cov')) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2881 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2882 # Map install directory paths back to source directory. |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2883 cov.config.paths['srcdir'] = ['.', self._pythondir] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2884 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2885 cov.combine() |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2886 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2887 omit = [os.path.join(x, '*') for x in [self._bindir, self._testdir]] |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2888 cov.report(ignore_errors=True, omit=omit) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2889 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2890 if self.options.htmlcov: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2891 htmldir = os.path.join(self._outputdir, 'htmlcov') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2892 cov.html_report(directory=htmldir, omit=omit) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2893 if self.options.annotate: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2894 adir = os.path.join(self._outputdir, 'annotated') |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2895 if not os.path.isdir(adir): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2896 os.mkdir(adir) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2897 cov.annotate(directory=adir, omit=omit) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2898 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2899 def _findprogram(self, program): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2900 """Search PATH for a executable program""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2901 dpb = _bytespath(os.defpath) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2902 sepb = _bytespath(os.pathsep) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2903 for p in osenvironb.get(b'PATH', dpb).split(sepb): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2904 name = os.path.join(p, program) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2905 if os.name == 'nt' or os.access(name, os.X_OK): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2906 return name |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2907 return None |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2908 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2909 def _checktools(self): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2910 """Ensure tools required to run tests are present.""" |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2911 for p in self.REQUIREDTOOLS: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2912 if os.name == 'nt' and not p.endswith('.exe'): |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2913 p += '.exe' |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2914 found = self._findprogram(p) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2915 if found: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2916 vlog("# Found prerequisite", p, "at", found) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2917 else: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2918 print("WARNING: Did not find prerequisite tool: %s " % |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2919 p.decode("utf-8")) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2920 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2921 if __name__ == '__main__': |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2922 runner = TestRunner() |
492
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
2923 |
6d010ec28d7d
tests: upgrade run-tests.py
David M. Carr <david@carrclan.us>
parents:
32
diff
changeset
|
2924 try: |
1055
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2925 import msvcrt |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2926 msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2927 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2928 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2929 except ImportError: |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2930 pass |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2931 |
e085b381e8e2
tests: update run-tests.py
Kevin Bullock <kbullock@ringworld.org>
parents:
674
diff
changeset
|
2932 sys.exit(runner.run(sys.argv[1:])) |