variants = {} log.info(sh.cc('--version')) for variant_file in os.listdir('simulator/configs'): log.info("Building {}".format(variant_file)) variant = os.path.basename(variant_file) build_variant_dir = os.path.join(BUILD_DIR, variant) mkdir(build_variant_dir) cp('-r', PRISTINE, build_variant_dir) with sh.pushd(os.path.join(build_variant_dir, 'simulator')): tup('init') tup('generate', 'build.sh', '--config', os.path.join('configs', variant)) try: errbuf = io.StringIO() sh.sh('-x', 'build.sh', _err=errbuf) except: errbuf.seek(0) for l in errbuf.readlines(): print(l, end='') raise sh.test('-x', 'simulator') log.info("Built {}".format(variant_file)) any_fail = False
import os import pprint import sys import sh # n.b. pushd is coming to sh in v1.10 @contextmanager def pushd(path): cwd = os.getcwd() os.chdir(path) yield os.chdir(cwd) # Make sure everything is up-to-date sh.tup() def test_operations(): def get_test_paths(): tests = {} for family in os.listdir('tests/operations/'): if not os.path.isdir(os.path.join('tests/operations/', family)): continue tests[family] = {} for test in os.listdir(os.path.join('tests/operations/', family)): if test[-2:] == '.s': tests[family][test[:-2]] = {} return tests tests = get_test_paths()
rm('-r', '-f', '.tup') rm('-r', '-f', sh.glob('build-*')) variants = {} for variant_file in os.listdir('simulator/configs'): log.info("Building {}".format(variant_file)) variant = os.path.basename(variant_file) build_variant_dir = os.path.join(BUILD_DIR, variant) mkdir(build_variant_dir) cp('-r', PRISTINE, build_variant_dir) with sh.pushd(os.path.join(build_variant_dir, 'simulator')): tup('generate', 'build.sh', '--config', os.path.join('configs', variant)) sh.Command('./build.sh')() sh.test('-x', 'simulator') log.info("Built {}".format(variant_file)) any_fail = False sim = sh.Command('./simulator') for test in glob.iglob('tests/**/*.bin', recursive=True): log.info("\t\ttest: %s", test) try: sim('-f', test) log.info("\t\t\tPASSED") except sh.ErrorReturnCode as e: # XXX: This is a hack
action='store_true', help='Stop on first error') args = parser.parse_args() # n.b. pushd is coming to sh in v1.10 @contextmanager def pushd(path): cwd = os.getcwd() os.chdir(path) yield os.chdir(cwd) # Make sure everything is up-to-date sh.tup() def tests(): any_fail = False variants = {} for variant in os.listdir('.'): if not variant[:6] == 'build-': continue log.info("Running tests for variant: %s", variant) with pushd(variant): sim = sh.Command('./simulator') variants[variant] = {}