summaryrefslogtreecommitdiff
path: root/ext/ply/test/testyacc.py
blob: a185cbb2940f559745daf986dc69a2d06d94ba26 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/local/bin
# ----------------------------------------------------------------------
# testyacc.py
#
# Run tests for the yacc module
# ----------------------------------------------------------------------

import sys,os,glob

if len(sys.argv) < 2:
    print "Usage: python testyacc.py directory"
    raise SystemExit

dirname = None
make = 0

for o in sys.argv[1:]:
    if o == '-make':
        make = 1
    else:
        dirname = o
        break

if not dirname:
    print "Usage: python testyacc.py [-make] directory"
    raise SystemExit

f = glob.glob("%s/%s" % (dirname,"yacc_*.py"))

print "**** Running tests for yacc ****"

for t in f:
    name = t[:-3]
    print "Testing %-32s" % name,
    os.system("rm -f %s/parsetab.*" % dirname)
    if make:
        if not os.path.exists("%s.exp" % name):
            os.system("python %s.py >%s.exp 2>&1" % (name,name))
        passed = 1
    else:
        os.system("python %s.py >%s.out 2>&1" % (name,name))
        a = os.system("diff %s.out %s.exp >%s.dif" % (name,name,name))
        if a == 0:
            passed = 1
        else:
            passed = 0

    if passed:
        print "Passed"
    else:
        print "Failed. See %s.dif" % name