2018-10-15 12:08:19 -04:00
|
|
|
#!/usr/bin/env python
|
2018-10-19 15:25:29 -04:00
|
|
|
# Copyright 2018 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
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
from util import rmtree, run
|
|
|
|
|
2018-10-15 16:46:42 -04:00
|
|
|
|
2018-10-15 12:08:19 -04:00
|
|
|
def deno_dir_test(deno_exe, deno_dir):
|
|
|
|
assert os.path.isfile(deno_exe)
|
|
|
|
|
|
|
|
old_deno_dir = None
|
|
|
|
if "DENO_DIR" in os.environ:
|
|
|
|
old_deno_dir = os.environ["DENO_DIR"]
|
|
|
|
del os.environ["DENO_DIR"]
|
|
|
|
|
|
|
|
if os.path.isdir(deno_dir):
|
|
|
|
rmtree(deno_dir)
|
|
|
|
|
|
|
|
# Run deno with no env flag
|
|
|
|
run_deno(deno_exe)
|
|
|
|
assert not os.path.isdir(deno_dir)
|
|
|
|
|
|
|
|
# Run deno with DENO_DIR env flag
|
|
|
|
run_deno(deno_exe, 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)
|
|
|
|
|
|
|
|
if old_deno_dir is not None:
|
2018-10-15 16:46:42 -04:00
|
|
|
os.environ["DENO_DIR"] = old_deno_dir
|
2018-10-15 12:08:19 -04:00
|
|
|
|
|
|
|
|
|
|
|
def run_deno(deno_exe, deno_dir=None):
|
|
|
|
cmd = [deno_exe, "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)
|
|
|
|
|
2018-10-15 16:46:42 -04:00
|
|
|
|
2018-11-30 03:27:41 -05:00
|
|
|
USAGE = "./tools/deno_dir_test.py target/debug/deno target/debug/.deno_dir"
|
|
|
|
|
|
|
|
|
2018-10-15 12:08:19 -04:00
|
|
|
def main(argv):
|
|
|
|
if len(sys.argv) != 3:
|
2018-11-30 03:27:41 -05:00
|
|
|
print "Usage: " + USAGE
|
2018-10-15 12:08:19 -04:00
|
|
|
sys.exit(1)
|
|
|
|
deno_dir_test(argv[1], argv[2])
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main(sys.argv))
|