tests/run-tests.py
changeset 21363 00e5f5b9fc90
parent 21362 ff4ce72cc8d6
child 21364 558246fa98b8
equal deleted inserted replaced
21362:ff4ce72cc8d6 21363:00e5f5b9fc90
  1024             'i': [],
  1024             'i': [],
  1025         }
  1025         }
  1026         self.abort = [False]
  1026         self.abort = [False]
  1027         self._createdfiles = []
  1027         self._createdfiles = []
  1028 
  1028 
       
  1029     def findtests(self, args):
       
  1030         """Finds possible test files from arguments.
       
  1031 
       
  1032         If you wish to inject custom tests into the test harness, this would
       
  1033         be a good function to monkeypatch or override in a derived class.
       
  1034         """
       
  1035         if not args:
       
  1036             if self.options.changed:
       
  1037                 proc = Popen4('hg st --rev "%s" -man0 .' %
       
  1038                               self.options.changed, None, 0)
       
  1039                 stdout, stderr = proc.communicate()
       
  1040                 args = stdout.strip('\0').split('\0')
       
  1041             else:
       
  1042                 args = os.listdir('.')
       
  1043 
       
  1044         return [t for t in args
       
  1045                 if os.path.basename(t).startswith('test-')
       
  1046                     and (t.endswith('.py') or t.endswith('.t'))]
       
  1047 
  1029     def runtests(self, tests):
  1048     def runtests(self, tests):
  1030         try:
  1049         try:
  1031             if self.inst:
  1050             if self.inst:
  1032                 self.installhg()
  1051                 self.installhg()
  1033                 self.checkhglib("Testing")
  1052                 self.checkhglib("Testing")
  1320     runner.options = options
  1339     runner.options = options
  1321     os.umask(022)
  1340     os.umask(022)
  1322 
  1341 
  1323     checktools()
  1342     checktools()
  1324 
  1343 
  1325     if not args:
  1344     tests = runner.findtests(args)
  1326         if options.changed:
       
  1327             proc = Popen4('hg st --rev "%s" -man0 .' % options.changed,
       
  1328                           None, 0)
       
  1329             stdout, stderr = proc.communicate()
       
  1330             args = stdout.strip('\0').split('\0')
       
  1331         else:
       
  1332             args = os.listdir(".")
       
  1333 
       
  1334     tests = [t for t in args
       
  1335              if os.path.basename(t).startswith("test-")
       
  1336                  and (t.endswith(".py") or t.endswith(".t"))]
       
  1337 
  1345 
  1338     if options.random:
  1346     if options.random:
  1339         random.shuffle(tests)
  1347         random.shuffle(tests)
  1340     else:
  1348     else:
  1341         # keywords for slow tests
  1349         # keywords for slow tests