cscg24-lolpython

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

testlex.py (1218B)


      1#!/usr/local/bin
      2# ----------------------------------------------------------------------
      3# testlex.py
      4#
      5# Run tests for the lexing module
      6# ----------------------------------------------------------------------
      7
      8import sys,os,glob
      9
     10if len(sys.argv) < 2:
     11    print "Usage: python testlex.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 testlex.py [-make] directory"
     26    raise SystemExit
     27
     28f = glob.glob("%s/%s" % (dirname,"lex_*.py"))
     29
     30print "**** Running tests for lex ****"
     31
     32for t in f:
     33    name = t[:-3]
     34    print "Testing %-32s" % name,
     35    if make:
     36        if not os.path.exists("%s.exp" % name):
     37            os.system("python %s.py >%s.exp 2>&1" % (name,name))
     38        passed = 1
     39    else:
     40        os.system("python %s.py >%s.out 2>&1" % (name,name))
     41        a = os.system("diff %s.out %s.exp >%s.dif" % (name,name,name))
     42        if a == 0:
     43            passed = 1
     44        else:
     45            passed = 0
     46
     47    if passed:
     48        print "Passed"
     49    else:
     50        print "Failed. See %s.dif" % name
     51        
     52        
     53                      
     54
     55    
     56        
     57