File: help.test

package info (click to toggle)
atheist 0.20100717-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 900 kB
  • ctags: 558
  • sloc: python: 2,922; xml: 578; makefile: 111; sh: 5
file content (58 lines) | stat: -rw-r--r-- 1,365 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- mode:python; coding:utf-8 -*-

def get_opts():
    import atheist
    return atheist.parser.option_list


def man_opts():

    retval = []
    for opt in get_opts():
        _short = str.join('', opt._short_opts)
        _long = opt._long_opts[0]
        dest = opt.dest.upper() if opt.dest else ''

        val = ''
        if opt.takes_value():
            if _short:
                val = "%s %s, " % (_short, dest)
            val += "%s=%s" % (_long, dest)
        else:
            if _short:
                val = "%s, " % _short
            val += _long

#        print opt._short_opts, val
        retval.append(val)

    return retval


def doc_opts():
    return ['cmdoption:: %s' % x for x in man_opts()]

# --help
t = Test('$atheist', expected=1)
t.post += FileContains('ABSOLUTELY NO WARRANTY')
for opt in man_opts():
    t.post += FileContains(opt)

# sphinx documentation
atheist_doc = '$basedir/doc/intro.rst'
t = Test('cat %s' % atheist_doc)
t.pre += FileExists(atheist_doc)
for opt in doc_opts():
    t.post += FileContains(opt)

# manpage
man_src = '$basedir/debian/atheist.xml'
man_dst = '$basedir/debian/atheist.1'
t = Test('./debian/rules %s' % man_dst)
t.pre += DebPkgInstalled("cdbs")
t.pre += FileExists(man_src)
t.gen += man_dst

t = Test('man %s | cat' % man_dst, shell=True)
for opt in man_opts():
    t.post += FileContains(opt)