mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
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.)
This commit is contained in:
parent
a327759971
commit
15590a0cde
6 changed files with 79 additions and 7 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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."
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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)),
|
||||
|
|
48
tools/deno_dir_test.py
Executable file
48
tools/deno_dir_test.py
Executable file
|
@ -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))
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue