#!/usr/bin/env python3 # # Command-line interface for the glacia interpreter. # import sys import argparse from glacia.run import run p = argparse.ArgumentParser() p.add_argument("-v", "--verbose", action='store_true') p.add_argument("-r", "--runlines", type=int, default=-1) p.add_argument("-f", "--file") args = p.parse_args(sys.argv[1:]) run(**{ 'verbose': args.verbose, 'exec_lines': args.runlines, 'fn': args.file, })
print('') successful = 0 total = 0 for fn in glob.glob('test/code_tests/*.glaciatest'): total += 1 with open(fn, 'rb') as f: parts = f.read().decode('utf-8').split('---') expected = parts[0].strip() try: # Run the test program and collect the standard output. actual = run(src=parts[1].strip(), collect_stdout=True) except: print(color.print('Error running '+fn+':', 'red')) raise # If the expected output matches the actual output, the test passed. if expected == '\n'.join(actual): print(color.print('Test passed', 'green') + ': ' + fn) successful += 1 continue # Helper function to add tabs to multi-line strings. def output(s): if isinstance(s, str): return output(s.split('\n')) else: