tests/run-tests.py
branchstable
changeset 741 e5bfe51eeea9
parent 740 7d3c26dea450
child 775 16f4cb2900fe
equal deleted inserted replaced
740:7d3c26dea450 741:e5bfe51eeea9
   130     parser.add_option("--tmpdir", type="string",
   130     parser.add_option("--tmpdir", type="string",
   131         help="run tests in the given temporary directory"
   131         help="run tests in the given temporary directory"
   132              " (implies --keep-tmpdir)")
   132              " (implies --keep-tmpdir)")
   133     parser.add_option("-v", "--verbose", action="store_true",
   133     parser.add_option("-v", "--verbose", action="store_true",
   134         help="output verbose messages")
   134         help="output verbose messages")
       
   135     parser.add_option("--view", type="string",
       
   136         help="external diff viewer")
   135     parser.add_option("--with-hg", type="string",
   137     parser.add_option("--with-hg", type="string",
   136         metavar="HG",
   138         metavar="HG",
   137         help="test using specified hg script rather than a "
   139         help="test using specified hg script rather than a "
   138              "temporary installation")
   140              "temporary installation")
   139     parser.add_option("-3", "--py3k-warnings", action="store_true",
   141     parser.add_option("-3", "--py3k-warnings", action="store_true",
   571         signal.alarm(0)
   573         signal.alarm(0)
   572 
   574 
   573     mark = '.'
   575     mark = '.'
   574 
   576 
   575     skipped = (ret == SKIPPED_STATUS)
   577     skipped = (ret == SKIPPED_STATUS)
       
   578 
   576     # If we're not in --debug mode and reference output file exists,
   579     # If we're not in --debug mode and reference output file exists,
   577     # check test output against it.
   580     # check test output against it.
   578     if options.debug:
   581     if options.debug:
   579         refout = None                   # to match out == None
   582         refout = None                   # to match out == None
   580     elif os.path.exists(ref):
   583     elif os.path.exists(ref):
   581         f = open(ref, "r")
   584         f = open(ref, "r")
   582         refout = splitnewlines(f.read())
   585         refout = splitnewlines(f.read())
   583         f.close()
   586         f.close()
   584     else:
   587     else:
   585         refout = []
   588         refout = []
       
   589 
       
   590     if (ret != 0 or out != refout) and not skipped and not options.debug:
       
   591         # Save errors to a file for diagnosis
       
   592         f = open(err, "wb")
       
   593         for line in out:
       
   594             f.write(line)
       
   595         f.close()
   586 
   596 
   587     if skipped:
   597     if skipped:
   588         mark = 's'
   598         mark = 's'
   589         if out is None:                 # debug mode: nothing to parse
   599         if out is None:                 # debug mode: nothing to parse
   590             missing = ['unknown']
   600             missing = ['unknown']
   603         if ret:
   613         if ret:
   604             fail("output changed and returned error code %d" % ret)
   614             fail("output changed and returned error code %d" % ret)
   605         else:
   615         else:
   606             fail("output changed")
   616             fail("output changed")
   607         if not options.nodiff:
   617         if not options.nodiff:
   608             showdiff(refout, out, ref, err)
   618             if options.view:
       
   619                 os.system("%s %s %s" % (options.view, ref, err))
       
   620             else:
       
   621                 showdiff(refout, out, ref, err)
   609         ret = 1
   622         ret = 1
   610     elif ret:
   623     elif ret:
   611         mark = '!'
   624         mark = '!'
   612         fail("returned error code %d" % ret)
   625         fail("returned error code %d" % ret)
   613 
   626 
   614     if not options.verbose:
   627     if not options.verbose:
   615         sys.stdout.write(mark)
   628         sys.stdout.write(mark)
   616         sys.stdout.flush()
   629         sys.stdout.flush()
   617 
       
   618     if ret != 0 and not skipped and not options.debug:
       
   619         # Save errors to a file for diagnosis
       
   620         f = open(err, "wb")
       
   621         for line in out:
       
   622             f.write(line)
       
   623         f.close()
       
   624 
   630 
   625     killdaemons()
   631     killdaemons()
   626 
   632 
   627     os.chdir(TESTDIR)
   633     os.chdir(TESTDIR)
   628     if not options.keep_tmpdir:
   634     if not options.keep_tmpdir: