mirror of
https://github.com/denoland/deno.git
synced 2025-01-08 15:19:40 -05:00
43c6c1a9f5
* 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
45 lines
1.3 KiB
Python
Executable file
45 lines
1.3 KiB
Python
Executable file
#!/usr/bin/env python
|
|
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
|
# Check deno dir is created properly
|
|
# Usage: deno_dir_test.py [path to deno dir]
|
|
import os
|
|
|
|
from test_util import DenoTestCase, run_tests
|
|
from util import mkdtemp, rmtree, run
|
|
|
|
|
|
class TestDenoDir(DenoTestCase):
|
|
def setUp(self):
|
|
self.old_deno_dir = None
|
|
if "DENO_DIR" in os.environ:
|
|
self.old_deno_dir = os.environ["DENO_DIR"]
|
|
del os.environ["DENO_DIR"]
|
|
|
|
def tearDown(self):
|
|
if self.old_deno_dir is not None:
|
|
os.environ["DENO_DIR"] = self.old_deno_dir
|
|
|
|
def test_deno_dir(self):
|
|
deno_dir = mkdtemp()
|
|
if os.path.isdir(deno_dir):
|
|
rmtree(deno_dir)
|
|
|
|
# Run deno with no env flag
|
|
self.run_deno()
|
|
assert not os.path.isdir(deno_dir)
|
|
|
|
# Run deno with DENO_DIR env flag
|
|
self.run_deno(deno_dir)
|
|
assert os.path.isdir(deno_dir)
|
|
assert os.path.isdir(os.path.join(deno_dir, "deps"))
|
|
assert os.path.isdir(os.path.join(deno_dir, "gen"))
|
|
rmtree(deno_dir)
|
|
|
|
def run_deno(self, deno_dir=None):
|
|
cmd = [self.deno_exe, "run", "tests/002_hello.ts"]
|
|
deno_dir_env = {"DENO_DIR": deno_dir} if deno_dir is not None else None
|
|
run(cmd, quiet=True, env=deno_dir_env)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
run_tests()
|