summaryrefslogtreecommitdiff
path: root/tools/prefetch_test.py
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2019-01-15 09:19:58 -0800
committerRyan Dahl <ry@tinyclouds.org>2019-01-15 12:19:58 -0500
commitc870cf40823a4900278f8ddf03489338c169878b (patch)
tree80c171f7bb36c988f459a4d0ee248a40d3feb34b /tools/prefetch_test.py
parentac6ac5037ff53f4e7b9693aeed24f1e3ef1339ad (diff)
Add --prefetch flag for deps prefetch without running (#1475)
Diffstat (limited to 'tools/prefetch_test.py')
-rwxr-xr-xtools/prefetch_test.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/prefetch_test.py b/tools/prefetch_test.py
new file mode 100755
index 000000000..d6de9d398
--- /dev/null
+++ b/tools/prefetch_test.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+# Copyright 2018 the Deno authors. All rights reserved. MIT license.
+import os
+import sys
+from util import tests_path, run_output, build_path, executable_suffix, green_ok
+import tempfile
+import shutil
+
+
+def prefetch_test(deno_exe):
+ sys.stdout.write("prefetch_test...")
+ sys.stdout.flush()
+
+ # On Windows, set the base directory that mkdtemp() uses explicitly. If not,
+ # it'll use the short (8.3) path to the temp dir, which triggers the error
+ # 'TS5009: Cannot find the common subdirectory path for the input files.'
+ temp_dir = os.environ["TEMP"] if os.name == 'nt' else None
+ deno_dir = tempfile.mkdtemp(dir=temp_dir)
+ try:
+ t = os.path.join(tests_path, "006_url_imports.ts")
+ output = run_output([deno_exe, "--prefetch", t],
+ merge_env={"DENO_DIR": deno_dir})
+ assert output == ""
+ # Check that we actually did the prefetch.
+ os.path.exists(
+ os.path.join(deno_dir,
+ "deps/http/localhost_PORT4545/tests/subdir/mod2.ts"))
+ finally:
+ shutil.rmtree(deno_dir)
+
+ print green_ok()
+
+
+if __name__ == "__main__":
+ prefetch_test(sys.argv[1])