def main(argv): if len(argv) == 2: build_dir = sys.argv[1] elif len(argv) == 1: build_dir = build_path() else: print "Usage: tools/benchmark.py [build_dir]" sys.exit(1) http_server.spawn() deno_path = os.path.join(build_dir, "deno") benchmark_file = os.path.join(build_dir, "benchmark.json") os.chdir(root_path) import_data_from_gh_pages() # TODO: Use hyperfine in //third_party run(["hyperfine", "--export-json", benchmark_file, "--warmup", "3"] + [ deno_path + " " + " ".join(args) for [_, args] in exec_time_benchmarks ]) all_data = read_json(data_file) benchmark_data = read_json(benchmark_file) sha1 = run_output(["git", "rev-parse", "HEAD"]).strip() new_data = { "created_at": time.strftime("%Y-%m-%dT%H:%M:%SZ"), "sha1": sha1, "binary_size": {}, "thread_count": {}, "syscall_count": {}, "benchmark": {} } for [[name, _], data] in zip(exec_time_benchmarks, benchmark_data["results"]): new_data["benchmark"][name] = { "mean": data["mean"], "stddev": data["stddev"], "user": data["user"], "system": data["system"], "min": data["min"], "max": data["max"] } new_data["binary_size"] = get_binary_sizes(build_dir) # Cannot run throughput benchmark on windows because they don't have nc or # pipe. if os.name != 'nt': new_data["throughput"] = run_throughput(deno_path) new_data["req_per_sec"] = http_benchmark(deno_path) if "linux" in sys.platform: # Thread count test, only on linux new_data["thread_count"] = run_thread_count_benchmark(deno_path) new_data["syscall_count"] = run_syscall_count_benchmark(deno_path) all_data.append(new_data) write_json(data_file, all_data)
def main(argv): if len(argv) == 2: build_dir = sys.argv[1] elif len(argv) == 1: build_dir = build_path() else: print "Usage: tools/test.py [build_dir]" sys.exit(1) deno_dir = os.path.join(build_dir, ".deno_test") if os.path.isdir(deno_dir): rmtree(deno_dir) os.environ["DENO_DIR"] = deno_dir enable_ansi_colors() http_server.spawn() deno_exe = os.path.join(build_dir, "deno" + executable_suffix) check_exists(deno_exe) # Internal tools testing setup_test() util_test() benchmark_test(build_dir, deno_exe) test_cc = os.path.join(build_dir, "test_cc" + executable_suffix) check_exists(test_cc) run([test_cc]) test_rs = os.path.join(build_dir, "test_rs" + executable_suffix) check_exists(test_rs) run([test_rs]) unit_tests(deno_exe) prefetch_test(deno_exe) fmt_test(deno_exe) integration_tests(deno_exe) # TODO We currently skip testing the prompt and IsTTY in Windows completely. # Windows does not support the pty module used for testing the permission # prompt. if os.name != 'nt': from permission_prompt_test import permission_prompt_test from is_tty_test import is_tty_test permission_prompt_test(deno_exe) is_tty_test(deno_exe) repl_tests(deno_exe) rmtree(deno_dir) deno_dir_test(deno_exe, deno_dir)
def main(argv): if len(argv) == 2: build_dir = sys.argv[1] elif len(argv) == 1: build_dir = build_path() else: print "Usage: tools/benchmark.py [build_dir]" sys.exit(1) sha1 = run_output(["git", "rev-parse", "HEAD"], exit_on_fail=True).out.strip() http_server.spawn() deno_exe = os.path.join(build_dir, "deno") os.chdir(root_path) import_data_from_gh_pages() new_data = { "created_at": time.strftime("%Y-%m-%dT%H:%M:%SZ"), "sha1": sha1, } # TODO(ry) The "benchmark" benchmark should actually be called "exec_time". # When this is changed, the historical data in gh-pages branch needs to be # changed too. new_data["benchmark"] = run_exec_time(deno_exe, build_dir) new_data["binary_size"] = get_binary_sizes(build_dir) new_data["bundle_size"] = bundle_benchmark(deno_exe) # Cannot run throughput benchmark on windows because they don't have nc or # pipe. if os.name != 'nt': new_data["throughput"] = run_throughput(deno_exe) run_http(build_dir, new_data) if "linux" in sys.platform: run_strace_benchmarks(deno_exe, new_data) new_data["max_memory"] = run_max_mem_benchmark(deno_exe) print "===== <BENCHMARK RESULTS>" print json.dumps(new_data, indent=2) print "===== </BENCHMARK RESULTS>" all_data = read_json(all_data_file) all_data.append(new_data) write_json(all_data_file, all_data) write_json(recent_data_file, all_data[-20:])
def main(): args = parse_test_args() deno_dir = os.path.join(args.build_dir, ".deno_test") if os.path.isdir(deno_dir): rmtree(deno_dir) os.environ["DENO_DIR"] = deno_dir enable_ansi_colors() test_cases = [ TestSetup, TestUtil, TestTarget, JsUnitTests, TestFetch, TestRepl, TestDenoDir, TestBenchmark, TestIsTty, ] test_cases += permission_prompt_tests() test_cases += complex_permissions_tests() # It is very slow, so do TestFmt at the end. test_cases += [TestFmt] with http_server.spawn(): run_tests(test_cases)
def main(): parser = argparse.ArgumentParser() parser.add_argument("--filter", help="Run specific tests") parser.add_argument("--release", help="Use release build of Deno", action="store_true") parser.add_argument("--executable", help="Use external executable of Deno") args = parser.parse_args() target = "release" if args.release else "debug" build_dir = os.environ.get("DENO_BUILD_PATH", os.path.join(root_path, "target", target)) deno_dir = os.path.join(build_dir, ".deno_test") if os.path.isdir(deno_dir): rmtree(deno_dir) os.environ["DENO_DIR"] = deno_dir test_names = [ test_name for test_name in unittest.TestLoader().getTestCaseNames( TestIntegrations) if not args.filter or args.filter in test_name ] suite = unittest.TestLoader().loadTestsFromNames(test_names, module=TestIntegrations) with spawn(): result = ColorTextTestRunner(verbosity=2).run(suite) if not result.wasSuccessful(): sys.exit(1)
def main(argv): if len(argv) == 2: build_dir = sys.argv[1] elif len(argv) == 1: build_dir = build_path() else: print "Usage: tools/test.py [build_dir]" sys.exit(1) deno_dir = os.path.join(build_dir, ".deno_test") if os.path.isdir(deno_dir): rmtree(deno_dir) os.environ["DENO_DIR"] = deno_dir enable_ansi_colors() http_server.spawn() deno_exe = os.path.join(build_dir, "deno" + executable_suffix) check_exists(deno_exe) deno_ns_exe = os.path.join(build_dir, "deno_ns" + executable_suffix) check_exists(deno_ns_exe) # Internal tools testing setup_test() util_test() benchmark_test(build_dir, deno_exe) test_cc = os.path.join(build_dir, "test_cc" + executable_suffix) check_exists(test_cc) run([test_cc]) test_rs = os.path.join(build_dir, "test_rs" + executable_suffix) check_exists(test_rs) run([test_rs]) unit_tests(deno_exe) check_output_test(deno_exe) check_output_test(deno_ns_exe) rmtree(deno_dir) deno_dir_test(deno_exe, deno_dir)
def main(argv): args = test_args(argv) deno_dir = os.path.join(args.build_dir, ".deno_test") if os.path.isdir(deno_dir): rmtree(deno_dir) os.environ["DENO_DIR"] = deno_dir enable_ansi_colors() with spawn(): test_cases = [ TestSetup, TestUtil, TestTarget, JsUnitTests, FetchTest, FmtTest, TestIntegrations, TestRepl, TestDenoDir, TestBenchmark, ] # These tests are skipped, but to make the test output less noisy # we'll avoid triggering them. if os.name != 'nt': test_cases.append(TestIsTty) test_cases += permission_prompt_tests() test_cases += complex_permissions_tests() suite = unittest.TestSuite([ unittest.TestLoader().loadTestsFromTestCase(tc) for tc in test_cases ]) result = ColorTextTestRunner( verbosity=args.verbosity + 1, failfast=args.failfast).run(suite) if not result.wasSuccessful(): sys.exit(1)
def main(): print "Permissions prompt tests" deno_exe = os.path.join(build_path(), "deno" + executable_suffix) http_server.spawn() complex_permissions_test(deno_exe)
#!/usr/bin/env python # Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import sys import subprocess from http_server import spawn from util import DenoTestCase, test_main class JsUnitTests(DenoTestCase): def test_unit_test_runner(self): cmd = [ self.deno_exe, "run", "--reload", "--allow-run", "js/unit_test_runner.ts" ] process = subprocess.Popen( cmd, bufsize=1, universal_newlines=True, stderr=subprocess.STDOUT) process.wait() errcode = process.returncode if errcode != 0: raise AssertionError( "js/unit_test_runner.ts exited with exit code %s" % errcode) if __name__ == '__main__': with spawn(): test_main()
def main(argv): if len(argv) == 2: build_dir = sys.argv[1] elif len(argv) == 1: build_dir = build_path() else: print "Usage: tools/test.py [build_dir]" sys.exit(1) deno_dir = os.path.join(build_dir, ".deno_test") if os.path.isdir(deno_dir): rmtree(deno_dir) os.environ["DENO_DIR"] = deno_dir enable_ansi_colors() http_server.spawn() deno_exe = os.path.join(build_dir, "deno" + executable_suffix) check_exists(deno_exe) # Python/build tools testing setup_test() util_test() run([ "node", "./node_modules/.bin/ts-node", "--project", "tools/ts_library_builder/tsconfig.json", "tools/ts_library_builder/test.ts" ]) test_cc = os.path.join(build_dir, "test_cc" + executable_suffix) check_exists(test_cc) run([test_cc]) test_rs = os.path.join(build_dir, "test_rs" + executable_suffix) check_exists(test_rs) run([test_rs]) deno_core_test = os.path.join(build_dir, "deno_core_test" + executable_suffix) check_exists(deno_core_test) run([deno_core_test]) deno_core_http_bench_test = os.path.join( build_dir, "deno_core_http_bench_test" + executable_suffix) check_exists(deno_core_http_bench_test) run([deno_core_http_bench_test]) unit_tests(deno_exe) fetch_test(deno_exe) fmt_test(deno_exe) integration_tests(deno_exe) # TODO We currently skip testing the prompt and IsTTY in Windows completely. # Windows does not support the pty module used for testing the permission # prompt. if os.name != 'nt': from is_tty_test import is_tty_test from permission_prompt_test import permission_prompt_test permission_prompt_test(deno_exe) is_tty_test(deno_exe) repl_tests(deno_exe) rmtree(deno_dir) deno_dir_test(deno_exe, deno_dir) test_no_color(deno_exe) benchmark_test(build_dir, deno_exe) exec_path_test(deno_exe)
code, _stdout, stderr = self._run_deno( ["--allow-net=deno.land"], [self.test_type, "localhost:4545"]) assert code == 1 assert PROMPT_PATTERN not in stderr assert PERMISSION_DENIED_PATTERN in stderr def test_allow_localhost_4555_fail(self): code, _stdout, stderr = self._run_deno( ["--allow-net=localhost:4555"], [self.test_type, "localhost:4556"]) assert code == 1 assert PROMPT_PATTERN not in stderr assert PERMISSION_DENIED_PATTERN in stderr def test_allow_localhost(self): code, _stdout, stderr = self._run_deno(["--allow-net=localhost"], [ self.test_type, "localhost:4555", "localhost:4556", "localhost:4557" ]) assert code == 0 assert PROMPT_PATTERN not in stderr assert PERMISSION_DENIED_PATTERN not in stderr def complex_permissions_tests(): return BaseComplexPermissionTest.__subclasses__() if __name__ == "__main__": with http_server.spawn(): run_tests()
def main(argv): if len(argv) == 2: build_dir = sys.argv[1] elif len(argv) == 1: build_dir = build_path() else: print "Usage: tools/test.py [build_dir]" sys.exit(1) deno_dir = os.path.join(build_dir, ".deno_test") if os.path.isdir(deno_dir): rmtree(deno_dir) os.environ["DENO_DIR"] = deno_dir enable_ansi_colors() http_server.spawn() deno_exe = os.path.join(build_dir, "deno" + executable_suffix) check_exists(deno_exe) exec_path_test(deno_exe) # Internal tools testing run([ "node", "./node_modules/.bin/ts-node", "--project", "tools/ts_library_builder/tsconfig.json", "tools/ts_library_builder/test.ts" ]) setup_test() util_test() benchmark_test(build_dir, deno_exe) test_cc = os.path.join(build_dir, "test_cc" + executable_suffix) check_exists(test_cc) run([test_cc]) test_rs = os.path.join(build_dir, "test_rs" + executable_suffix) check_exists(test_rs) run([test_rs]) deno_core_test = os.path.join(build_dir, "deno_core_test" + executable_suffix) check_exists(deno_core_test) run([deno_core_test]) unit_tests(deno_exe) prefetch_test(deno_exe) fmt_test(deno_exe) integration_tests(deno_exe) # TODO We currently skip testing the prompt and IsTTY in Windows completely. # Windows does not support the pty module used for testing the permission # prompt. if os.name != 'nt': from permission_prompt_test import permission_prompt_test from is_tty_test import is_tty_test permission_prompt_test(deno_exe) is_tty_test(deno_exe) repl_tests(deno_exe) rmtree(deno_dir) deno_dir_test(deno_exe, deno_dir) test_no_color(deno_exe)
def main(argv): if len(argv) == 2: build_dir = sys.argv[1] elif len(argv) == 1: build_dir = build_path() else: print "Usage: tools/benchmark.py [build_dir]" sys.exit(1) http_server.spawn() deno_path = os.path.join(build_dir, "deno") benchmark_file = os.path.join(build_dir, "benchmark.json") os.chdir(root_path) import_data_from_gh_pages() hyperfine = prebuilt.load_hyperfine() run([ hyperfine, "--ignore-failure", "--export-json", benchmark_file, "--warmup", "3" ] + [ deno_path + " " + " ".join(args) for [_, args] in exec_time_benchmarks ]) all_data = read_json(all_data_file) benchmark_data = read_json(benchmark_file) sha1 = run_output(["git", "rev-parse", "HEAD"]).strip() new_data = { "created_at": time.strftime("%Y-%m-%dT%H:%M:%SZ"), "sha1": sha1, "binary_size": {}, "thread_count": {}, "syscall_count": {}, "benchmark": {} } for [[name, _], data] in zip(exec_time_benchmarks, benchmark_data["results"]): new_data["benchmark"][name] = { "mean": data["mean"], "stddev": data["stddev"], "user": data["user"], "system": data["system"], "min": data["min"], "max": data["max"] } new_data["binary_size"] = get_binary_sizes(build_dir) # Cannot run throughput benchmark on windows because they don't have nc or # pipe. if os.name != 'nt': hyper_hello_path = os.path.join(build_dir, "hyper_hello") core_http_bench_exe = os.path.join(build_dir, "deno_core_http_bench") new_data["throughput"] = run_throughput(deno_path) new_data["req_per_sec"] = http_benchmark(deno_path, hyper_hello_path, core_http_bench_exe) if "linux" in sys.platform: # Thread count test, only on linux new_data["thread_count"] = run_thread_count_benchmark(deno_path) new_data["syscall_count"] = run_syscall_count_benchmark(deno_path) all_data.append(new_data) write_json(all_data_file, all_data) write_json(recent_data_file, all_data[-20:])