Alien-SVN
view release on metacpan or search on metacpan
src/subversion/build/run_tests.py view on Meta::CPAN
try:
failed = svntest.main.execute_tests(prog_mod.test_list,
serial_only=serial_only,
test_name=progbase,
progress_func=prog_f,
test_selection=test_selection)
except svntest.Failure:
if self.log:
os.write(old_stdout, '.' * dot_count)
failed = True
# restore some values
sys.path = old_path
if self.log:
sys.stdout.flush()
sys.stderr.flush()
os.dup2(old_stdout, sys.stdout.fileno())
os.dup2(old_stderr, sys.stderr.fileno())
os.close(old_stdout)
os.close(old_stderr)
return failed
def _run_test(self, prog, test_nr, total_tests):
"Run a single test. Return the test's exit code."
if self.log:
log = self.log
else:
log = sys.stdout
test_nums = None
if '#' in prog:
prog, test_nums = prog.split('#')
progdir, progbase = os.path.split(prog)
if self.log:
# Using write here because we don't want even a trailing space
test_info = '[%s/%d] %s' % (str(test_nr + 1).zfill(len(str(total_tests))),
total_tests, progbase)
if self.list_tests:
sys.stdout.write('Listing tests in %s' % (test_info, ))
else:
sys.stdout.write('%s' % (test_info, ))
sys.stdout.flush()
else:
# ### Hack for --log-to-stdout to work (but not print any dots).
test_info = ''
if self.list_tests:
log.write('LISTING: %s\n' % progbase)
else:
log.write('START: %s\n' % progbase)
log.flush()
start_time = datetime.now()
progabs = os.path.abspath(os.path.join(self.srcdir, prog))
old_cwd = os.getcwd()
line_length = _get_term_width()
dots_needed = line_length \
- len(test_info) \
- len('success')
try:
os.chdir(progdir)
if progbase[-3:] == '.py':
failed = self._run_py_test(progabs, test_nums, dots_needed)
else:
failed = self._run_c_test(prog, test_nums, dots_needed)
except:
os.chdir(old_cwd)
raise
else:
os.chdir(old_cwd)
# We always return 1 for failed tests. Some other failure than 1
# probably means the test didn't run at all and probably didn't
# output any failure info. In that case, log a generic failure message.
# ### Even if failure==1 it could be that the test didn't run at all.
if failed and failed != 1:
if self.log:
log.write('FAIL: %s: Unknown test failure; see tests.log.\n' % progbase)
log.flush()
else:
log.write('FAIL: %s: Unknown test failure.\n' % progbase)
if not self.list_tests:
# Log the elapsed time.
elapsed_time = str(datetime.now() - start_time)
log.write('END: %s\n' % progbase)
log.write('ELAPSED: %s %s\n' % (progbase, elapsed_time))
log.write('\n')
# If we are only listing the tests just add a newline, otherwise if
# we printed a "Running all tests in ..." line, add the test result.
if self.log:
if self.list_tests:
print ''
else:
if failed:
print(TextColors.FAILURE + 'FAILURE' + TextColors.ENDC)
else:
print(TextColors.SUCCESS + 'success' + TextColors.ENDC)
return failed
def main():
try:
opts, args = my_getopt(sys.argv[1:], 'u:f:vc',
['url=', 'fs-type=', 'verbose', 'cleanup',
'http-library=', 'server-minor-version=',
'fsfs-packing', 'fsfs-sharding=',
'enable-sasl', 'parallel', 'config-file=',
'log-to-stdout', 'list', 'milestone-filter=',
'mode-filter=', 'set-log-level=', 'ssl-cert=',
'http-proxy='])
except getopt.GetoptError:
args = []
( run in 0.410 second using v1.01-cache-2.11-cpan-5735350b133 )