def run(cls, args, file_ptr): try: sa = SyntaxAnalyzer(file_ptr, args) sa.run_analyzer() except Exception as ex: print(ex) traceback.print_exc()
def helper_run(self, filename): input_name = os.path.join(self.test_files, filename) output_path = os.path.join(self.test_files, "instructions_" + filename) assert_name = os.path.join(self.test_files, "assert_" + filename) sys.argv.extend(['-i', input_name]) argp = CompilersMain.get_args() with open(input_name, 'r') as input_file: sa = SyntaxAnalyzer(input_file, argp) sa.run_analyzer() with open(output_path) as ofile: with open(assert_name) as afile: for line in afile: self.assertEqual(ofile.readline().strip(), line.strip())