summaryrefslogtreecommitdiff
path: root/xml2po/tests/test.py
blob: c482b6e39328c21e891bd4d412c03f136ae115ff (plain)
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
#!/usr/bin/env python
import sys, os

SIMPLETESTS = { 'deep-finals.xml' : {},
                'deep-nonfinals.xml': {},
                'attribute-entities.xml': {},
                'docbook.xml' : {},
                'utf8-original.xml': {},
                'footnotes.xml': {},
                'keepents.xml': { "options" : "-k" },
                'adjacent-ents.xml': { "options" : "-k" },
                }

OTHERTESTS = [ ('relnotes', 'test.sh') ]

if len(sys.argv) > 1:
    input = sys.argv[1]
    pot = input.replace(".xml", ".pot")
    po = input.replace(".xml", ".po")
    myopts = ""
    if len(sys.argv) > 2:
        for opt in sys.argv[2:]:
            myopts += " " + opt
    output = input.replace(".xml", ".xml.out")
    ret = os.system("../xml2po %s %s | sed 's/\"POT-Creation-Date: .*$/\"POT-Creation-Date: \\\\n\"/' | diff -u %s -" % (myopts, input, pot))
    if ret:
        print "Problem: extraction from '%s'" % (input)
    ret = os.system("../xml2po -p %s %s %s | diff -u %s -" % (po, myopts, input, output))
    if ret:
        print "Problem: merging translation into '%s'" % (input)
else:
    for t in SIMPLETESTS:
        if SIMPLETESTS[t].has_key("options"):
            myopts = SIMPLETESTS[t]["options"]
        else: myopts = ""
        if os.system("%s %s %s" % (sys.argv[0], t, myopts)):
            print "WARNING: Test %s failed." % (t)
    
    for t in OTHERTESTS:
        if os.system("cd %s && ./%s" % (t[0], t[1])):
            print "WARNING: Test %s failed." % (t[0])