Skip to content

Commit

Permalink
Let deno_dir_test run deno with or without env DENO_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
amoseui committed Oct 15, 2018
1 parent d6aaee1 commit f993be1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
34 changes: 32 additions & 2 deletions tools/deno_dir_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,46 @@
# 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

def deno_dir_test(deno_dir):
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:
os.environ["DENO_DIR"] = old_deno_dir


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)

def main(argv):
deno_dir_test(argv[1])
if len(sys.argv) != 3:
print "Usage ./tools/deno_dir_test.py out/debug/deno out/debug/.deno_dir"
sys.exit(1)
deno_dir_test(argv[1], argv[2])


if __name__ == '__main__':
Expand Down
3 changes: 2 additions & 1 deletion tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ def main(argv):
check_output_test(deno_exe)
check_output_test(deno_ns_exe)

deno_dir_test(deno_dir)
rmtree(deno_dir)

deno_dir_test(deno_exe, deno_dir)


if __name__ == '__main__':
sys.exit(main(sys.argv))

0 comments on commit f993be1

Please sign in to comment.