mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 04:39:10 +00:00
Refactor test infrastructure (#2432)
* use subclass of unittest.TestCase for all test cases * allow to run single test file (eg. python tools/integration_tests.py) * test filtering (via --pattern/-p CLI flag) * use common CLI parser for all tests: usage: test.py [-h] [--failfast] [--verbose] [--executable EXECUTABLE] [--release] [--pattern PATTERN] [--build-dir BUILD_DIR] optional arguments: -h, --help show this help message and exit --failfast, -f Stop on first failure --verbose, -v Verbose output --executable EXECUTABLE Use external executable of Deno --release Test against release executable --pattern PATTERN, -p PATTERN Run tests that match provided pattern --build-dir BUILD_DIR Deno build directory * respect NO_COLOR variable
This commit is contained in:
parent
bbc8de0c7a
commit
43c6c1a9f5
17 changed files with 283 additions and 278 deletions
|
@ -7,16 +7,13 @@
|
|||
# exit code can be specified.
|
||||
#
|
||||
# Usage: integration_tests.py [path to deno executable]
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import subprocess
|
||||
import unittest
|
||||
|
||||
from http_server import spawn
|
||||
from util import (DenoTestCase, ColorTextTestRunner, root_path, tests_path,
|
||||
pattern_match, rmtree, test_main)
|
||||
import http_server
|
||||
from test_util import DenoTestCase, run_tests
|
||||
from util import root_path, tests_path, pattern_match, rmtree
|
||||
|
||||
|
||||
def strip_ansi_codes(s):
|
||||
|
@ -107,36 +104,6 @@ for fn in sorted(
|
|||
tn = t.__name__ = "test_" + fn.split(".")[0]
|
||||
setattr(TestIntegrations, tn, t)
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
with http_server.spawn():
|
||||
run_tests()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue