1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-02 17:01:14 -05:00
denoland-deno/tools/deno_dir_test.py
Bartek Iwańczuk 8214b686ce Refactor DenoDir (#2636)
* rename `ModuleMetaData` to `SourceFile` and remove TS specific
  functionality

* add `TsCompiler` struct encapsulating processing of TypeScript files

* move `SourceMapGetter` trait implementation to `//cli/compiler.rs`

* add low-level `DiskCache` API for general purpose caches and use it in
  `DenoDir` and `TsCompiler` for filesystem access

* don't use hash-like filenames for compiled modules, instead use
  metadata file for storing compilation hash

* add `SourceFileCache` for in-process caching of loaded files for fast
  subsequent access

* define `SourceFileFetcher` trait encapsulating loading of local and
  remote files and implement it for `DenoDir`

* define `use_cache` and `no_fetch` flags on `DenoDir` instead of using
  in fetch methods
2019-07-17 18:15:30 -04:00

52 lines
1.6 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_output
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)
# TODO(bartlomieju): reenable or rewrite these tests
# now all cache directories are lazily created
# 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",
"http://localhost:4545/tests/subdir/print_hello.ts"
]
deno_dir_env = {"DENO_DIR": deno_dir} if deno_dir is not None else None
res = run_output(cmd, quiet=True, env=deno_dir_env)
print res.code, res.out, res.err
self.assertEqual(res.code, 0)
if __name__ == '__main__':
run_tests()