comparison tests/run-tests.py @ 2145:5bb3cb9e5d13

make indentation of coverage code in run-tests.py nicer.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Thu, 27 Apr 2006 22:01:28 -0700
parents d3bddedfdbd0
children eb1ed410aa34
comparison
equal deleted inserted replaced
2144:d3bddedfdbd0 2145:5bb3cb9e5d13
101 os.path.join(BINDIR, '_hg.py'))) 101 os.path.join(BINDIR, '_hg.py')))
102 f.close() 102 f.close()
103 os.chmod(os.path.join(BINDIR, 'hg'), 0700) 103 os.chmod(os.path.join(BINDIR, 'hg'), 0700)
104 104
105 def output_coverage(): 105 def output_coverage():
106 if coverage: 106 vlog("# Producing coverage report")
107 vlog("# Producing coverage report") 107 omit = [BINDIR, TESTDIR, PYTHONDIR]
108 omit = [BINDIR, TESTDIR, PYTHONDIR] 108 if not options.cover_stdlib:
109 if not options.cover_stdlib: 109 # Exclude as system paths (ignoring empty strings seen on win)
110 # Exclude as system paths (ignoring empty strings seen on win) 110 omit += [x for x in sys.path if x != '']
111 omit += [x for x in sys.path if x != ''] 111 omit = ','.join(omit)
112 omit = ','.join(omit) 112 os.chdir(PYTHONDIR)
113 os.chdir(PYTHONDIR) 113 cmd = '"%s" "%s" -r "--omit=%s"' % (
114 cmd = '"%s" "%s" -r "--omit=%s"' % ( 114 sys.executable, os.path.join(TESTDIR, 'coverage.py'), omit)
115 sys.executable, os.path.join(TESTDIR, 'coverage.py'), omit) 115 vlog("# Running: "+cmd)
116 os.system(cmd)
117 if options.annotate:
118 adir = os.path.join(TESTDIR, 'annotated')
119 if not os.path.isdir(adir):
120 os.mkdir(adir)
121 cmd = '"%s" "%s" -a "--directory=%s" "--omit=%s"' % (
122 sys.executable, os.path.join(TESTDIR, 'coverage.py'),
123 adir, omit)
116 vlog("# Running: "+cmd) 124 vlog("# Running: "+cmd)
117 os.system(cmd) 125 os.system(cmd)
118 if options.annotate:
119 adir = os.path.join(TESTDIR, 'annotated')
120 if not os.path.isdir(adir):
121 os.mkdir(adir)
122 cmd = '"%s" "%s" -a "--directory=%s" "--omit=%s"' % (
123 sys.executable, os.path.join(TESTDIR, 'coverage.py'),
124 adir, omit)
125 vlog("# Running: "+cmd)
126 os.system(cmd)
127 126
128 def run(cmd, split_lines=True): 127 def run(cmd, split_lines=True):
129 """Run command in a sub-process, capturing the output (stdout and stderr). 128 """Run command in a sub-process, capturing the output (stdout and stderr).
130 Return the exist code, and output.""" 129 Return the exist code, and output."""
131 # TODO: Use subprocess.Popen if we're running on Python 2.4 130 # TODO: Use subprocess.Popen if we're running on Python 2.4
240 if not run_one(test): 239 if not run_one(test):
241 failed += 1 240 failed += 1
242 tests += 1 241 tests += 1
243 242
244 print "\n# Ran %d tests, %d failed." % (tests, failed) 243 print "\n# Ran %d tests, %d failed." % (tests, failed)
245 output_coverage() 244 if coverage:
245 output_coverage()
246 finally: 246 finally:
247 cleanup_exit() 247 cleanup_exit()
248 248
249 if failed: 249 if failed:
250 sys.exit(1) 250 sys.exit(1)