#! /usr/bin/python import string import sys, getopt import re # This function scans the .tst-file for tests with numbers in # the list testnumbers. These have to be ordered in the same way as they # are occuring in the .tst-file class command_id: def __init__(self): self.nr = 10 def increment(self): self.nr += 10 def string(self): return "%d" % self.nr def write_tests(tstfilename, test_numbers, first_commandid): print '# Tests from', tstfilename+':' tstfile = open(tstfilename, 'r') commands = '' for number in test_numbers: comment = '' print '#', tstfilename+':', number current_line = tstfile.readline() command_pattern = re.compile("^%d " % number) # Look for the line containing the command with matching id, # while keeping recent commands and comments while (not command_pattern.match(current_line)): if re.match(r"^#[^\?]", current_line): comment += current_line elif (re.match(r"^$", current_line) or re.match(r"^ +$", current_line)): comment = '' elif re.search("loadsgf", current_line): commands = current_line elif (not re.match(r"[0-9]", current_line)): commands += current_line current_line = tstfile.readline() print comment + commands, global_command_id.string(), \ re.sub(command_pattern, '', current_line), # Now look for the result line: while (not re.match(r"^#\?", current_line)): current_line = tstfile.readline() print current_line global_command_id.increment() tstfile.close print print """ # Reset owl node counter reset_owl_node_counter # Reset reading node counter reset_reading_node_counter """ test_numbers=[] global_command_id = command_id() while 1: try: inputline = raw_input() except EOFError: write_tests(filename, test_numbers, command_id) break else: s = string.split(inputline)[0] if (re.search(r"regress\.sh", s) or re.search(r"eval\.sh", s)): if len(test_numbers) > 0: write_tests(filename, test_numbers, command_id) filename = re.search(r"[^\s]+\.tst", inputline).group() test_numbers = [] elif (re.search("PASS", inputline) or re.search("FAIL", inputline)): test_numbers.append(int(s)) print """ ########### end of tests ##################### # Report number of nodes visited by the tactical reading 100000 get_reading_node_counter #? [0]& # Report number of nodes visited by the owl code 100001 get_owl_node_counter #? [0]& """