def _main(): setup_logging() logging.debug("args: %s", " ".join(sys.argv)) # earlier plumbum versions are missing features such as TEE if pb.__version__ < c.MIN_PLUMBUM_VERSION: err = "locally installed version {} of plumbum is too old.\n" \ .format(pb.__version__) err += "please upgrade plumbum to version {} or later." \ .format(c.MIN_PLUMBUM_VERSION) die(err) args = _parse_args() if args.clean_all: logging.info("cleaning all dependencies and previous built files") shutil.rmtree(c.CLANG_XCHECK_PLUGIN_BLD, ignore_errors=True) # prerequisites if not have_rust_toolchain(c.CUSTOM_RUST_NAME): die("missing rust toolchain: " + c.CUSTOM_RUST_NAME, errno.ENOENT) # clang 3.6.0 is known to work; 3.4.0 known to not work. ensure_clang_version([3, 6, 0]) ensure_rustc_version(c.CUSTOM_RUST_RUSTC_VERSION) ensure_dir(c.CLANG_XCHECK_PLUGIN_BLD) ensure_dir(c.DEPS_DIR) git_ignore_dir(c.DEPS_DIR) build_clang_plugin(args)
def _main(): setup_logging() logging.debug("args: %s", " ".join(sys.argv)) # FIXME: allow env/cli override of LLVM_SRC, LLVM_VER, and LLVM_BLD # FIXME: check that cmake and ninja are installed # FIXME: option to build LLVM/Clang from master? # earlier plumbum versions are missing features such as TEE if pb.__version__ < c.MIN_PLUMBUM_VERSION: err = "locally installed version {} of plumbum is too old.\n" \ .format(pb.__version__) err += "please upgrade plumbum to version {} or later." \ .format(c.MIN_PLUMBUM_VERSION) die(err) args = _parse_args() if args.clean_all: logging.info("cleaning all dependencies and previous built files") shutil.rmtree(c.LLVM_SRC, ignore_errors=True) shutil.rmtree(c.LLVM_BLD, ignore_errors=True) shutil.rmtree(c.DEPS_DIR, ignore_errors=True) # prerequisites if not have_rust_toolchain(c.CUSTOM_RUST_NAME): die("missing rust toolchain: " + c.CUSTOM_RUST_NAME, errno.ENOENT) # clang 3.6.0 is known to work; 3.4.0 known to not work. ensure_clang_version([3, 6, 0]) ensure_rustc_version(c.CUSTOM_RUST_RUSTC_VERSION) ensure_dir(c.LLVM_BLD) ensure_dir(c.DEPS_DIR) git_ignore_dir(c.DEPS_DIR) if on_linux(): build_a_bear() if not os.path.isfile(c.BEAR_BIN): die("bear not found", errno.ENOENT) download_llvm_sources() integrate_ast_exporter() cc_db = install_tinycbor() configure_and_build_llvm(args) # NOTE: we're not doing this anymore since it is # faster and takes less space to simply pull the # prebuilt nightly binaries with rustup # download_and_build_custom_rustc(args) build_ast_importer(args.debug) if not on_mac() and args.sanity_test: test_ast_exporter(cc_db)
def main(): # TODO: implement rustfmt and diff actions from `run-test.sh` setup_logging() ensure_rustc_version(c.CUSTOM_RUST_RUSTC_VERSION) # TODO: update rustfmt version check once idiomize bitrot has been fixed # ensure_rustfmt_version() test_dir = os.path.join(c.RREF_DIR, "tests") assert os.path.isdir(test_dir), "test dir missing: " + test_dir idiomize_binary = os.path.join(c.RREF_DIR, "target/debug/idiomize") if not os.path.isfile(idiomize_binary): die("build idiomize binary first. expected: " + idiomize_binary) testcases = get_testcases(test_dir) run_tests(sorted(testcases))
def main() -> None: desc = 'run regression / unit / feature tests.' parser = argparse.ArgumentParser(description=desc) parser.add_argument('directory', type=readable_directory) parser.add_argument('--only-files', dest='regex_files', type=regex, default='.*', help="Regular expression to filter which tests to run") parser.add_argument('--only-directories', dest='regex_directories', type=regex, default='.*', help="Regular expression to filter which tests to run") parser.add_argument( '--log', dest='logLevel', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], default='CRITICAL', help="Set the logging level") parser.add_argument('--keep', dest='keep', action='append', choices=intermediate_files + ['all'], default=[], help="Which intermediate files to not clear") c.add_args(parser) args = parser.parse_args() c.update_args(args) test_directories = get_testdirectories(args.directory, args.regex_files, args.keep) setup_logging(args.logLevel) logging.debug("args: %s", " ".join(sys.argv)) # check that the binaries have been built first bins = [c.AST_EXPO, c.AST_IMPO] for b in bins: if not os.path.isfile(b): msg = b + " not found; run build_translator.py first?" die(msg, errno.ENOENT) ensure_dir(c.DEPS_DIR) ensure_rustc_version(c.CUSTOM_RUST_RUSTC_VERSION) if not test_directories: die("nothing to test") # Accumulate test case stats test_results = { "unexpected failures": 0, "unexpected successes": 0, "expected failures": 0, "successes": 0 } for test_directory in test_directories: if args.regex_directories.fullmatch(test_directory.name): # Testdirectories are run one after another. Only test directories # that match the '--only-directories' or tests that match the # '--only-files' arguments are run. We make a best effort to clean # up files we left behind. try: statuses = test_directory.run() except (KeyboardInterrupt, SystemExit): test_directory.cleanup() raise finally: test_directory.cleanup() for status in statuses: test_results[status.value] += 1 # Print out test case stats sys.stdout.write("\nTest summary:\n") for variant, count in test_results.items(): sys.stdout.write(" {}: {}\n".format(variant, count)) # If anything unexpected happened, exit with error code 1 unexpected = \ test_results["unexpected failures"] + \ test_results["unexpected successes"] if 0 < unexpected: quit(1)