~ubuntu-branches/ubuntu/precise/mercurial/precise-updates

« back to all changes in this revision

Viewing changes to tests/run-tests.py

  • Committer: Bazaar Package Importer
  • Author(s): Vincent Danjean, Javi Merino, Vincent Danjean
  • Date: 2010-07-04 09:55:28 UTC
  • mfrom: (1.2.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20100704095528-bzag1mhfylss9zth
Tags: 1.6-1
[ Javi Merino ]
* New upstream release (1.6). Many bug fixes and improvements. Among
    them:
  - push: break infinite http recursion bug with Python 2.6.5
       (issue2179 and issue2255) (Closes: #586907)
  - zeroconf: Don't use string exceptions (Closes: #585250)
* Removed patch for_upstream__bashism_in_examples.patch since a fix for
    #581122 is included upstream.
* Updated Standards-Version to 3.9 (no change needed)

[ Vincent Danjean ]
* debian/control:
  + Use Breaks instead of Conflicts
  + Use a fixed version in Replaces
    I put 1.4 but it has been a long time since nothing has been moved
    from mercurial to mercurial-common

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
import errno
47
47
import optparse
48
48
import os
49
 
import signal
 
49
import shutil
50
50
import subprocess
51
 
import shutil
52
51
import signal
53
52
import sys
54
53
import tempfile
70
69
SKIPPED_PREFIX = 'skipped: '
71
70
FAILED_PREFIX  = 'hghave check failed: '
72
71
PYTHON = sys.executable
 
72
IMPL_PATH = 'PYTHONPATH'
 
73
if 'java' in sys.platform:
 
74
    IMPL_PATH = 'JYTHONPATH'
73
75
 
74
76
requiredtools = ["python", "diff", "grep", "unzip", "gunzip", "bunzip2", "sed"]
75
77
 
81
83
 
82
84
def parseargs():
83
85
    parser = optparse.OptionParser("%prog [options] [tests]")
 
86
 
 
87
    # keep these sorted
 
88
    parser.add_option("--blacklist", action="append",
 
89
        help="skip tests listed in the specified blacklist file")
84
90
    parser.add_option("-C", "--annotate", action="store_true",
85
91
        help="output files annotated with coverage")
86
92
    parser.add_option("--child", type="int",
87
93
        help="run as child process, summary to given fd")
88
94
    parser.add_option("-c", "--cover", action="store_true",
89
95
        help="print a test coverage report")
 
96
    parser.add_option("-d", "--debug", action="store_true",
 
97
        help="debug mode: write output of test scripts to console"
 
98
             " rather than capturing and diff'ing it (disables timeout)")
90
99
    parser.add_option("-f", "--first", action="store_true",
91
100
        help="exit on the first test failure")
 
101
    parser.add_option("--inotify", action="store_true",
 
102
        help="enable inotify extension when running tests")
92
103
    parser.add_option("-i", "--interactive", action="store_true",
93
104
        help="prompt to accept changed output")
94
105
    parser.add_option("-j", "--jobs", type="int",
95
106
        help="number of jobs to run in parallel"
96
107
             " (default: $%s or %d)" % defaults['jobs'])
 
108
    parser.add_option("--keep-tmpdir", action="store_true",
 
109
        help="keep temporary directory after running tests")
97
110
    parser.add_option("-k", "--keywords",
98
111
        help="run tests matching keywords")
99
 
    parser.add_option("--keep-tmpdir", action="store_true",
100
 
        help="keep temporary directory after running tests")
101
 
    parser.add_option("--tmpdir", type="string",
102
 
        help="run tests in the given temporary directory"
103
 
             " (implies --keep-tmpdir)")
104
 
    parser.add_option("-d", "--debug", action="store_true",
105
 
        help="debug mode: write output of test scripts to console"
106
 
             " rather than capturing and diff'ing it (disables timeout)")
107
 
    parser.add_option("-R", "--restart", action="store_true",
108
 
        help="restart at last error")
 
112
    parser.add_option("-l", "--local", action="store_true",
 
113
        help="shortcut for --with-hg=<testdir>/../hg")
 
114
    parser.add_option("-n", "--nodiff", action="store_true",
 
115
        help="skip showing test changes")
109
116
    parser.add_option("-p", "--port", type="int",
110
117
        help="port on which servers should listen"
111
118
             " (default: $%s or %d)" % defaults['port'])
 
119
    parser.add_option("--pure", action="store_true",
 
120
        help="use pure Python code instead of C extensions")
 
121
    parser.add_option("-R", "--restart", action="store_true",
 
122
        help="restart at last error")
112
123
    parser.add_option("-r", "--retest", action="store_true",
113
124
        help="retest failed tests")
114
125
    parser.add_option("-S", "--noskips", action="store_true",
116
127
    parser.add_option("-t", "--timeout", type="int",
117
128
        help="kill errant tests after TIMEOUT seconds"
118
129
             " (default: $%s or %d)" % defaults['timeout'])
 
130
    parser.add_option("--tmpdir", type="string",
 
131
        help="run tests in the given temporary directory"
 
132
             " (implies --keep-tmpdir)")
119
133
    parser.add_option("-v", "--verbose", action="store_true",
120
134
        help="output verbose messages")
121
 
    parser.add_option("-n", "--nodiff", action="store_true",
122
 
        help="skip showing test changes")
 
135
    parser.add_option("--view", type="string",
 
136
        help="external diff viewer")
123
137
    parser.add_option("--with-hg", type="string",
124
138
        metavar="HG",
125
139
        help="test using specified hg script rather than a "
126
140
             "temporary installation")
127
 
    parser.add_option("--local", action="store_true",
128
 
        help="shortcut for --with-hg=<testdir>/../hg")
129
 
    parser.add_option("--pure", action="store_true",
130
 
        help="use pure Python code instead of C extensions")
131
141
    parser.add_option("-3", "--py3k-warnings", action="store_true",
132
142
        help="enable Py3k warnings on Python 2.6+")
133
 
    parser.add_option("--inotify", action="store_true",
134
 
        help="enable inotify extension when running tests")
135
 
    parser.add_option("--blacklist", action="append",
136
 
        help="skip tests listed in the specified blacklist file")
137
143
 
138
144
    for option, default in defaults.items():
139
145
        defaults[option] = int(os.environ.get(*default))
140
146
    parser.set_defaults(**defaults)
141
147
    (options, args) = parser.parse_args()
142
148
 
 
149
    # jython is always pure
 
150
    if 'java' in sys.platform or '__pypy__' in sys.modules:
 
151
        options.pure = True
 
152
 
143
153
    if options.with_hg:
144
154
        if not (os.path.isfile(options.with_hg) and
145
155
                os.access(options.with_hg, os.X_OK)):
565
575
    mark = '.'
566
576
 
567
577
    skipped = (ret == SKIPPED_STATUS)
 
578
 
568
579
    # If we're not in --debug mode and reference output file exists,
569
580
    # check test output against it.
570
581
    if options.debug:
576
587
    else:
577
588
        refout = []
578
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()
 
596
 
579
597
    if skipped:
580
598
        mark = 's'
581
599
        if out is None:                 # debug mode: nothing to parse
597
615
        else:
598
616
            fail("output changed")
599
617
        if not options.nodiff:
600
 
            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)
601
622
        ret = 1
602
623
    elif ret:
603
624
        mark = '!'
607
628
        sys.stdout.write(mark)
608
629
        sys.stdout.flush()
609
630
 
610
 
    if ret != 0 and not skipped and not options.debug:
611
 
        # Save errors to a file for diagnosis
612
 
        f = open(err, "wb")
613
 
        for line in out:
614
 
            f.write(line)
615
 
        f.close()
616
 
 
617
631
    killdaemons()
618
632
 
619
633
    os.chdir(TESTDIR)
843
857
    os.environ["EMAIL"] = "Foo Bar <foo.bar@example.com>"
844
858
    os.environ['CDPATH'] = ''
845
859
    os.environ['COLUMNS'] = '80'
 
860
    os.environ['GREP_OPTIONS'] = ''
846
861
    os.environ['http_proxy'] = ''
847
862
 
848
863
    # unset env related to hooks
914
929
        # it, in case external libraries are only available via current
915
930
        # PYTHONPATH.  (In particular, the Subversion bindings on OS X
916
931
        # are in /opt/subversion.)
917
 
        oldpypath = os.environ.get('PYTHONPATH')
 
932
        oldpypath = os.environ.get(IMPL_PATH)
918
933
        if oldpypath:
919
934
            pypath.append(oldpypath)
920
 
        os.environ['PYTHONPATH'] = os.pathsep.join(pypath)
 
935
        os.environ[IMPL_PATH] = os.pathsep.join(pypath)
921
936
 
922
937
    COVERAGE_FILE = os.path.join(TESTDIR, ".coverage")
923
938
 
938
953
    vlog("# Using TESTDIR", TESTDIR)
939
954
    vlog("# Using HGTMP", HGTMP)
940
955
    vlog("# Using PATH", os.environ["PATH"])
941
 
    vlog("# Using PYTHONPATH", os.environ["PYTHONPATH"])
 
956
    vlog("# Using", IMPL_PATH, os.environ[IMPL_PATH])
942
957
 
943
958
    try:
944
959
        if len(tests) > 1 and options.jobs > 1: