Changeset 903


Ignore:
Timestamp:
12/29/19 16:07:19 (4 years ago)
Author:
Maciej Komosinski
Message:

Tester no longer exits on popular exceptions like 'file not found'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tester/tester.py

    r854 r903  
    11import os, os.path, sys, platform, re, copy
     2import traceback # for custom printing of exception trace/stack
    23import errno  # for delete_file_if_present()
    34import argparse
     
    150151                exename[0] = re.sub(rule[0], rule[1], exename[0])
    151152        return exename
     153
     154
     155def print_exception():
     156        print("\n"+("-"*60),'begin exception')
     157        traceback.print_exc()
     158        print("-"*60,'end exception')
    152159
    153160
     
    235242                        if is_test_active():
    236243                                print("\t", command, '"%s"' % line[1], end=" ")
    237                                 contents = []
    238                                 with open(os.path.join(globals.FILESDIR, line[1]), 'r') as main_test_filename:
    239                                         for line in main_test_filename:
    240                                                 contents.append(globals.stripEOL(line))
    241                                 ok = compare(contents, outfile, '_file')
     244                                try:
     245                                        contents = []
     246                                        with open(os.path.join(globals.FILESDIR, line[1]), 'r') as main_test_filename:
     247                                                for line in main_test_filename:
     248                                                        contents.append(globals.stripEOL(line))
     249                                        ok = compare(contents, outfile, '_file')
     250                                except Exception as e: # could also 'raise' for some types of exceptions if we wanted
     251                                        print_exception()
     252                                        ok = 0
    242253                                tests_failed += int(not ok)
    243254                                tests_total += 1
     
    245256                        if is_test_active():
    246257                                print("\t", command, end=" ")
    247                                 ok = test(args, test_name, input_text, output_net, output_msg, exe_prog, exeargs)
     258                                try:
     259                                        ok = test(args, test_name, input_text, output_net, output_msg, exe_prog, exeargs)
     260                                except Exception as e: # could also 'raise' for some types of exceptions if we wanted
     261                                        print_exception()
     262                                        ok = 0
    248263                                tests_failed += int(not ok)
    249264                                tests_total += 1
Note: See TracChangeset for help on using the changeset viewer.