tests/run-tests.py
changeset 21366 5047248536c5
parent 21365 10cf9054d941
child 21367 522e3d24a461
equal deleted inserted replaced
21365:10cf9054d941 21366:5047248536c5
  1012             'i': [],
  1012             'i': [],
  1013         }
  1013         }
  1014         self.abort = [False]
  1014         self.abort = [False]
  1015         self._createdfiles = []
  1015         self._createdfiles = []
  1016 
  1016 
       
  1017     def run(self, tests):
       
  1018         """Run the test suite."""
       
  1019         return self._run(tests)
       
  1020 
       
  1021     def _run(self, tests):
       
  1022         vlog("# Using TESTDIR", self.testdir)
       
  1023         vlog("# Using HGTMP", self.hgtmp)
       
  1024         vlog("# Using PATH", os.environ["PATH"])
       
  1025         vlog("# Using", IMPL_PATH, os.environ[IMPL_PATH])
       
  1026 
       
  1027         try:
       
  1028             return self._runtests(tests) or 0
       
  1029         finally:
       
  1030             time.sleep(.1)
       
  1031             self._cleanup()
       
  1032 
  1017     def findtests(self, args):
  1033     def findtests(self, args):
  1018         """Finds possible test files from arguments.
  1034         """Finds possible test files from arguments.
  1019 
  1035 
  1020         If you wish to inject custom tests into the test harness, this would
  1036         If you wish to inject custom tests into the test harness, this would
  1021         be a good function to monkeypatch or override in a derived class.
  1037         be a good function to monkeypatch or override in a derived class.
  1031 
  1047 
  1032         return [t for t in args
  1048         return [t for t in args
  1033                 if os.path.basename(t).startswith('test-')
  1049                 if os.path.basename(t).startswith('test-')
  1034                     and (t.endswith('.py') or t.endswith('.t'))]
  1050                     and (t.endswith('.py') or t.endswith('.t'))]
  1035 
  1051 
  1036     def runtests(self, tests):
  1052     def _runtests(self, tests):
  1037         try:
  1053         try:
  1038             if self.inst:
  1054             if self.inst:
  1039                 self.installhg()
  1055                 self.installhg()
  1040                 self.checkhglib("Testing")
  1056                 self.checkhglib("Testing")
  1041             else:
  1057             else:
  1103                 refpath = os.path.join(self.testdir, test + out)
  1119                 refpath = os.path.join(self.testdir, test + out)
  1104                 break
  1120                 break
  1105 
  1121 
  1106         return testcls(self, test, count, refpath)
  1122         return testcls(self, test, count, refpath)
  1107 
  1123 
  1108     def cleanup(self):
  1124     def _cleanup(self):
  1109         """Clean up state from this test invocation."""
  1125         """Clean up state from this test invocation."""
  1110 
  1126 
  1111         if self.options.keep_tmpdir:
  1127         if self.options.keep_tmpdir:
  1112             return
  1128             return
  1113 
  1129 
  1443         pypath.append(oldpypath)
  1459         pypath.append(oldpypath)
  1444     os.environ[IMPL_PATH] = os.pathsep.join(pypath)
  1460     os.environ[IMPL_PATH] = os.pathsep.join(pypath)
  1445 
  1461 
  1446     runner.coveragefile = os.path.join(runner.testdir, ".coverage")
  1462     runner.coveragefile = os.path.join(runner.testdir, ".coverage")
  1447 
  1463 
  1448     vlog("# Using TESTDIR", runner.testdir)
  1464     return runner.run(tests)
  1449     vlog("# Using HGTMP", runner.hgtmp)
       
  1450     vlog("# Using PATH", os.environ["PATH"])
       
  1451     vlog("# Using", IMPL_PATH, os.environ[IMPL_PATH])
       
  1452 
       
  1453     try:
       
  1454         return runner.runtests(tests) or 0
       
  1455     finally:
       
  1456         time.sleep(.1)
       
  1457         runner.cleanup()
       
  1458 
  1465 
  1459 if __name__ == '__main__':
  1466 if __name__ == '__main__':
  1460     sys.exit(main(sys.argv[1:]))
  1467     sys.exit(main(sys.argv[1:]))