Changes in tests/test.py [a2f2fda:21c3ea1]
- File:
-
- 1 edited
-
tests/test.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/test.py
ra2f2fda r21c3ea1 24 24 25 25 def match_test(path): 26 match = re.search("^%s\/([\w\/\-_]*).expect\/([\w\-_]+)(\. nast|\.oast)?(\.[\w\-_]+)?\.txt$" % settings.SRCDIR, path)26 match = re.search("^%s\/([\w\/\-_]*).expect\/([\w\-_]+)(\.[\w\-_]+)?\.txt$" % settings.SRCDIR, path) 27 27 if match : 28 28 test = Test() 29 29 test.name = match.group(2) 30 30 test.path = match.group(1) 31 test.arch = match.group(4)[1:] if match.group(4) else None 32 33 astv = match.group(3)[1:] if match.group(3) else None 34 if astv == 'oast': 35 test.astv = 'old' 36 elif astv == 'nast': 37 test.astv = 'new' 38 elif astv: 39 print('ERROR: "%s", expect file has astv but it is not "nast" or "oast"' % testname, file=sys.stderr) 40 sys.exit(1) 41 31 test.arch = match.group(3)[1:] if match.group(3) else None 42 32 expected.append(test) 43 33 … … 76 66 if options.regenerate_expected : 77 67 for testname in options.tests : 78 testname = os.path.normpath( os.path.join(settings.SRCDIR, testname) ) 79 68 testname = canonical_path( testname ) 80 69 # first check if this is a valid name to regenerate 81 70 if Test.valid_name(testname): 82 71 # this is a valid name, let's check if it already exists 83 72 found = [test for test in all_tests if canonical_path( test.target() ) == testname] 84 setup = itertools.product(settings.all_arch if options.arch else [None], settings.all_ast if options.ast else [None])85 73 if not found: 86 # it's a new name, create it according to the name and specified architecture/ast version 87 tests.extend( [Test.new_target(testname, arch, ast) for arch, ast in setup] ) 74 # it's a new name, create it according to the name and specified architecture 75 if options.arch: 76 # user specified one or multiple architectures, assume the tests will have architecture specific results 77 tests.extend( [Test.new_target(testname, arch) for arch in settings.all_arch] ) 78 else: 79 # user didn't specify an architecture, just create a cross platform test 80 tests.append( Test.new_target( testname, None ) ) 88 81 elif len(found) == 1 and not found[0].arch: 89 82 # we found a single test, the user better be wanting to create a cross platform test 90 83 if options.arch: 91 84 print('ERROR: "%s", test has no specified architecture but --arch was specified, ignoring it' % testname, file=sys.stderr) 92 elif options.ast:93 print('ERROR: "%s", test has no specified ast version but --ast was specified, ignoring it' % testname, file=sys.stderr)94 85 else: 95 86 tests.append( found[0] ) 96 87 else: 97 88 # this test is already cross platform, just add a test for each platform the user asked 98 tests.extend( [Test.new_target(testname, arch , ast) for arch, ast in setup] )89 tests.extend( [Test.new_target(testname, arch) for arch in settings.all_arch] ) 99 90 100 91 # print a warning if it users didn't ask for a specific architecture 101 92 if not options.arch: 102 93 print('WARNING: "%s", test has architecture specific expected files but --arch was not specified, regenerating only for current host' % testname, file=sys.stderr) 103 104 105 # print a warning if it users didn't ask for a specific ast version106 if not options.ast:107 print('WARNING: "%s", test has ast version specific expected files but --ast was not specified, regenerating only for current ast' % testname, file=sys.stderr)108 94 109 95 else : … … 126 112 # create a parser with the arguments for the tests script 127 113 parser = argparse.ArgumentParser(description='Script which runs cforall tests') 128 parser.add_argument('--ast', help='Test for specific ast', type=comma_separated(str), default=None)129 parser.add_argument('--arch', help='Test for specific architecture', type=comma_separated(str), default=None)130 114 parser.add_argument('--debug', help='Run all tests in debug or release', type=comma_separated(yes_no), default='yes') 131 115 parser.add_argument('--install', help='Run all tests based on installed binaries or tree binaries', type=comma_separated(yes_no), default='no') 116 parser.add_argument('--arch', help='Test for specific architecture', type=comma_separated(str), default=None) 132 117 parser.add_argument('--continue', help='When multiple specifications are passed (debug/install/arch), sets whether or not to continue if the last specification failed', type=yes_no, default='yes', dest='continue_') 133 118 parser.add_argument('--timeout', help='Maximum duration in seconds after a single test is considered to have timed out', type=int, default=120) … … 266 251 except KeyboardInterrupt: 267 252 return False, "" 268 #except Exception as ex:269 #print("Unexpected error in worker thread running {}: {}".format(t.target(), ex), file=sys.stderr)270 #sys.stderr.flush()271 #return False, ""253 except Exception as ex: 254 print("Unexpected error in worker thread running {}: {}".format(t.target(), ex), file=sys.stderr) 255 sys.stderr.flush() 256 return False, "" 272 257 273 258 … … 377 362 # for each build configurations, run the test 378 363 with Timed() as total_dur: 379 for ast, arch, debug, install in itertools.product(settings.all_ast, settings.all_arch, settings.all_debug, settings.all_install): 380 settings.ast = ast 364 for arch, debug, install in itertools.product(settings.all_arch, settings.all_debug, settings.all_install): 381 365 settings.arch = arch 382 366 settings.debug = debug … … 385 369 # filter out the tests for a different architecture 386 370 # tests are the same across debug/install 387 local_tests = settings.ast.filter( tests ) 388 local_tests = settings.arch.filter( local_tests ) 371 local_tests = settings.arch.filter( tests ) 389 372 options.jobs, forceJobs = job_count( options, local_tests ) 390 373 settings.update_make_cmd(forceJobs, options.jobs) … … 394 377 395 378 # print configuration 396 print('%s %i tests on %i cores (%s:%s - %s)' % (379 print('%s %i tests on %i cores (%s:%s)' % ( 397 380 'Regenerating' if settings.generating else 'Running', 398 381 len(local_tests), 399 382 options.jobs, 400 settings.ast.string,401 383 settings.arch.string, 402 384 settings.debug.string 403 385 )) 404 if not local_tests :405 print('WARNING: No tests for this configuration')406 continue407 386 408 387 # otherwise run all tests and make sure to return the correct error code
Note:
See TracChangeset
for help on using the changeset viewer.