New directory structure:
[gem5.git] / ext / ply / test / testyacc.py
1 #!/usr/local/bin
2 # ----------------------------------------------------------------------
3 # testyacc.py
4 #
5 # Run tests for the yacc module
6 # ----------------------------------------------------------------------
7
8 import sys,os,glob
9
10 if len(sys.argv) < 2:
11 print "Usage: python testyacc.py directory"
12 raise SystemExit
13
14 dirname = None
15 make = 0
16
17 for o in sys.argv[1:]:
18 if o == '-make':
19 make = 1
20 else:
21 dirname = o
22 break
23
24 if not dirname:
25 print "Usage: python testyacc.py [-make] directory"
26 raise SystemExit
27
28 f = glob.glob("%s/%s" % (dirname,"yacc_*.py"))
29
30 print "**** Running tests for yacc ****"
31
32 for t in f:
33 name = t[:-3]
34 print "Testing %-32s" % name,
35 os.system("rm -f %s/parsetab.*" % dirname)
36 if make:
37 if not os.path.exists("%s.exp" % name):
38 os.system("python %s.py >%s.exp 2>&1" % (name,name))
39 passed = 1
40 else:
41 os.system("python %s.py >%s.out 2>&1" % (name,name))
42 a = os.system("diff %s.out %s.exp >%s.dif" % (name,name,name))
43 if a == 0:
44 passed = 1
45 else:
46 passed = 0
47
48 if passed:
49 print "Passed"
50 else:
51 print "Failed. See %s.dif" % name
52
53
54
55
56
57
58