tests/heredoctest.py
author Patrick Mezard <pmezard@gmail.com>
Sun, 04 Dec 2011 18:22:25 +0100
branchstable
changeset 15609 8f4bad72d8b1
parent 15398 474279be5add
child 15434 5635a4017061
permissions -rw-r--r--
util: fix url.__str__() for windows file URLs Before: >>> str(url('file:///c:/tmp/foo/bar')) 'file:c%3C/tmp/foo/bar' After: >>> str(url('file:///c:/tmp/foo/bar')) 'file:///c%3C/tmp/foo/bar' The previous behaviour had no effect on mercurial itself (clone command for instance) because we fortunately called .localpath() on the parsed URL. hgsubversion was not so lucky and cloning a local subversion repository on Windows no longer worked on the default branch (it works on stable because de7e2fba4326 defeats the hasdriveletter() test in url class). I do not know if the %3C is correct or not but svn accepts file:// URLs containing it. Mads fixed it in de7e2fba4326, so we can always backport should the need arise.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15235
f7044da7a793 tests: add helper script for processing doctests read from stdin
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     1
import doctest, tempfile, os, sys
f7044da7a793 tests: add helper script for processing doctests read from stdin
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     2
f7044da7a793 tests: add helper script for processing doctests read from stdin
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     3
if __name__ == "__main__":
15398
474279be5add tests: fix readline escape characters in heredoctest.py/test-url.py
Brodie Rao <brodie@bitheap.org>
parents: 15247
diff changeset
     4
    if 'TERM' in os.environ:
474279be5add tests: fix readline escape characters in heredoctest.py/test-url.py
Brodie Rao <brodie@bitheap.org>
parents: 15247
diff changeset
     5
        del os.environ['TERM']
474279be5add tests: fix readline escape characters in heredoctest.py/test-url.py
Brodie Rao <brodie@bitheap.org>
parents: 15247
diff changeset
     6
15235
f7044da7a793 tests: add helper script for processing doctests read from stdin
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     7
    fd, name = tempfile.mkstemp(suffix='hg-tst')
15247
3cd1605e9d8e tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents: 15235
diff changeset
     8
3cd1605e9d8e tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents: 15235
diff changeset
     9
    try:
3cd1605e9d8e tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents: 15235
diff changeset
    10
        os.write(fd, sys.stdin.read())
3cd1605e9d8e tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents: 15235
diff changeset
    11
        os.close(fd)
3cd1605e9d8e tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents: 15235
diff changeset
    12
        failures, _ = doctest.testfile(name, module_relative=False)
3cd1605e9d8e tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents: 15235
diff changeset
    13
        if failures:
3cd1605e9d8e tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents: 15235
diff changeset
    14
            sys.exit(1)
3cd1605e9d8e tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents: 15235
diff changeset
    15
    finally:
3cd1605e9d8e tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents: 15235
diff changeset
    16
        os.remove(name)