summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmos Lim <amoseui@gmail.com>2018-10-16 01:08:19 +0900
committerRyan Dahl <ry@tinyclouds.org>2018-10-15 12:08:19 -0400
commit15590a0cde8901f15d200d433761d11cc5468270 (patch)
tree79514c9465ab81504981010644681fe56ac09e98
parenta327759971fe5cb095e1d2f6125269e60ac00123 (diff)
Specify deno_dir location with env var DENO_DIR (#970)
(Use C:\deno instead of c:\deno in appveyor config because it's cloned to c:\ by clone_folder variable in .appveyor.yml. On the other hand, build directory is pointed to C:\ by $(APPVEYOR_BUILD_FOLDER) so that test targets are placed on separated partitions.)
-rw-r--r--.appveyor.yml6
-rw-r--r--README.md2
-rw-r--r--src/flags.rs5
-rw-r--r--src/isolate.rs13
-rwxr-xr-xtools/deno_dir_test.py48
-rwxr-xr-xtools/test.py12
6 files changed, 79 insertions, 7 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index adbcfac55..f946aa5c0 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -2,7 +2,7 @@ version: '{build}.{branch}'
skip_branch_with_pr: true
-clone_folder: c:\deno
+clone_folder: C:\deno
clone_depth: 1
environment:
@@ -283,8 +283,8 @@ install:
# Add binary dir for `pip --user` packages.
$p += "$env:APPDATA\Python\Scripts"
# Add python27-x64.
- $p += "c:\Python27-x64"
- $p += "c:\Python27-x64\Scripts"
+ $p += "C:\Python27-x64"
+ $p += "C:\Python27-x64\Scripts"
$env:PATH = $p -join ";"
# Pip on Appveyor is too old. Install a recent version in our user dir.
diff --git a/README.md b/README.md
index a953c7601..1d57d9ce1 100644
--- a/README.md
+++ b/README.md
@@ -152,7 +152,7 @@ Other useful commands:
./third_party/depot_tools/gn desc out/debug/ :deno
./third_party/depot_tools/gn help
-Env vars: `DENO_BUILD_MODE`, `DENO_BUILD_PATH`, `DENO_BUILD_ARGS`.
+Env vars: `DENO_BUILD_MODE`, `DENO_BUILD_PATH`, `DENO_BUILD_ARGS`, `DENO_DIR`.
## Contributing
diff --git a/src/flags.rs b/src/flags.rs
index e4e3c28df..d766fee0c 100644
--- a/src/flags.rs
+++ b/src/flags.rs
@@ -60,7 +60,10 @@ pub fn print_usage() {
-h or --help Print this message.
--v8-options Print V8 command line options.
--deps Print module dependencies.
---types Print runtime TypeScript declarations."
+--types Print runtime TypeScript declarations.
+
+Environment variables:
+DENO_DIR Set deno's base directory."
);
}
diff --git a/src/isolate.rs b/src/isolate.rs
index 5a09b8855..7860b216b 100644
--- a/src/isolate.rs
+++ b/src/isolate.rs
@@ -12,8 +12,10 @@ use libdeno;
use futures::Future;
use libc::c_void;
use std;
+use std::env;
use std::ffi::CStr;
use std::ffi::CString;
+use std::path::Path;
use std::sync::mpsc;
use std::sync::Arc;
use std::sync::Mutex;
@@ -108,6 +110,15 @@ impl Isolate {
// This channel handles sending async messages back to the runtime.
let (tx, rx) = mpsc::channel::<(i32, Buf)>();
+ let custom_root_path;
+ let custom_root = match env::var("DENO_DIR") {
+ Ok(path) => {
+ custom_root_path = path;
+ Some(Path::new(custom_root_path.as_str()))
+ }
+ Err(_e) => None,
+ };
+
Isolate {
libdeno_isolate,
dispatch,
@@ -115,7 +126,7 @@ impl Isolate {
ntasks: 0,
timeout_due: None,
state: Arc::new(IsolateState {
- dir: deno_dir::DenoDir::new(flags.reload, None).unwrap(),
+ dir: deno_dir::DenoDir::new(flags.reload, custom_root).unwrap(),
argv: argv_rest,
flags,
tx: Mutex::new(Some(tx)),
diff --git a/tools/deno_dir_test.py b/tools/deno_dir_test.py
new file mode 100755
index 000000000..571914fc6
--- /dev/null
+++ b/tools/deno_dir_test.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# 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_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):
+ 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__':
+ sys.exit(main(sys.argv))
diff --git a/tools/test.py b/tools/test.py
index 45c9f5e2b..d2a7944e6 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -4,8 +4,9 @@
import os
import sys
from check_output_test import check_output_test
+from deno_dir_test import deno_dir_test
from setup_test import setup_test
-from util import build_path, enable_ansi_colors, executable_suffix, run
+from util import build_path, enable_ansi_colors, executable_suffix, run, rmtree
from unit_tests import unit_tests
from util_test import util_test
from benchmark_test import benchmark_test
@@ -29,6 +30,11 @@ def main(argv):
print "Usage: tools/test.py [build_dir]"
sys.exit(1)
+ deno_dir = os.path.join(build_dir, ".deno_test")
+ if os.path.isdir(deno_dir):
+ rmtree(deno_dir)
+ os.environ["DENO_DIR"] = deno_dir
+
enable_ansi_colors()
http_server.spawn()
@@ -56,6 +62,10 @@ def main(argv):
check_output_test(deno_exe)
check_output_test(deno_ns_exe)
+ rmtree(deno_dir)
+
+ deno_dir_test(deno_exe, deno_dir)
+
if __name__ == '__main__':
sys.exit(main(sys.argv))