tests/test-duplicateoptions.py
author Mads Kiilerich <mads@kiilerich.com>
Wed, 29 Jun 2011 00:19:27 +0200
branchstable
changeset 14762 6beb26747430
parent 14449 7d171c05a631
child 15099 b1f49efeab65
permissions -rw-r--r--
tests: ignore inotify extension in test-duplicateoptions.py The inotify extension is only available on linux and setup.py will not install it on other platforms - but it will of course always be there in the source. test-duplicateoptions.py tried to load most extensions (including inotify if available). When the local uninstalled Mercurial was used it would thus always load the inotify extension and cause a warning on unsupported platforms. The inotify extension is not relevant for this test, so now we explicitly ignore it.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14449
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     1
import os
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     2
from mercurial import ui, commands, extensions
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     3
14762
6beb26747430 tests: ignore inotify extension in test-duplicateoptions.py
Mads Kiilerich <mads@kiilerich.com>
parents: 14449
diff changeset
     4
ignore = set(['highlight', 'inotify', 'win32text'])
14449
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     5
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     6
if os.name != 'nt':
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     7
    ignore.add('win32mbcs')
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     8
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     9
disabled = [ext for ext in extensions.disabled().keys() if ext not in ignore]
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    10
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    11
hgrc = open(os.environ["HGRCPATH"], 'w')
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    12
hgrc.write('[extensions]\n')
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    13
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    14
for ext in disabled:
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    15
    hgrc.write(ext + '=\n')
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    16
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    17
hgrc.close()
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    18
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    19
u = ui.ui()
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    20
extensions.loadall(u)
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    21
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    22
for cmd, entry in commands.table.iteritems():
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    23
    seenshort = set()
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    24
    seenlong = set()
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    25
    for option in entry[1]:
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    26
        if (option[0] and option[0] in seenshort) or \
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    27
           (option[1] and option[1] in seenlong):
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    28
            print "command '" + cmd + "' has duplicate option " + str(option)
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    29
        seenshort.add(option[0])
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    30
        seenlong.add(option[1])