2018-10-15 12:08:19 -04:00
|
|
|
#!/usr/bin/env python
|
2020-01-02 15:13:47 -05:00
|
|
|
# Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2018-10-15 12:08:19 -04:00
|
|
|
# Check deno dir is created properly
|
|
|
|
# Usage: deno_dir_test.py [path to deno dir]
|
|
|
|
import os
|
|
|
|
|
2019-06-03 12:35:55 -04:00
|
|
|
from test_util import DenoTestCase, run_tests
|
2019-06-08 07:46:57 -04:00
|
|
|
from util import mkdtemp, rmtree, run_output
|
2018-10-15 16:46:42 -04:00
|
|
|
|
2018-10-15 12:08:19 -04:00
|
|
|
|
2019-05-30 16:40:40 -04:00
|
|
|
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"]
|
2018-10-15 12:08:19 -04:00
|
|
|
|
2019-05-30 16:40:40 -04:00
|
|
|
def tearDown(self):
|
|
|
|
if self.old_deno_dir is not None:
|
|
|
|
os.environ["DENO_DIR"] = self.old_deno_dir
|
2018-10-15 12:08:19 -04:00
|
|
|
|
2019-05-30 16:40:40 -04:00
|
|
|
def test_deno_dir(self):
|
|
|
|
deno_dir = mkdtemp()
|
|
|
|
if os.path.isdir(deno_dir):
|
|
|
|
rmtree(deno_dir)
|
2018-10-15 12:08:19 -04:00
|
|
|
|
2019-05-30 16:40:40 -04:00
|
|
|
# Run deno with no env flag
|
|
|
|
self.run_deno()
|
|
|
|
assert not os.path.isdir(deno_dir)
|
2018-11-30 03:27:41 -05:00
|
|
|
|
2019-07-17 18:15:30 -04:00
|
|
|
# TODO(bartlomieju): reenable or rewrite these tests
|
|
|
|
# now all cache directories are lazily created
|
2019-05-30 16:40:40 -04:00
|
|
|
# Run deno with DENO_DIR env flag
|
2019-07-17 18:15:30 -04:00
|
|
|
# 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)
|
2018-11-30 03:27:41 -05:00
|
|
|
|
2019-05-30 16:40:40 -04:00
|
|
|
def run_deno(self, deno_dir=None):
|
2019-07-17 18:15:30 -04:00
|
|
|
cmd = [
|
|
|
|
self.deno_exe, "run",
|
2020-02-02 16:55:22 -05:00
|
|
|
"http://localhost:4545/cli/tests/subdir/print_hello.ts"
|
2019-07-17 18:15:30 -04:00
|
|
|
]
|
2019-05-30 16:40:40 -04:00
|
|
|
deno_dir_env = {"DENO_DIR": deno_dir} if deno_dir is not None else None
|
2019-06-08 07:46:57 -04:00
|
|
|
res = run_output(cmd, quiet=True, env=deno_dir_env)
|
2019-07-17 18:15:30 -04:00
|
|
|
print res.code, res.out, res.err
|
2019-06-08 07:46:57 -04:00
|
|
|
self.assertEqual(res.code, 0)
|
2018-10-15 12:08:19 -04:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2019-06-03 12:35:55 -04:00
|
|
|
run_tests()
|