cscg24-lolpython

CSCG 2024 Challenge 'Can I Haz Lolpython?'
git clone https://git.sinitax.com/sinitax/cscg24-lolpython
Log | Files | Refs | sfeed.txt

testyacc.py (1268B)


      1#!/usr/local/bin
      2# ----------------------------------------------------------------------
      3# testyacc.py
      4#
      5# Run tests for the yacc module
      6# ----------------------------------------------------------------------
      7
      8import sys,os,glob
      9
     10if len(sys.argv) < 2:
     11    print "Usage: python testyacc.py directory"
     12    raise SystemExit
     13
     14dirname = None
     15make = 0
     16
     17for o in sys.argv[1:]:
     18    if o == '-make':
     19        make = 1
     20    else:
     21        dirname = o
     22        break
     23
     24if not dirname:
     25    print "Usage: python testyacc.py [-make] directory"
     26    raise SystemExit
     27
     28f = glob.glob("%s/%s" % (dirname,"yacc_*.py"))
     29
     30print "**** Running tests for yacc ****"
     31
     32for 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