##// END OF EJS Templates
run-tests: rename Test._test to Test.name...
Gregory Szorc -
r21435:f376f56a default
parent child Browse files
Show More
@@ -351,9 +351,10 b' class Test(object):'
351 path = os.path.join(runner.testdir, test)
351 path = os.path.join(runner.testdir, test)
352 errpath = os.path.join(runner.testdir, '%s.err' % test)
352 errpath = os.path.join(runner.testdir, '%s.err' % test)
353
353
354 self.name = test
355
354 self._runner = runner
356 self._runner = runner
355 self._testdir = runner.testdir
357 self._testdir = runner.testdir
356 self._test = test
357 self._path = path
358 self._path = path
358 self._options = runner.options
359 self._options = runner.options
359 self._count = count
360 self._count = count
@@ -392,16 +393,16 b' class Test(object):'
392 return self.skip("Doesn't exist")
393 return self.skip("Doesn't exist")
393
394
394 options = self._options
395 options = self._options
395 if not (options.whitelisted and self._test in options.whitelisted):
396 if not (options.whitelisted and self.name in options.whitelisted):
396 if options.blacklist and self._test in options.blacklist:
397 if options.blacklist and self.name in options.blacklist:
397 return self.skip('blacklisted')
398 return self.skip('blacklisted')
398
399
399 if options.retest and not os.path.exists('%s.err' % self._test):
400 if options.retest and not os.path.exists('%s.err' % self.name):
400 return self.ignore('not retesting')
401 return self.ignore('not retesting')
401
402
402 if options.keywords:
403 if options.keywords:
403 f = open(self._test)
404 f = open(self.name)
404 t = f.read().lower() + self._test.lower()
405 t = f.read().lower() + self.name.lower()
405 f.close()
406 f.close()
406 for k in options.keywords.lower().split():
407 for k in options.keywords.lower().split():
407 if k in t:
408 if k in t:
@@ -409,7 +410,7 b' class Test(object):'
409 else:
410 else:
410 return self.ignore("doesn't match keyword")
411 return self.ignore("doesn't match keyword")
411
412
412 if not os.path.basename(self._test.lower()).startswith('test-'):
413 if not os.path.basename(self.name.lower()).startswith('test-'):
413 return self.skip('not a test file')
414 return self.skip('not a test file')
414
415
415 # Remove any previous output files.
416 # Remove any previous output files.
@@ -423,7 +424,7 b' class Test(object):'
423 self._daemonpids.append(env['DAEMON_PIDS'])
424 self._daemonpids.append(env['DAEMON_PIDS'])
424 self._createhgrc(env['HGRCPATH'])
425 self._createhgrc(env['HGRCPATH'])
425
426
426 vlog('# Test', self._test)
427 vlog('# Test', self.name)
427
428
428 starttime = time.time()
429 starttime = time.time()
429 try:
430 try:
@@ -431,7 +432,7 b' class Test(object):'
431 duration = time.time() - starttime
432 duration = time.time() - starttime
432 except KeyboardInterrupt:
433 except KeyboardInterrupt:
433 duration = time.time() - starttime
434 duration = time.time() - starttime
434 log('INTERRUPTED: %s (after %d seconds)' % (self._test, duration))
435 log('INTERRUPTED: %s (after %d seconds)' % (self.name, duration))
435 raise
436 raise
436 except Exception, e:
437 except Exception, e:
437 return self.fail('Exception during execution: %s' % e, 255)
438 return self.fail('Exception during execution: %s' % e, 255)
@@ -506,7 +507,7 b' class Test(object):'
506 sys.stdout.flush()
507 sys.stdout.flush()
507 iolock.release()
508 iolock.release()
508
509
509 self._runner.times.append((self._test, duration))
510 self._runner.times.append((self.name, duration))
510
511
511 return res
512 return res
512
513
@@ -587,12 +588,12 b' class Test(object):'
587 hgrc.close()
588 hgrc.close()
588
589
589 def success(self):
590 def success(self):
590 return '.', self._test, ''
591 return '.', self.name, ''
591
592
592 def fail(self, msg, ret):
593 def fail(self, msg, ret):
593 warned = ret is False
594 warned = ret is False
594 if not self._options.nodiff:
595 if not self._options.nodiff:
595 log("\n%s: %s %s" % (warned and 'Warning' or 'ERROR', self._test,
596 log("\n%s: %s %s" % (warned and 'Warning' or 'ERROR', self.name,
596 msg))
597 msg))
597 if (not ret and self._options.interactive and
598 if (not ret and self._options.interactive and
598 os.path.exists(self._errpath)):
599 os.path.exists(self._errpath)):
@@ -601,23 +602,23 b' class Test(object):'
601 answer = sys.stdin.readline().strip()
602 answer = sys.stdin.readline().strip()
602 iolock.release()
603 iolock.release()
603 if answer.lower() in ('y', 'yes'):
604 if answer.lower() in ('y', 'yes'):
604 if self._test.endswith('.t'):
605 if self.name.endswith('.t'):
605 rename(self._errpath, self._path)
606 rename(self._errpath, self._path)
606 else:
607 else:
607 rename(self._errpath, '%s.out' % self._path)
608 rename(self._errpath, '%s.out' % self._path)
608
609
609 return '.', self._test, ''
610 return '.', self.name, ''
610
611
611 return warned and '~' or '!', self._test, msg
612 return warned and '~' or '!', self.name, msg
612
613
613 def skip(self, msg):
614 def skip(self, msg):
614 if self._options.verbose:
615 if self._options.verbose:
615 log("\nSkipping %s: %s" % (self._path, msg))
616 log("\nSkipping %s: %s" % (self._path, msg))
616
617
617 return 's', self._test, msg
618 return 's', self.name, msg
618
619
619 def ignore(self, msg):
620 def ignore(self, msg):
620 return 'i', self._test, msg
621 return 'i', self.name, msg
621
622
622 class PythonTest(Test):
623 class PythonTest(Test):
623 """A Python-based test."""
624 """A Python-based test."""
General Comments 0
You need to be logged in to leave comments. Login now