Show More
@@ -40,6 +40,7 b' def find_program(program):' | |||
|
40 | 40 | return name |
|
41 | 41 | return None |
|
42 | 42 | |
|
43 | def check_required_tools(): | |
|
43 | 44 | # Before we go any further, check for pre-requisite tools |
|
44 | 45 | # stuff from coreutils (cat, rm, etc) are not tested |
|
45 | 46 | for p in required_tools: |
@@ -51,28 +52,12 b' for p in required_tools:' | |||
|
51 | 52 | else: |
|
52 | 53 | print "WARNING: Did not find prerequisite tool: "+p |
|
53 | 54 | |
|
54 | # Reset some environment variables to well-known values | |
|
55 | os.environ['LANG'] = os.environ['LC_ALL'] = 'C' | |
|
56 | os.environ['TZ'] = 'GMT' | |
|
57 | ||
|
58 | os.environ["HGEDITOR"] = sys.executable + ' -c "import sys; sys.exit(0)"' | |
|
59 | os.environ["HGMERGE"] = sys.executable + ' -c "import sys; sys.exit(0)"' | |
|
60 | os.environ["HGUSER"] = "test" | |
|
61 | os.environ["HGRCPATH"] = "" | |
|
62 | ||
|
63 | TESTDIR = os.environ["TESTDIR"] = os.getcwd() | |
|
64 | HGTMP = os.environ["HGTMP"] = tempfile.mkdtemp("", "hgtests.") | |
|
65 | ||
|
66 | 55 | def cleanup_exit(): |
|
67 | 56 | if verbose: |
|
68 | 57 | print "# Cleaning up HGTMP", HGTMP |
|
69 | 58 | shutil.rmtree(HGTMP, True) |
|
70 | 59 | |
|
71 | vlog("# Using TESTDIR", TESTDIR) | |
|
72 | vlog("# Using HGTMP", HGTMP) | |
|
73 | ||
|
74 | os.umask(022) | |
|
75 | ||
|
60 | def install_hg(): | |
|
76 | 61 | vlog("# Performing temporary installation of HG") |
|
77 | 62 | INST = os.path.join(HGTMP, "install") |
|
78 | 63 | BINDIR = os.path.join(INST, "bin") |
@@ -91,16 +76,12 b' else:' | |||
|
91 | 76 | for line in f: |
|
92 | 77 | print line, |
|
93 | 78 | f.close() |
|
94 | cleanup_exit() | |
|
95 | 79 | sys.exit(1) |
|
96 | 80 | os.chdir(TESTDIR) |
|
97 | 81 | |
|
98 | 82 | os.environ["PATH"] = "%s%s%s" % (BINDIR, os.pathsep, os.environ["PATH"]) |
|
99 | 83 | os.environ["PYTHONPATH"] = PYTHONDIR |
|
100 | 84 | |
|
101 | tests = 0 | |
|
102 | failed = 0 | |
|
103 | ||
|
104 | 85 | def run(cmd, split_lines=True): |
|
105 | 86 | """Run command in a sub-process, capturing the output (stdout and stderr). |
|
106 | 87 | Return the exist code, and output.""" |
@@ -176,7 +157,35 b' def run_one(test):' | |||
|
176 | 157 | shutil.rmtree(tmpd, True) |
|
177 | 158 | return ret == 0 |
|
178 | 159 | |
|
179 | for test in os.listdir("."): | |
|
160 | ||
|
161 | os.umask(022) | |
|
162 | ||
|
163 | check_required_tools() | |
|
164 | ||
|
165 | # Reset some environment variables to well-known values so that | |
|
166 | # the tests produce repeatable output. | |
|
167 | os.environ['LANG'] = os.environ['LC_ALL'] = 'C' | |
|
168 | os.environ['TZ'] = 'GMT' | |
|
169 | ||
|
170 | os.environ["HGEDITOR"] = sys.executable + ' -c "import sys; sys.exit(0)"' | |
|
171 | os.environ["HGMERGE"] = sys.executable + ' -c "import sys; sys.exit(0)"' | |
|
172 | os.environ["HGUSER"] = "test" | |
|
173 | os.environ["HGRCPATH"] = "" | |
|
174 | ||
|
175 | TESTDIR = os.environ["TESTDIR"] = os.getcwd() | |
|
176 | HGTMP = os.environ["HGTMP"] = tempfile.mkdtemp("", "hgtests.") | |
|
177 | vlog("# Using TESTDIR", TESTDIR) | |
|
178 | vlog("# Using HGTMP", HGTMP) | |
|
179 | ||
|
180 | try: | |
|
181 | install_hg() | |
|
182 | ||
|
183 | tests = 0 | |
|
184 | failed = 0 | |
|
185 | ||
|
186 | if len(args) == 0: | |
|
187 | args = os.listdir(".") | |
|
188 | for test in args: | |
|
180 | 189 | if test.startswith("test-"): |
|
181 | 190 | if '~' in test or re.search(r'\.(out|err)$', test): |
|
182 | 191 | continue |
@@ -184,8 +193,8 b' for test in os.listdir("."):' | |||
|
184 | 193 | failed += 1 |
|
185 | 194 | tests += 1 |
|
186 | 195 | |
|
187 | print "# Ran %d tests, %d failed." % (tests, failed) | |
|
188 | ||
|
196 | print "\n# Ran %d tests, %d failed." % (tests, failed) | |
|
197 | finally: | |
|
189 | 198 | cleanup_exit() |
|
190 | 199 | |
|
191 | 200 | if failed: |
General Comments 0
You need to be logged in to leave comments.
Login now