diff --git a/.eslintignore b/.eslintignore index a76bd68241..1b9e355376 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,2 @@ /js/deps/ -/tests/error_syntax.js +cli/tests/error_syntax.js diff --git a/.prettierignore b/.prettierignore index 695354438c..10caa2fbcf 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,2 @@ -tests/error_syntax.js -tests/badly_formatted.js +cli/tests/error_syntax.js +cli/tests/badly_formatted.js \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index b633597134..9fe95b1fa2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -266,7 +266,7 @@ dependencies = [ [[package]] name = "deno_cli" -version = "0.18.3" +version = "0.18.4" dependencies = [ "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index cf51781fa0..b9a9c1456a 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,11 +1,8 @@ # Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -[[bin]] -name = "deno" -path = "main.rs" [package] name = "deno_cli" -version = "0.18.3" +version = "0.18.4" license = "MIT" authors = ["the Deno authors"] edition = "2018" @@ -13,6 +10,14 @@ description = "Provides the deno executable" repository = "https://github.com/denoland/deno" default-run = "deno" +[lib] +name = "deno_cli" +path = "lib.rs" + +[[bin]] +name = "deno" +path = "main.rs" + [dependencies] deno = { path = "../core", version = "0.18.0" } deno_cli_snapshots = { path = "../js", version = "0.18.3" } diff --git a/cli/colors.rs b/cli/colors.rs index 7ca42e2f5c..9c2c7a4010 100644 --- a/cli/colors.rs +++ b/cli/colors.rs @@ -21,7 +21,6 @@ lazy_static! { } /// Helper function to strip ansi codes. -#[cfg(test)] pub fn strip_ansi_codes(s: &str) -> std::borrow::Cow { STRIP_ANSI_RE.replace_all(s, "") } diff --git a/cli/compilers/ts.rs b/cli/compilers/ts.rs index 8330d86e93..fc280a898c 100644 --- a/cli/compilers/ts.rs +++ b/cli/compilers/ts.rs @@ -670,7 +670,7 @@ mod tests { url: specifier.as_url().clone(), filename: PathBuf::from(p.to_str().unwrap().to_string()), media_type: msg::MediaType::TypeScript, - source_code: include_bytes!("../../tests/002_hello.ts").to_vec(), + source_code: include_bytes!("../tests/002_hello.ts").to_vec(), }; let mock_state = ThreadSafeState::mock(vec![ diff --git a/cli/lib.rs b/cli/lib.rs new file mode 100644 index 0000000000..ff8f022393 --- /dev/null +++ b/cli/lib.rs @@ -0,0 +1,437 @@ +// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +#[macro_use] +extern crate lazy_static; +#[macro_use] +extern crate log; +#[macro_use] +extern crate futures; +#[macro_use] +extern crate serde_json; +extern crate clap; +extern crate deno; +extern crate deno_cli_snapshots; +extern crate indexmap; +#[cfg(unix)] +extern crate nix; +extern crate rand; +extern crate serde; +extern crate serde_derive; +extern crate url; + +pub mod colors; +pub mod compilers; +pub mod deno_dir; +pub mod deno_error; +pub mod diagnostics; +mod disk_cache; +mod file_fetcher; +pub mod flags; +pub mod fmt_errors; +mod fs; +mod global_timer; +mod http_body; +mod http_util; +mod import_map; +pub mod msg; +pub mod ops; +pub mod permissions; +mod progress; +mod repl; +pub mod resolve_addr; +pub mod resources; +mod shell; +mod signal; +pub mod source_maps; +mod startup_data; +pub mod state; +mod tokio_read; +mod tokio_util; +mod tokio_write; +pub mod version; +pub mod worker; + +use crate::progress::Progress; +use crate::state::ThreadSafeState; +use crate::worker::Worker; +use deno::v8_set_flags; +use deno::ErrBox; +use deno::ModuleSpecifier; +use flags::DenoFlags; +use flags::DenoSubcommand; +use futures::lazy; +use futures::Future; +use log::Level; +use log::Metadata; +use log::Record; +use std::env; + +static LOGGER: Logger = Logger; + +struct Logger; + +impl log::Log for Logger { + fn enabled(&self, metadata: &Metadata) -> bool { + metadata.level() <= log::max_level() + } + + fn log(&self, record: &Record) { + if self.enabled(record.metadata()) { + let mut target = record.target().to_string(); + + if let Some(line_no) = record.line() { + target.push_str(":"); + target.push_str(&line_no.to_string()); + } + + println!("{} RS - {} - {}", record.level(), target, record.args()); + } + } + fn flush(&self) {} +} + +fn print_err_and_exit(err: ErrBox) { + eprintln!("{}", err.to_string()); + std::process::exit(1); +} + +fn js_check(r: Result<(), ErrBox>) { + if let Err(err) = r { + print_err_and_exit(err); + } +} + +fn create_worker_and_state( + flags: DenoFlags, + argv: Vec, +) -> (Worker, ThreadSafeState) { + use crate::shell::Shell; + use std::sync::Arc; + use std::sync::Mutex; + let shell = Arc::new(Mutex::new(Shell::new())); + let progress = Progress::new(); + progress.set_callback(move |_done, _completed, _total, status, msg| { + if !status.is_empty() { + let mut s = shell.lock().unwrap(); + s.status(status, msg).expect("shell problem"); + } + }); + // TODO(kevinkassimo): maybe make include_deno_namespace also configurable? + let state = ThreadSafeState::new(flags, argv, progress, true) + .map_err(print_err_and_exit) + .unwrap(); + let worker = Worker::new( + "main".to_string(), + startup_data::deno_isolate_init(), + state.clone(), + ); + + (worker, state) +} + +fn types_command() { + let content = deno_cli_snapshots::get_asset("lib.deno_runtime.d.ts").unwrap(); + println!("{}", content); +} + +fn print_cache_info(worker: Worker) { + let state = worker.state; + + println!( + "{} {:?}", + colors::bold("DENO_DIR location:".to_string()), + state.dir.root + ); + println!( + "{} {:?}", + colors::bold("Remote modules cache:".to_string()), + state.dir.deps_cache.location + ); + println!( + "{} {:?}", + colors::bold("TypeScript compiler cache:".to_string()), + state.dir.gen_cache.location + ); +} + +pub fn print_file_info( + worker: Worker, + module_specifier: &ModuleSpecifier, +) -> impl Future { + let state_ = worker.state.clone(); + let module_specifier_ = module_specifier.clone(); + + state_ + .file_fetcher + .fetch_source_file_async(&module_specifier) + .map_err(|err| println!("{}", err)) + .and_then(|out| { + println!( + "{} {}", + colors::bold("local:".to_string()), + out.filename.to_str().unwrap() + ); + + println!( + "{} {}", + colors::bold("type:".to_string()), + msg::enum_name_media_type(out.media_type) + ); + + state_ + .clone() + .fetch_compiled_module(&module_specifier_) + .map_err(|e| { + debug!("compiler error exiting!"); + eprintln!("\n{}", e.to_string()); + std::process::exit(1); + }) + .and_then(move |compiled| { + if out.media_type == msg::MediaType::TypeScript + || (out.media_type == msg::MediaType::JavaScript + && state_.ts_compiler.compile_js) + { + let compiled_source_file = state_ + .ts_compiler + .get_compiled_source_file(&out.url) + .unwrap(); + + println!( + "{} {}", + colors::bold("compiled:".to_string()), + compiled_source_file.filename.to_str().unwrap(), + ); + } + + if let Ok(source_map) = state_ + .clone() + .ts_compiler + .get_source_map_file(&module_specifier_) + { + println!( + "{} {}", + colors::bold("map:".to_string()), + source_map.filename.to_str().unwrap() + ); + } + + if let Some(deps) = + worker.state.modules.lock().unwrap().deps(&compiled.name) + { + println!("{}{}", colors::bold("deps:\n".to_string()), deps.name); + if let Some(ref depsdeps) = deps.deps { + for d in depsdeps { + println!("{}", d); + } + } + } else { + println!( + "{} cannot retrieve full dependency graph", + colors::bold("deps:".to_string()), + ); + } + Ok(worker) + }) + }) +} + +fn info_command(flags: DenoFlags, argv: Vec) { + let (mut worker, state) = create_worker_and_state(flags, argv.clone()); + + // If it was just "deno info" print location of caches and exit + if argv.len() == 1 { + return print_cache_info(worker); + } + + let main_module = state.main_module().unwrap(); + let main_future = lazy(move || { + // Setup runtime. + js_check(worker.execute("denoMain()")); + debug!("main_module {}", main_module); + + worker + .execute_mod_async(&main_module, true) + .map_err(print_err_and_exit) + .and_then(move |()| print_file_info(worker, &main_module)) + .and_then(|worker| { + worker.then(|result| { + js_check(result); + Ok(()) + }) + }) + }); + tokio_util::run(main_future); +} + +fn fetch_command(flags: DenoFlags, argv: Vec) { + let (mut worker, state) = create_worker_and_state(flags, argv.clone()); + + let main_module = state.main_module().unwrap(); + let main_future = lazy(move || { + // Setup runtime. + js_check(worker.execute("denoMain()")); + debug!("main_module {}", main_module); + + worker.execute_mod_async(&main_module, true).then(|result| { + js_check(result); + Ok(()) + }) + }); + tokio_util::run(main_future); +} + +fn eval_command(flags: DenoFlags, argv: Vec) { + let (mut worker, state) = create_worker_and_state(flags, argv); + // Wrap provided script in async function so asynchronous methods + // work. This is required until top-level await is not supported. + let js_source = format!( + "async function _topLevelWrapper(){{ + {} + }} + _topLevelWrapper(); + ", + &state.argv[1] + ); + + let main_future = lazy(move || { + js_check(worker.execute("denoMain()")); + // ATM imports in `deno eval` are not allowed + // TODO Support ES modules once Worker supports evaluating anonymous modules. + js_check(worker.execute(&js_source)); + worker.then(|result| { + js_check(result); + Ok(()) + }) + }); + tokio_util::run(main_future); +} + +fn xeval_command(flags: DenoFlags, argv: Vec) { + let xeval_replvar = flags.xeval_replvar.clone().unwrap(); + let (mut worker, state) = create_worker_and_state(flags, argv); + let xeval_source = format!( + "window._xevalWrapper = async function ({}){{ + {} + }}", + &xeval_replvar, &state.argv[1] + ); + + let main_future = lazy(move || { + // Setup runtime. + js_check(worker.execute(&xeval_source)); + js_check(worker.execute("denoMain()")); + worker + .then(|result| { + js_check(result); + Ok(()) + }) + .map_err(print_err_and_exit) + }); + tokio_util::run(main_future); +} + +fn bundle_command(flags: DenoFlags, argv: Vec) { + let (mut _worker, state) = create_worker_and_state(flags, argv); + + let main_module = state.main_module().unwrap(); + assert!(state.argv.len() >= 3); + let out_file = state.argv[2].clone(); + debug!(">>>>> bundle_async START"); + let bundle_future = state + .ts_compiler + .bundle_async(state.clone(), main_module.to_string(), out_file) + .map_err(|err| { + debug!("diagnostics returned, exiting!"); + eprintln!(""); + print_err_and_exit(err); + }) + .and_then(move |_| { + debug!(">>>>> bundle_async END"); + Ok(()) + }); + tokio_util::run(bundle_future); +} + +fn run_repl(flags: DenoFlags, argv: Vec) { + let (mut worker, _state) = create_worker_and_state(flags, argv); + + // REPL situation. + let main_future = lazy(move || { + // Setup runtime. + js_check(worker.execute("denoMain()")); + worker + .then(|result| { + js_check(result); + Ok(()) + }) + .map_err(|(err, _worker): (ErrBox, Worker)| print_err_and_exit(err)) + }); + tokio_util::run(main_future); +} + +fn run_script(flags: DenoFlags, argv: Vec) { + let use_current_thread = flags.current_thread; + let (mut worker, state) = create_worker_and_state(flags, argv); + + let main_module = state.main_module().unwrap(); + // Normal situation of executing a module. + let main_future = lazy(move || { + // Setup runtime. + js_check(worker.execute("denoMain()")); + debug!("main_module {}", main_module); + + worker + .execute_mod_async(&main_module, false) + .and_then(move |()| { + js_check(worker.execute("window.dispatchEvent(new Event('load'))")); + worker.then(|result| { + js_check(result); + Ok(()) + }) + }) + .map_err(print_err_and_exit) + }); + + if use_current_thread { + tokio_util::run_on_current_thread(main_future); + } else { + tokio_util::run(main_future); + } +} + +fn version_command() { + println!("deno: {}", version::DENO); + println!("v8: {}", version::v8()); + println!("typescript: {}", version::TYPESCRIPT); +} + +pub fn main() { + #[cfg(windows)] + ansi_term::enable_ansi_support().ok(); // For Windows 10 + + log::set_logger(&LOGGER).unwrap(); + let args: Vec = env::args().collect(); + let (flags, subcommand, argv) = flags::flags_from_vec(args); + + if let Some(ref v8_flags) = flags.v8_flags { + v8_set_flags(v8_flags.clone()); + } + + let log_level = match flags.log_level { + Some(level) => level, + None => Level::Warn, + }; + log::set_max_level(log_level.to_level_filter()); + + match subcommand { + DenoSubcommand::Bundle => bundle_command(flags, argv), + DenoSubcommand::Completions => {} + DenoSubcommand::Eval => eval_command(flags, argv), + DenoSubcommand::Fetch => fetch_command(flags, argv), + DenoSubcommand::Info => info_command(flags, argv), + DenoSubcommand::Repl => run_repl(flags, argv), + DenoSubcommand::Run => run_script(flags, argv), + DenoSubcommand::Types => types_command(), + DenoSubcommand::Version => version_command(), + DenoSubcommand::Xeval => xeval_command(flags, argv), + } +} diff --git a/cli/main.rs b/cli/main.rs index e535b70bd6..b24c61a9b3 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -1,440 +1,5 @@ -// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -#[macro_use] -extern crate lazy_static; -#[macro_use] -extern crate log; -#[macro_use] -extern crate futures; -#[macro_use] -extern crate serde_json; -extern crate clap; -extern crate deno; -extern crate deno_cli_snapshots; -extern crate indexmap; -#[cfg(unix)] -extern crate nix; -extern crate rand; -extern crate serde; -extern crate serde_derive; -extern crate url; - -#[cfg(test)] -mod integration_tests; - -mod colors; -pub mod compilers; -pub mod deno_dir; -pub mod deno_error; -pub mod diagnostics; -mod disk_cache; -mod file_fetcher; -pub mod flags; -pub mod fmt_errors; -mod fs; -mod global_timer; -mod http_body; -mod http_util; -mod import_map; -pub mod msg; -pub mod ops; -pub mod permissions; -mod progress; -mod repl; -pub mod resolve_addr; -pub mod resources; -mod shell; -mod signal; -pub mod source_maps; -mod startup_data; -pub mod state; -mod tokio_read; -mod tokio_util; -mod tokio_write; -pub mod version; -pub mod worker; - -use crate::progress::Progress; -use crate::state::ThreadSafeState; -use crate::worker::Worker; -use deno::v8_set_flags; -use deno::ErrBox; -use deno::ModuleSpecifier; -use flags::DenoFlags; -use flags::DenoSubcommand; -use futures::lazy; -use futures::Future; -use log::Level; -use log::Metadata; -use log::Record; -use std::env; - -static LOGGER: Logger = Logger; - -struct Logger; - -impl log::Log for Logger { - fn enabled(&self, metadata: &Metadata) -> bool { - metadata.level() <= log::max_level() - } - - fn log(&self, record: &Record) { - if self.enabled(record.metadata()) { - let mut target = record.target().to_string(); - - if let Some(line_no) = record.line() { - target.push_str(":"); - target.push_str(&line_no.to_string()); - } - - println!("{} RS - {} - {}", record.level(), target, record.args()); - } - } - fn flush(&self) {} -} - -fn print_err_and_exit(err: ErrBox) { - eprintln!("{}", err.to_string()); - std::process::exit(1); -} - -fn js_check(r: Result<(), ErrBox>) { - if let Err(err) = r { - print_err_and_exit(err); - } -} - -fn create_worker_and_state( - flags: DenoFlags, - argv: Vec, -) -> (Worker, ThreadSafeState) { - use crate::shell::Shell; - use std::sync::Arc; - use std::sync::Mutex; - let shell = Arc::new(Mutex::new(Shell::new())); - let progress = Progress::new(); - progress.set_callback(move |_done, _completed, _total, status, msg| { - if !status.is_empty() { - let mut s = shell.lock().unwrap(); - s.status(status, msg).expect("shell problem"); - } - }); - // TODO(kevinkassimo): maybe make include_deno_namespace also configurable? - let state = ThreadSafeState::new(flags, argv, progress, true) - .map_err(print_err_and_exit) - .unwrap(); - let worker = Worker::new( - "main".to_string(), - startup_data::deno_isolate_init(), - state.clone(), - ); - - (worker, state) -} - -fn types_command() { - let content = deno_cli_snapshots::get_asset("lib.deno_runtime.d.ts").unwrap(); - println!("{}", content); -} - -fn print_cache_info(worker: Worker) { - let state = worker.state; - - println!( - "{} {:?}", - colors::bold("DENO_DIR location:".to_string()), - state.dir.root - ); - println!( - "{} {:?}", - colors::bold("Remote modules cache:".to_string()), - state.dir.deps_cache.location - ); - println!( - "{} {:?}", - colors::bold("TypeScript compiler cache:".to_string()), - state.dir.gen_cache.location - ); -} - -pub fn print_file_info( - worker: Worker, - module_specifier: &ModuleSpecifier, -) -> impl Future { - let state_ = worker.state.clone(); - let module_specifier_ = module_specifier.clone(); - - state_ - .file_fetcher - .fetch_source_file_async(&module_specifier) - .map_err(|err| println!("{}", err)) - .and_then(|out| { - println!( - "{} {}", - colors::bold("local:".to_string()), - out.filename.to_str().unwrap() - ); - - println!( - "{} {}", - colors::bold("type:".to_string()), - msg::enum_name_media_type(out.media_type) - ); - - state_ - .clone() - .fetch_compiled_module(&module_specifier_) - .map_err(|e| { - debug!("compiler error exiting!"); - eprintln!("\n{}", e.to_string()); - std::process::exit(1); - }) - .and_then(move |compiled| { - if out.media_type == msg::MediaType::TypeScript - || (out.media_type == msg::MediaType::JavaScript - && state_.ts_compiler.compile_js) - { - let compiled_source_file = state_ - .ts_compiler - .get_compiled_source_file(&out.url) - .unwrap(); - - println!( - "{} {}", - colors::bold("compiled:".to_string()), - compiled_source_file.filename.to_str().unwrap(), - ); - } - - if let Ok(source_map) = state_ - .clone() - .ts_compiler - .get_source_map_file(&module_specifier_) - { - println!( - "{} {}", - colors::bold("map:".to_string()), - source_map.filename.to_str().unwrap() - ); - } - - if let Some(deps) = - worker.state.modules.lock().unwrap().deps(&compiled.name) - { - println!("{}{}", colors::bold("deps:\n".to_string()), deps.name); - if let Some(ref depsdeps) = deps.deps { - for d in depsdeps { - println!("{}", d); - } - } - } else { - println!( - "{} cannot retrieve full dependency graph", - colors::bold("deps:".to_string()), - ); - } - Ok(worker) - }) - }) -} - -fn info_command(flags: DenoFlags, argv: Vec) { - let (mut worker, state) = create_worker_and_state(flags, argv.clone()); - - // If it was just "deno info" print location of caches and exit - if argv.len() == 1 { - return print_cache_info(worker); - } - - let main_module = state.main_module().unwrap(); - let main_future = lazy(move || { - // Setup runtime. - js_check(worker.execute("denoMain()")); - debug!("main_module {}", main_module); - - worker - .execute_mod_async(&main_module, true) - .map_err(print_err_and_exit) - .and_then(move |()| print_file_info(worker, &main_module)) - .and_then(|worker| { - worker.then(|result| { - js_check(result); - Ok(()) - }) - }) - }); - tokio_util::run(main_future); -} - -fn fetch_command(flags: DenoFlags, argv: Vec) { - let (mut worker, state) = create_worker_and_state(flags, argv.clone()); - - let main_module = state.main_module().unwrap(); - let main_future = lazy(move || { - // Setup runtime. - js_check(worker.execute("denoMain()")); - debug!("main_module {}", main_module); - - worker.execute_mod_async(&main_module, true).then(|result| { - js_check(result); - Ok(()) - }) - }); - tokio_util::run(main_future); -} - -fn eval_command(flags: DenoFlags, argv: Vec) { - let (mut worker, state) = create_worker_and_state(flags, argv); - // Wrap provided script in async function so asynchronous methods - // work. This is required until top-level await is not supported. - let js_source = format!( - "async function _topLevelWrapper(){{ - {} - }} - _topLevelWrapper(); - ", - &state.argv[1] - ); - - let main_future = lazy(move || { - js_check(worker.execute("denoMain()")); - // ATM imports in `deno eval` are not allowed - // TODO Support ES modules once Worker supports evaluating anonymous modules. - js_check(worker.execute(&js_source)); - worker.then(|result| { - js_check(result); - Ok(()) - }) - }); - tokio_util::run(main_future); -} - -fn xeval_command(flags: DenoFlags, argv: Vec) { - let xeval_replvar = flags.xeval_replvar.clone().unwrap(); - let (mut worker, state) = create_worker_and_state(flags, argv); - let xeval_source = format!( - "window._xevalWrapper = async function ({}){{ - {} - }}", - &xeval_replvar, &state.argv[1] - ); - - let main_future = lazy(move || { - // Setup runtime. - js_check(worker.execute(&xeval_source)); - js_check(worker.execute("denoMain()")); - worker - .then(|result| { - js_check(result); - Ok(()) - }) - .map_err(print_err_and_exit) - }); - tokio_util::run(main_future); -} - -fn bundle_command(flags: DenoFlags, argv: Vec) { - let (mut _worker, state) = create_worker_and_state(flags, argv); - - let main_module = state.main_module().unwrap(); - assert!(state.argv.len() >= 3); - let out_file = state.argv[2].clone(); - debug!(">>>>> bundle_async START"); - let bundle_future = state - .ts_compiler - .bundle_async(state.clone(), main_module.to_string(), out_file) - .map_err(|err| { - debug!("diagnostics returned, exiting!"); - eprintln!(""); - print_err_and_exit(err); - }) - .and_then(move |_| { - debug!(">>>>> bundle_async END"); - Ok(()) - }); - tokio_util::run(bundle_future); -} - -fn run_repl(flags: DenoFlags, argv: Vec) { - let (mut worker, _state) = create_worker_and_state(flags, argv); - - // REPL situation. - let main_future = lazy(move || { - // Setup runtime. - js_check(worker.execute("denoMain()")); - worker - .then(|result| { - js_check(result); - Ok(()) - }) - .map_err(|(err, _worker): (ErrBox, Worker)| print_err_and_exit(err)) - }); - tokio_util::run(main_future); -} - -fn run_script(flags: DenoFlags, argv: Vec) { - let use_current_thread = flags.current_thread; - let (mut worker, state) = create_worker_and_state(flags, argv); - - let main_module = state.main_module().unwrap(); - // Normal situation of executing a module. - let main_future = lazy(move || { - // Setup runtime. - js_check(worker.execute("denoMain()")); - debug!("main_module {}", main_module); - - worker - .execute_mod_async(&main_module, false) - .and_then(move |()| { - js_check(worker.execute("window.dispatchEvent(new Event('load'))")); - worker.then(|result| { - js_check(result); - Ok(()) - }) - }) - .map_err(print_err_and_exit) - }); - - if use_current_thread { - tokio_util::run_on_current_thread(main_future); - } else { - tokio_util::run(main_future); - } -} - -fn version_command() { - println!("deno: {}", version::DENO); - println!("v8: {}", version::v8()); - println!("typescript: {}", version::TYPESCRIPT); -} +extern crate deno_cli; fn main() { - #[cfg(windows)] - ansi_term::enable_ansi_support().ok(); // For Windows 10 - - log::set_logger(&LOGGER).unwrap(); - let args: Vec = env::args().collect(); - let (flags, subcommand, argv) = flags::flags_from_vec(args); - - if let Some(ref v8_flags) = flags.v8_flags { - v8_set_flags(v8_flags.clone()); - } - - let log_level = match flags.log_level { - Some(level) => level, - None => Level::Warn, - }; - log::set_max_level(log_level.to_level_filter()); - - match subcommand { - DenoSubcommand::Bundle => bundle_command(flags, argv), - DenoSubcommand::Completions => {} - DenoSubcommand::Eval => eval_command(flags, argv), - DenoSubcommand::Fetch => fetch_command(flags, argv), - DenoSubcommand::Info => info_command(flags, argv), - DenoSubcommand::Repl => run_repl(flags, argv), - DenoSubcommand::Run => run_script(flags, argv), - DenoSubcommand::Types => types_command(), - DenoSubcommand::Version => version_command(), - DenoSubcommand::Xeval => xeval_command(flags, argv), - } + deno_cli::main(); } diff --git a/tests/001_hello.js b/cli/tests/001_hello.js similarity index 100% rename from tests/001_hello.js rename to cli/tests/001_hello.js diff --git a/tests/001_hello.js.out b/cli/tests/001_hello.js.out similarity index 100% rename from tests/001_hello.js.out rename to cli/tests/001_hello.js.out diff --git a/tests/002_hello.ts b/cli/tests/002_hello.ts similarity index 100% rename from tests/002_hello.ts rename to cli/tests/002_hello.ts diff --git a/tests/002_hello.ts.out b/cli/tests/002_hello.ts.out similarity index 100% rename from tests/002_hello.ts.out rename to cli/tests/002_hello.ts.out diff --git a/tests/003_relative_import.ts b/cli/tests/003_relative_import.ts similarity index 100% rename from tests/003_relative_import.ts rename to cli/tests/003_relative_import.ts diff --git a/tests/003_relative_import.ts.out b/cli/tests/003_relative_import.ts.out similarity index 100% rename from tests/003_relative_import.ts.out rename to cli/tests/003_relative_import.ts.out diff --git a/tests/004_set_timeout.ts b/cli/tests/004_set_timeout.ts similarity index 100% rename from tests/004_set_timeout.ts rename to cli/tests/004_set_timeout.ts diff --git a/tests/004_set_timeout.ts.out b/cli/tests/004_set_timeout.ts.out similarity index 100% rename from tests/004_set_timeout.ts.out rename to cli/tests/004_set_timeout.ts.out diff --git a/tests/005_more_imports.ts b/cli/tests/005_more_imports.ts similarity index 100% rename from tests/005_more_imports.ts rename to cli/tests/005_more_imports.ts diff --git a/tests/005_more_imports.ts.out b/cli/tests/005_more_imports.ts.out similarity index 100% rename from tests/005_more_imports.ts.out rename to cli/tests/005_more_imports.ts.out diff --git a/tests/006_url_imports.ts b/cli/tests/006_url_imports.ts similarity index 100% rename from tests/006_url_imports.ts rename to cli/tests/006_url_imports.ts diff --git a/tests/006_url_imports.ts.out b/cli/tests/006_url_imports.ts.out similarity index 100% rename from tests/006_url_imports.ts.out rename to cli/tests/006_url_imports.ts.out diff --git a/tests/012_async.ts b/cli/tests/012_async.ts similarity index 100% rename from tests/012_async.ts rename to cli/tests/012_async.ts diff --git a/tests/012_async.ts.out b/cli/tests/012_async.ts.out similarity index 100% rename from tests/012_async.ts.out rename to cli/tests/012_async.ts.out diff --git a/tests/013_dynamic_import.ts b/cli/tests/013_dynamic_import.ts similarity index 100% rename from tests/013_dynamic_import.ts rename to cli/tests/013_dynamic_import.ts diff --git a/tests/013_dynamic_import.ts.out b/cli/tests/013_dynamic_import.ts.out similarity index 100% rename from tests/013_dynamic_import.ts.out rename to cli/tests/013_dynamic_import.ts.out diff --git a/tests/014_duplicate_import.ts b/cli/tests/014_duplicate_import.ts similarity index 100% rename from tests/014_duplicate_import.ts rename to cli/tests/014_duplicate_import.ts diff --git a/tests/014_duplicate_import.ts.out b/cli/tests/014_duplicate_import.ts.out similarity index 100% rename from tests/014_duplicate_import.ts.out rename to cli/tests/014_duplicate_import.ts.out diff --git a/tests/015_duplicate_parallel_import.js b/cli/tests/015_duplicate_parallel_import.js similarity index 100% rename from tests/015_duplicate_parallel_import.js rename to cli/tests/015_duplicate_parallel_import.js diff --git a/tests/015_duplicate_parallel_import.js.out b/cli/tests/015_duplicate_parallel_import.js.out similarity index 100% rename from tests/015_duplicate_parallel_import.js.out rename to cli/tests/015_duplicate_parallel_import.js.out diff --git a/tests/016_double_await.ts b/cli/tests/016_double_await.ts similarity index 100% rename from tests/016_double_await.ts rename to cli/tests/016_double_await.ts diff --git a/tests/016_double_await.ts.out b/cli/tests/016_double_await.ts.out similarity index 100% rename from tests/016_double_await.ts.out rename to cli/tests/016_double_await.ts.out diff --git a/tests/017_import_redirect.ts b/cli/tests/017_import_redirect.ts similarity index 100% rename from tests/017_import_redirect.ts rename to cli/tests/017_import_redirect.ts diff --git a/tests/017_import_redirect.ts.out b/cli/tests/017_import_redirect.ts.out similarity index 100% rename from tests/017_import_redirect.ts.out rename to cli/tests/017_import_redirect.ts.out diff --git a/tests/018_async_catch.ts b/cli/tests/018_async_catch.ts similarity index 100% rename from tests/018_async_catch.ts rename to cli/tests/018_async_catch.ts diff --git a/tests/018_async_catch.ts.out b/cli/tests/018_async_catch.ts.out similarity index 100% rename from tests/018_async_catch.ts.out rename to cli/tests/018_async_catch.ts.out diff --git a/tests/019_media_types.ts b/cli/tests/019_media_types.ts similarity index 100% rename from tests/019_media_types.ts rename to cli/tests/019_media_types.ts diff --git a/tests/019_media_types.ts.out b/cli/tests/019_media_types.ts.out similarity index 100% rename from tests/019_media_types.ts.out rename to cli/tests/019_media_types.ts.out diff --git a/tests/020_json_modules.ts b/cli/tests/020_json_modules.ts similarity index 100% rename from tests/020_json_modules.ts rename to cli/tests/020_json_modules.ts diff --git a/tests/020_json_modules.ts.out b/cli/tests/020_json_modules.ts.out similarity index 100% rename from tests/020_json_modules.ts.out rename to cli/tests/020_json_modules.ts.out diff --git a/tests/021_mjs_modules.ts b/cli/tests/021_mjs_modules.ts similarity index 100% rename from tests/021_mjs_modules.ts rename to cli/tests/021_mjs_modules.ts diff --git a/tests/021_mjs_modules.ts.out b/cli/tests/021_mjs_modules.ts.out similarity index 100% rename from tests/021_mjs_modules.ts.out rename to cli/tests/021_mjs_modules.ts.out diff --git a/tests/022_info_flag_script.out b/cli/tests/022_info_flag_script.out similarity index 100% rename from tests/022_info_flag_script.out rename to cli/tests/022_info_flag_script.out diff --git a/tests/023_no_ext_with_headers b/cli/tests/023_no_ext_with_headers similarity index 100% rename from tests/023_no_ext_with_headers rename to cli/tests/023_no_ext_with_headers diff --git a/tests/023_no_ext_with_headers.headers.json b/cli/tests/023_no_ext_with_headers.headers.json similarity index 100% rename from tests/023_no_ext_with_headers.headers.json rename to cli/tests/023_no_ext_with_headers.headers.json diff --git a/tests/023_no_ext_with_headers.out b/cli/tests/023_no_ext_with_headers.out similarity index 100% rename from tests/023_no_ext_with_headers.out rename to cli/tests/023_no_ext_with_headers.out diff --git a/tests/024_import_no_ext_with_headers.ts b/cli/tests/024_import_no_ext_with_headers.ts similarity index 100% rename from tests/024_import_no_ext_with_headers.ts rename to cli/tests/024_import_no_ext_with_headers.ts diff --git a/tests/024_import_no_ext_with_headers.ts.out b/cli/tests/024_import_no_ext_with_headers.ts.out similarity index 100% rename from tests/024_import_no_ext_with_headers.ts.out rename to cli/tests/024_import_no_ext_with_headers.ts.out diff --git a/tests/025_hrtime.ts b/cli/tests/025_hrtime.ts similarity index 100% rename from tests/025_hrtime.ts rename to cli/tests/025_hrtime.ts diff --git a/tests/025_hrtime.ts.out b/cli/tests/025_hrtime.ts.out similarity index 100% rename from tests/025_hrtime.ts.out rename to cli/tests/025_hrtime.ts.out diff --git a/tests/025_reload_js_type_error.js b/cli/tests/025_reload_js_type_error.js similarity index 100% rename from tests/025_reload_js_type_error.js rename to cli/tests/025_reload_js_type_error.js diff --git a/tests/025_reload_js_type_error.js.out b/cli/tests/025_reload_js_type_error.js.out similarity index 100% rename from tests/025_reload_js_type_error.js.out rename to cli/tests/025_reload_js_type_error.js.out diff --git a/tests/026_redirect_javascript.js b/cli/tests/026_redirect_javascript.js similarity index 100% rename from tests/026_redirect_javascript.js rename to cli/tests/026_redirect_javascript.js diff --git a/tests/026_redirect_javascript.js.out b/cli/tests/026_redirect_javascript.js.out similarity index 100% rename from tests/026_redirect_javascript.js.out rename to cli/tests/026_redirect_javascript.js.out diff --git a/tests/026_workers.ts b/cli/tests/026_workers.ts similarity index 100% rename from tests/026_workers.ts rename to cli/tests/026_workers.ts diff --git a/tests/026_workers.ts.out b/cli/tests/026_workers.ts.out similarity index 100% rename from tests/026_workers.ts.out rename to cli/tests/026_workers.ts.out diff --git a/tests/027_redirect_typescript.ts b/cli/tests/027_redirect_typescript.ts similarity index 100% rename from tests/027_redirect_typescript.ts rename to cli/tests/027_redirect_typescript.ts diff --git a/tests/027_redirect_typescript.ts.out b/cli/tests/027_redirect_typescript.ts.out similarity index 100% rename from tests/027_redirect_typescript.ts.out rename to cli/tests/027_redirect_typescript.ts.out diff --git a/tests/028_args.ts b/cli/tests/028_args.ts similarity index 100% rename from tests/028_args.ts rename to cli/tests/028_args.ts diff --git a/tests/028_args.ts.out b/cli/tests/028_args.ts.out similarity index 100% rename from tests/028_args.ts.out rename to cli/tests/028_args.ts.out diff --git a/tests/029_eval.out b/cli/tests/029_eval.out similarity index 100% rename from tests/029_eval.out rename to cli/tests/029_eval.out diff --git a/tests/030_xeval.out b/cli/tests/030_xeval.out similarity index 100% rename from tests/030_xeval.out rename to cli/tests/030_xeval.out diff --git a/tests/031_xeval_replvar.out b/cli/tests/031_xeval_replvar.out similarity index 100% rename from tests/031_xeval_replvar.out rename to cli/tests/031_xeval_replvar.out diff --git a/tests/032_xeval_delim.out b/cli/tests/032_xeval_delim.out similarity index 100% rename from tests/032_xeval_delim.out rename to cli/tests/032_xeval_delim.out diff --git a/tests/033_import_map.out b/cli/tests/033_import_map.out similarity index 100% rename from tests/033_import_map.out rename to cli/tests/033_import_map.out diff --git a/tests/034_onload.out b/cli/tests/034_onload.out similarity index 100% rename from tests/034_onload.out rename to cli/tests/034_onload.out diff --git a/tests/034_onload/imported.ts b/cli/tests/034_onload/imported.ts similarity index 100% rename from tests/034_onload/imported.ts rename to cli/tests/034_onload/imported.ts diff --git a/tests/034_onload/main.ts b/cli/tests/034_onload/main.ts similarity index 100% rename from tests/034_onload/main.ts rename to cli/tests/034_onload/main.ts diff --git a/tests/034_onload/nest_imported.ts b/cli/tests/034_onload/nest_imported.ts similarity index 100% rename from tests/034_onload/nest_imported.ts rename to cli/tests/034_onload/nest_imported.ts diff --git a/tests/034_onload_imported.ts b/cli/tests/034_onload_imported.ts similarity index 100% rename from tests/034_onload_imported.ts rename to cli/tests/034_onload_imported.ts diff --git a/tests/035_no_fetch_flag.out b/cli/tests/035_no_fetch_flag.out similarity index 100% rename from tests/035_no_fetch_flag.out rename to cli/tests/035_no_fetch_flag.out diff --git a/tests/036_import_map_fetch.out b/cli/tests/036_import_map_fetch.out similarity index 100% rename from tests/036_import_map_fetch.out rename to cli/tests/036_import_map_fetch.out diff --git a/tests/038_checkjs.js b/cli/tests/038_checkjs.js similarity index 100% rename from tests/038_checkjs.js rename to cli/tests/038_checkjs.js diff --git a/tests/038_checkjs.js.out b/cli/tests/038_checkjs.js.out similarity index 100% rename from tests/038_checkjs.js.out rename to cli/tests/038_checkjs.js.out diff --git a/tests/038_checkjs.tsconfig.json b/cli/tests/038_checkjs.tsconfig.json similarity index 100% rename from tests/038_checkjs.tsconfig.json rename to cli/tests/038_checkjs.tsconfig.json diff --git a/tests/039_worker_deno_ns.ts b/cli/tests/039_worker_deno_ns.ts similarity index 100% rename from tests/039_worker_deno_ns.ts rename to cli/tests/039_worker_deno_ns.ts diff --git a/tests/039_worker_deno_ns.ts.out b/cli/tests/039_worker_deno_ns.ts.out similarity index 100% rename from tests/039_worker_deno_ns.ts.out rename to cli/tests/039_worker_deno_ns.ts.out diff --git a/tests/039_worker_deno_ns/has_ns.ts b/cli/tests/039_worker_deno_ns/has_ns.ts similarity index 100% rename from tests/039_worker_deno_ns/has_ns.ts rename to cli/tests/039_worker_deno_ns/has_ns.ts diff --git a/tests/039_worker_deno_ns/maybe_ns.ts b/cli/tests/039_worker_deno_ns/maybe_ns.ts similarity index 100% rename from tests/039_worker_deno_ns/maybe_ns.ts rename to cli/tests/039_worker_deno_ns/maybe_ns.ts diff --git a/tests/039_worker_deno_ns/no_ns.ts b/cli/tests/039_worker_deno_ns/no_ns.ts similarity index 100% rename from tests/039_worker_deno_ns/no_ns.ts rename to cli/tests/039_worker_deno_ns/no_ns.ts diff --git a/tests/040_worker_blob.ts b/cli/tests/040_worker_blob.ts similarity index 100% rename from tests/040_worker_blob.ts rename to cli/tests/040_worker_blob.ts diff --git a/tests/040_worker_blob.ts.out b/cli/tests/040_worker_blob.ts.out similarity index 100% rename from tests/040_worker_blob.ts.out rename to cli/tests/040_worker_blob.ts.out diff --git a/tests/041_dyn_import_eval.out b/cli/tests/041_dyn_import_eval.out similarity index 100% rename from tests/041_dyn_import_eval.out rename to cli/tests/041_dyn_import_eval.out diff --git a/tests/041_info_flag.out b/cli/tests/041_info_flag.out similarity index 100% rename from tests/041_info_flag.out rename to cli/tests/041_info_flag.out diff --git a/tests/042_dyn_import_evalcontext.ts b/cli/tests/042_dyn_import_evalcontext.ts similarity index 100% rename from tests/042_dyn_import_evalcontext.ts rename to cli/tests/042_dyn_import_evalcontext.ts diff --git a/tests/042_dyn_import_evalcontext.ts.out b/cli/tests/042_dyn_import_evalcontext.ts.out similarity index 100% rename from tests/042_dyn_import_evalcontext.ts.out rename to cli/tests/042_dyn_import_evalcontext.ts.out diff --git a/tests/043_xeval_delim2.out b/cli/tests/043_xeval_delim2.out similarity index 100% rename from tests/043_xeval_delim2.out rename to cli/tests/043_xeval_delim2.out diff --git a/tests/043_xeval_delim2.test b/cli/tests/043_xeval_delim2.test similarity index 100% rename from tests/043_xeval_delim2.test rename to cli/tests/043_xeval_delim2.test diff --git a/tests/044_bad_resource.test b/cli/tests/044_bad_resource.test similarity index 100% rename from tests/044_bad_resource.test rename to cli/tests/044_bad_resource.test diff --git a/tests/044_bad_resource.ts b/cli/tests/044_bad_resource.ts similarity index 100% rename from tests/044_bad_resource.ts rename to cli/tests/044_bad_resource.ts diff --git a/tests/044_bad_resource.ts.out b/cli/tests/044_bad_resource.ts.out similarity index 100% rename from tests/044_bad_resource.ts.out rename to cli/tests/044_bad_resource.ts.out diff --git a/cli/tests/README.md b/cli/tests/README.md new file mode 100644 index 0000000000..dc199196d2 --- /dev/null +++ b/cli/tests/README.md @@ -0,0 +1,7 @@ +# Integration Tests + +This path contains integration tests. See integration_tests.rs for the index. + +TODO(ry) Currently //tests is a symlink to //cli/tests, to simplify transition. +In the future //tests should be removed when all references to //tests are +updated. diff --git a/tests/async_error.ts b/cli/tests/async_error.ts similarity index 100% rename from tests/async_error.ts rename to cli/tests/async_error.ts diff --git a/tests/async_error.ts.out b/cli/tests/async_error.ts.out similarity index 100% rename from tests/async_error.ts.out rename to cli/tests/async_error.ts.out diff --git a/tests/badly_formatted.js b/cli/tests/badly_formatted.js similarity index 100% rename from tests/badly_formatted.js rename to cli/tests/badly_formatted.js diff --git a/tests/badly_formatted_fixed.js b/cli/tests/badly_formatted_fixed.js similarity index 100% rename from tests/badly_formatted_fixed.js rename to cli/tests/badly_formatted_fixed.js diff --git a/tests/cat.ts b/cli/tests/cat.ts similarity index 100% rename from tests/cat.ts rename to cli/tests/cat.ts diff --git a/tests/circular1.js b/cli/tests/circular1.js similarity index 100% rename from tests/circular1.js rename to cli/tests/circular1.js diff --git a/tests/circular1.js.out b/cli/tests/circular1.js.out similarity index 100% rename from tests/circular1.js.out rename to cli/tests/circular1.js.out diff --git a/tests/circular2.js b/cli/tests/circular2.js similarity index 100% rename from tests/circular2.js rename to cli/tests/circular2.js diff --git a/tests/config.ts b/cli/tests/config.ts similarity index 100% rename from tests/config.ts rename to cli/tests/config.ts diff --git a/tests/config.ts.out b/cli/tests/config.ts.out similarity index 100% rename from tests/config.ts.out rename to cli/tests/config.ts.out diff --git a/tests/config.tsconfig.json b/cli/tests/config.tsconfig.json similarity index 100% rename from tests/config.tsconfig.json rename to cli/tests/config.tsconfig.json diff --git a/tests/echo_server.ts b/cli/tests/echo_server.ts similarity index 100% rename from tests/echo_server.ts rename to cli/tests/echo_server.ts diff --git a/tests/error_001.ts b/cli/tests/error_001.ts similarity index 100% rename from tests/error_001.ts rename to cli/tests/error_001.ts diff --git a/tests/error_001.ts.out b/cli/tests/error_001.ts.out similarity index 100% rename from tests/error_001.ts.out rename to cli/tests/error_001.ts.out diff --git a/tests/error_002.ts b/cli/tests/error_002.ts similarity index 100% rename from tests/error_002.ts rename to cli/tests/error_002.ts diff --git a/tests/error_002.ts.out b/cli/tests/error_002.ts.out similarity index 100% rename from tests/error_002.ts.out rename to cli/tests/error_002.ts.out diff --git a/tests/error_003_typescript.ts b/cli/tests/error_003_typescript.ts similarity index 100% rename from tests/error_003_typescript.ts rename to cli/tests/error_003_typescript.ts diff --git a/tests/error_003_typescript.ts.out b/cli/tests/error_003_typescript.ts.out similarity index 100% rename from tests/error_003_typescript.ts.out rename to cli/tests/error_003_typescript.ts.out diff --git a/tests/error_004_missing_module.ts b/cli/tests/error_004_missing_module.ts similarity index 100% rename from tests/error_004_missing_module.ts rename to cli/tests/error_004_missing_module.ts diff --git a/tests/error_004_missing_module.ts.out b/cli/tests/error_004_missing_module.ts.out similarity index 100% rename from tests/error_004_missing_module.ts.out rename to cli/tests/error_004_missing_module.ts.out diff --git a/tests/error_005_missing_dynamic_import.ts b/cli/tests/error_005_missing_dynamic_import.ts similarity index 100% rename from tests/error_005_missing_dynamic_import.ts rename to cli/tests/error_005_missing_dynamic_import.ts diff --git a/tests/error_005_missing_dynamic_import.ts.out b/cli/tests/error_005_missing_dynamic_import.ts.out similarity index 100% rename from tests/error_005_missing_dynamic_import.ts.out rename to cli/tests/error_005_missing_dynamic_import.ts.out diff --git a/tests/error_006_import_ext_failure.ts b/cli/tests/error_006_import_ext_failure.ts similarity index 100% rename from tests/error_006_import_ext_failure.ts rename to cli/tests/error_006_import_ext_failure.ts diff --git a/tests/error_006_import_ext_failure.ts.out b/cli/tests/error_006_import_ext_failure.ts.out similarity index 100% rename from tests/error_006_import_ext_failure.ts.out rename to cli/tests/error_006_import_ext_failure.ts.out diff --git a/tests/error_007_any.ts b/cli/tests/error_007_any.ts similarity index 100% rename from tests/error_007_any.ts rename to cli/tests/error_007_any.ts diff --git a/tests/error_007_any.ts.out b/cli/tests/error_007_any.ts.out similarity index 100% rename from tests/error_007_any.ts.out rename to cli/tests/error_007_any.ts.out diff --git a/tests/error_008_checkjs.js b/cli/tests/error_008_checkjs.js similarity index 100% rename from tests/error_008_checkjs.js rename to cli/tests/error_008_checkjs.js diff --git a/tests/error_008_checkjs.js.out b/cli/tests/error_008_checkjs.js.out similarity index 100% rename from tests/error_008_checkjs.js.out rename to cli/tests/error_008_checkjs.js.out diff --git a/tests/error_009_missing_js_module.disabled b/cli/tests/error_009_missing_js_module.disabled similarity index 100% rename from tests/error_009_missing_js_module.disabled rename to cli/tests/error_009_missing_js_module.disabled diff --git a/tests/error_009_missing_js_module.js b/cli/tests/error_009_missing_js_module.js similarity index 100% rename from tests/error_009_missing_js_module.js rename to cli/tests/error_009_missing_js_module.js diff --git a/tests/error_009_missing_js_module.js.out b/cli/tests/error_009_missing_js_module.js.out similarity index 100% rename from tests/error_009_missing_js_module.js.out rename to cli/tests/error_009_missing_js_module.js.out diff --git a/tests/error_010_nonexistent_arg.disabled b/cli/tests/error_010_nonexistent_arg.disabled similarity index 100% rename from tests/error_010_nonexistent_arg.disabled rename to cli/tests/error_010_nonexistent_arg.disabled diff --git a/tests/error_010_nonexistent_arg.out b/cli/tests/error_010_nonexistent_arg.out similarity index 100% rename from tests/error_010_nonexistent_arg.out rename to cli/tests/error_010_nonexistent_arg.out diff --git a/tests/error_011_bad_module_specifier.ts b/cli/tests/error_011_bad_module_specifier.ts similarity index 100% rename from tests/error_011_bad_module_specifier.ts rename to cli/tests/error_011_bad_module_specifier.ts diff --git a/tests/error_011_bad_module_specifier.ts.out b/cli/tests/error_011_bad_module_specifier.ts.out similarity index 100% rename from tests/error_011_bad_module_specifier.ts.out rename to cli/tests/error_011_bad_module_specifier.ts.out diff --git a/tests/error_012_bad_dynamic_import_specifier.ts b/cli/tests/error_012_bad_dynamic_import_specifier.ts similarity index 100% rename from tests/error_012_bad_dynamic_import_specifier.ts rename to cli/tests/error_012_bad_dynamic_import_specifier.ts diff --git a/tests/error_012_bad_dynamic_import_specifier.ts.out b/cli/tests/error_012_bad_dynamic_import_specifier.ts.out similarity index 100% rename from tests/error_012_bad_dynamic_import_specifier.ts.out rename to cli/tests/error_012_bad_dynamic_import_specifier.ts.out diff --git a/tests/error_013_missing_script.out b/cli/tests/error_013_missing_script.out similarity index 100% rename from tests/error_013_missing_script.out rename to cli/tests/error_013_missing_script.out diff --git a/tests/error_014_catch_dynamic_import_error.js b/cli/tests/error_014_catch_dynamic_import_error.js similarity index 100% rename from tests/error_014_catch_dynamic_import_error.js rename to cli/tests/error_014_catch_dynamic_import_error.js diff --git a/tests/error_014_catch_dynamic_import_error.js.out b/cli/tests/error_014_catch_dynamic_import_error.js.out similarity index 100% rename from tests/error_014_catch_dynamic_import_error.js.out rename to cli/tests/error_014_catch_dynamic_import_error.js.out diff --git a/tests/error_015_dynamic_import_permissions.js b/cli/tests/error_015_dynamic_import_permissions.js similarity index 100% rename from tests/error_015_dynamic_import_permissions.js rename to cli/tests/error_015_dynamic_import_permissions.js diff --git a/tests/error_015_dynamic_import_permissions.out b/cli/tests/error_015_dynamic_import_permissions.out similarity index 100% rename from tests/error_015_dynamic_import_permissions.out rename to cli/tests/error_015_dynamic_import_permissions.out diff --git a/tests/error_016_dynamic_import_permissions2.js b/cli/tests/error_016_dynamic_import_permissions2.js similarity index 100% rename from tests/error_016_dynamic_import_permissions2.js rename to cli/tests/error_016_dynamic_import_permissions2.js diff --git a/tests/error_016_dynamic_import_permissions2.out b/cli/tests/error_016_dynamic_import_permissions2.out similarity index 100% rename from tests/error_016_dynamic_import_permissions2.out rename to cli/tests/error_016_dynamic_import_permissions2.out diff --git a/tests/error_stack.ts b/cli/tests/error_stack.ts similarity index 100% rename from tests/error_stack.ts rename to cli/tests/error_stack.ts diff --git a/tests/error_stack.ts.out b/cli/tests/error_stack.ts.out similarity index 100% rename from tests/error_stack.ts.out rename to cli/tests/error_stack.ts.out diff --git a/tests/error_syntax.js b/cli/tests/error_syntax.js similarity index 100% rename from tests/error_syntax.js rename to cli/tests/error_syntax.js diff --git a/tests/error_syntax.js.out b/cli/tests/error_syntax.js.out similarity index 100% rename from tests/error_syntax.js.out rename to cli/tests/error_syntax.js.out diff --git a/tests/error_type_definitions.ts b/cli/tests/error_type_definitions.ts similarity index 100% rename from tests/error_type_definitions.ts rename to cli/tests/error_type_definitions.ts diff --git a/tests/error_type_definitions.ts.out b/cli/tests/error_type_definitions.ts.out similarity index 100% rename from tests/error_type_definitions.ts.out rename to cli/tests/error_type_definitions.ts.out diff --git a/tests/esm_imports_a.js b/cli/tests/esm_imports_a.js similarity index 100% rename from tests/esm_imports_a.js rename to cli/tests/esm_imports_a.js diff --git a/tests/esm_imports_b.js b/cli/tests/esm_imports_b.js similarity index 100% rename from tests/esm_imports_b.js rename to cli/tests/esm_imports_b.js diff --git a/tests/exec_path.ts b/cli/tests/exec_path.ts similarity index 100% rename from tests/exec_path.ts rename to cli/tests/exec_path.ts diff --git a/tests/exit_error42.ts b/cli/tests/exit_error42.ts similarity index 100% rename from tests/exit_error42.ts rename to cli/tests/exit_error42.ts diff --git a/tests/exit_error42.ts.out b/cli/tests/exit_error42.ts.out similarity index 100% rename from tests/exit_error42.ts.out rename to cli/tests/exit_error42.ts.out diff --git a/tests/fetch_deps.ts b/cli/tests/fetch_deps.ts similarity index 100% rename from tests/fetch_deps.ts rename to cli/tests/fetch_deps.ts diff --git a/tests/hello.txt b/cli/tests/hello.txt similarity index 100% rename from tests/hello.txt rename to cli/tests/hello.txt diff --git a/tests/https_import.ts b/cli/tests/https_import.ts similarity index 100% rename from tests/https_import.ts rename to cli/tests/https_import.ts diff --git a/tests/https_import.ts.out b/cli/tests/https_import.ts.out similarity index 100% rename from tests/https_import.ts.out rename to cli/tests/https_import.ts.out diff --git a/tests/if_main.ts b/cli/tests/if_main.ts similarity index 100% rename from tests/if_main.ts rename to cli/tests/if_main.ts diff --git a/tests/if_main.ts.out b/cli/tests/if_main.ts.out similarity index 100% rename from tests/if_main.ts.out rename to cli/tests/if_main.ts.out diff --git a/tests/import_meta.ts b/cli/tests/import_meta.ts similarity index 100% rename from tests/import_meta.ts rename to cli/tests/import_meta.ts diff --git a/tests/import_meta.ts.out b/cli/tests/import_meta.ts.out similarity index 100% rename from tests/import_meta.ts.out rename to cli/tests/import_meta.ts.out diff --git a/tests/import_meta2.ts b/cli/tests/import_meta2.ts similarity index 100% rename from tests/import_meta2.ts rename to cli/tests/import_meta2.ts diff --git a/tests/importmaps/import_map.json b/cli/tests/importmaps/import_map.json similarity index 100% rename from tests/importmaps/import_map.json rename to cli/tests/importmaps/import_map.json diff --git a/tests/importmaps/lodash/lodash.ts b/cli/tests/importmaps/lodash/lodash.ts similarity index 100% rename from tests/importmaps/lodash/lodash.ts rename to cli/tests/importmaps/lodash/lodash.ts diff --git a/tests/importmaps/lodash/other_file.ts b/cli/tests/importmaps/lodash/other_file.ts similarity index 100% rename from tests/importmaps/lodash/other_file.ts rename to cli/tests/importmaps/lodash/other_file.ts diff --git a/tests/importmaps/moment/moment.ts b/cli/tests/importmaps/moment/moment.ts similarity index 100% rename from tests/importmaps/moment/moment.ts rename to cli/tests/importmaps/moment/moment.ts diff --git a/tests/importmaps/moment/other_file.ts b/cli/tests/importmaps/moment/other_file.ts similarity index 100% rename from tests/importmaps/moment/other_file.ts rename to cli/tests/importmaps/moment/other_file.ts diff --git a/tests/importmaps/scope/scoped.ts b/cli/tests/importmaps/scope/scoped.ts similarity index 100% rename from tests/importmaps/scope/scoped.ts rename to cli/tests/importmaps/scope/scoped.ts diff --git a/tests/importmaps/scoped_moment.ts b/cli/tests/importmaps/scoped_moment.ts similarity index 100% rename from tests/importmaps/scoped_moment.ts rename to cli/tests/importmaps/scoped_moment.ts diff --git a/tests/importmaps/test.ts b/cli/tests/importmaps/test.ts similarity index 100% rename from tests/importmaps/test.ts rename to cli/tests/importmaps/test.ts diff --git a/tests/importmaps/vue.ts b/cli/tests/importmaps/vue.ts similarity index 100% rename from tests/importmaps/vue.ts rename to cli/tests/importmaps/vue.ts diff --git a/cli/integration_tests.rs b/cli/tests/integration_tests.rs similarity index 99% rename from cli/integration_tests.rs rename to cli/tests/integration_tests.rs index b03f695961..86de4fa6a6 100644 --- a/cli/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -1,5 +1,8 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -use crate::colors::strip_ansi_codes; +#[macro_use] +extern crate log; + +use deno_cli::colors::strip_ansi_codes; use os_pipe::pipe; use std::env; use std::io::Read; diff --git a/tests/is_tty.ts b/cli/tests/is_tty.ts similarity index 100% rename from tests/is_tty.ts rename to cli/tests/is_tty.ts diff --git a/tests/no_color.js b/cli/tests/no_color.js similarity index 100% rename from tests/no_color.js rename to cli/tests/no_color.js diff --git a/tests/seed_random.js b/cli/tests/seed_random.js similarity index 100% rename from tests/seed_random.js rename to cli/tests/seed_random.js diff --git a/tests/seed_random.js.out b/cli/tests/seed_random.js.out similarity index 100% rename from tests/seed_random.js.out rename to cli/tests/seed_random.js.out diff --git a/tests/subdir/auto_print_hello.ts b/cli/tests/subdir/auto_print_hello.ts similarity index 100% rename from tests/subdir/auto_print_hello.ts rename to cli/tests/subdir/auto_print_hello.ts diff --git a/tests/subdir/bench_worker.ts b/cli/tests/subdir/bench_worker.ts similarity index 100% rename from tests/subdir/bench_worker.ts rename to cli/tests/subdir/bench_worker.ts diff --git a/tests/subdir/config.json b/cli/tests/subdir/config.json similarity index 100% rename from tests/subdir/config.json rename to cli/tests/subdir/config.json diff --git a/tests/subdir/evil_remote_import.js b/cli/tests/subdir/evil_remote_import.js similarity index 100% rename from tests/subdir/evil_remote_import.js rename to cli/tests/subdir/evil_remote_import.js diff --git a/tests/subdir/form_urlencoded.txt b/cli/tests/subdir/form_urlencoded.txt similarity index 100% rename from tests/subdir/form_urlencoded.txt rename to cli/tests/subdir/form_urlencoded.txt diff --git a/tests/subdir/indirect_import_error.js b/cli/tests/subdir/indirect_import_error.js similarity index 100% rename from tests/subdir/indirect_import_error.js rename to cli/tests/subdir/indirect_import_error.js diff --git a/tests/subdir/indirect_throws.js b/cli/tests/subdir/indirect_throws.js similarity index 100% rename from tests/subdir/indirect_throws.js rename to cli/tests/subdir/indirect_throws.js diff --git a/tests/subdir/mismatch_ext.ts b/cli/tests/subdir/mismatch_ext.ts similarity index 100% rename from tests/subdir/mismatch_ext.ts rename to cli/tests/subdir/mismatch_ext.ts diff --git a/tests/subdir/mod1.ts b/cli/tests/subdir/mod1.ts similarity index 100% rename from tests/subdir/mod1.ts rename to cli/tests/subdir/mod1.ts diff --git a/tests/subdir/mod2.ts b/cli/tests/subdir/mod2.ts similarity index 100% rename from tests/subdir/mod2.ts rename to cli/tests/subdir/mod2.ts diff --git a/tests/subdir/mod3.js b/cli/tests/subdir/mod3.js similarity index 100% rename from tests/subdir/mod3.js rename to cli/tests/subdir/mod3.js diff --git a/tests/subdir/mod4.js b/cli/tests/subdir/mod4.js similarity index 100% rename from tests/subdir/mod4.js rename to cli/tests/subdir/mod4.js diff --git a/tests/subdir/mod5.mjs b/cli/tests/subdir/mod5.mjs similarity index 100% rename from tests/subdir/mod5.mjs rename to cli/tests/subdir/mod5.mjs diff --git a/tests/subdir/mt_application_ecmascript.j2.js b/cli/tests/subdir/mt_application_ecmascript.j2.js similarity index 100% rename from tests/subdir/mt_application_ecmascript.j2.js rename to cli/tests/subdir/mt_application_ecmascript.j2.js diff --git a/tests/subdir/mt_application_x_javascript.j4.js b/cli/tests/subdir/mt_application_x_javascript.j4.js similarity index 100% rename from tests/subdir/mt_application_x_javascript.j4.js rename to cli/tests/subdir/mt_application_x_javascript.j4.js diff --git a/tests/subdir/mt_application_x_typescript.t4.ts b/cli/tests/subdir/mt_application_x_typescript.t4.ts similarity index 100% rename from tests/subdir/mt_application_x_typescript.t4.ts rename to cli/tests/subdir/mt_application_x_typescript.t4.ts diff --git a/tests/subdir/mt_javascript.js b/cli/tests/subdir/mt_javascript.js similarity index 100% rename from tests/subdir/mt_javascript.js rename to cli/tests/subdir/mt_javascript.js diff --git a/tests/subdir/mt_text_ecmascript.j3.js b/cli/tests/subdir/mt_text_ecmascript.j3.js similarity index 100% rename from tests/subdir/mt_text_ecmascript.j3.js rename to cli/tests/subdir/mt_text_ecmascript.j3.js diff --git a/tests/subdir/mt_text_javascript.j1.js b/cli/tests/subdir/mt_text_javascript.j1.js similarity index 100% rename from tests/subdir/mt_text_javascript.j1.js rename to cli/tests/subdir/mt_text_javascript.j1.js diff --git a/tests/subdir/mt_text_typescript.t1.ts b/cli/tests/subdir/mt_text_typescript.t1.ts similarity index 100% rename from tests/subdir/mt_text_typescript.t1.ts rename to cli/tests/subdir/mt_text_typescript.t1.ts diff --git a/tests/subdir/mt_video_mp2t.t3.ts b/cli/tests/subdir/mt_video_mp2t.t3.ts similarity index 100% rename from tests/subdir/mt_video_mp2t.t3.ts rename to cli/tests/subdir/mt_video_mp2t.t3.ts diff --git a/tests/subdir/mt_video_vdn.t2.ts b/cli/tests/subdir/mt_video_vdn.t2.ts similarity index 100% rename from tests/subdir/mt_video_vdn.t2.ts rename to cli/tests/subdir/mt_video_vdn.t2.ts diff --git a/tests/subdir/no_ext b/cli/tests/subdir/no_ext similarity index 100% rename from tests/subdir/no_ext rename to cli/tests/subdir/no_ext diff --git a/tests/subdir/print_hello.ts b/cli/tests/subdir/print_hello.ts similarity index 100% rename from tests/subdir/print_hello.ts rename to cli/tests/subdir/print_hello.ts diff --git a/tests/subdir/redirects/redirect1.js b/cli/tests/subdir/redirects/redirect1.js similarity index 100% rename from tests/subdir/redirects/redirect1.js rename to cli/tests/subdir/redirects/redirect1.js diff --git a/tests/subdir/redirects/redirect1.ts b/cli/tests/subdir/redirects/redirect1.ts similarity index 100% rename from tests/subdir/redirects/redirect1.ts rename to cli/tests/subdir/redirects/redirect1.ts diff --git a/tests/subdir/redirects/redirect2.js b/cli/tests/subdir/redirects/redirect2.js similarity index 100% rename from tests/subdir/redirects/redirect2.js rename to cli/tests/subdir/redirects/redirect2.js diff --git a/tests/subdir/redirects/redirect3.js b/cli/tests/subdir/redirects/redirect3.js similarity index 100% rename from tests/subdir/redirects/redirect3.js rename to cli/tests/subdir/redirects/redirect3.js diff --git a/tests/subdir/redirects/redirect4.ts b/cli/tests/subdir/redirects/redirect4.ts similarity index 100% rename from tests/subdir/redirects/redirect4.ts rename to cli/tests/subdir/redirects/redirect4.ts diff --git a/tests/subdir/subdir2/mod2.ts b/cli/tests/subdir/subdir2/mod2.ts similarity index 100% rename from tests/subdir/subdir2/mod2.ts rename to cli/tests/subdir/subdir2/mod2.ts diff --git a/tests/subdir/test_worker.js b/cli/tests/subdir/test_worker.js similarity index 100% rename from tests/subdir/test_worker.js rename to cli/tests/subdir/test_worker.js diff --git a/tests/subdir/test_worker.ts b/cli/tests/subdir/test_worker.ts similarity index 100% rename from tests/subdir/test_worker.ts rename to cli/tests/subdir/test_worker.ts diff --git a/tests/subdir/throws.js b/cli/tests/subdir/throws.js similarity index 100% rename from tests/subdir/throws.js rename to cli/tests/subdir/throws.js diff --git a/tests/subdir/unknown_ext.deno b/cli/tests/subdir/unknown_ext.deno similarity index 100% rename from tests/subdir/unknown_ext.deno rename to cli/tests/subdir/unknown_ext.deno diff --git a/tests/type_definitions.ts b/cli/tests/type_definitions.ts similarity index 100% rename from tests/type_definitions.ts rename to cli/tests/type_definitions.ts diff --git a/tests/type_definitions.ts.out b/cli/tests/type_definitions.ts.out similarity index 100% rename from tests/type_definitions.ts.out rename to cli/tests/type_definitions.ts.out diff --git a/tests/type_definitions/bar.d.ts b/cli/tests/type_definitions/bar.d.ts similarity index 100% rename from tests/type_definitions/bar.d.ts rename to cli/tests/type_definitions/bar.d.ts diff --git a/tests/type_definitions/fizz.d.ts b/cli/tests/type_definitions/fizz.d.ts similarity index 100% rename from tests/type_definitions/fizz.d.ts rename to cli/tests/type_definitions/fizz.d.ts diff --git a/tests/type_definitions/fizz.js b/cli/tests/type_definitions/fizz.js similarity index 100% rename from tests/type_definitions/fizz.js rename to cli/tests/type_definitions/fizz.js diff --git a/tests/type_definitions/foo.d.ts b/cli/tests/type_definitions/foo.d.ts similarity index 100% rename from tests/type_definitions/foo.d.ts rename to cli/tests/type_definitions/foo.d.ts diff --git a/tests/type_definitions/foo.js b/cli/tests/type_definitions/foo.js similarity index 100% rename from tests/type_definitions/foo.js rename to cli/tests/type_definitions/foo.js diff --git a/tests/type_definitions/qat.ts b/cli/tests/type_definitions/qat.ts similarity index 100% rename from tests/type_definitions/qat.ts rename to cli/tests/type_definitions/qat.ts diff --git a/tests/types.out b/cli/tests/types.out similarity index 100% rename from tests/types.out rename to cli/tests/types.out diff --git a/tests/unbuffered_stderr.ts b/cli/tests/unbuffered_stderr.ts similarity index 100% rename from tests/unbuffered_stderr.ts rename to cli/tests/unbuffered_stderr.ts diff --git a/tests/unbuffered_stderr.ts.out b/cli/tests/unbuffered_stderr.ts.out similarity index 100% rename from tests/unbuffered_stderr.ts.out rename to cli/tests/unbuffered_stderr.ts.out diff --git a/tests/unbuffered_stdout.ts b/cli/tests/unbuffered_stdout.ts similarity index 100% rename from tests/unbuffered_stdout.ts rename to cli/tests/unbuffered_stdout.ts diff --git a/tests/unbuffered_stdout.ts.out b/cli/tests/unbuffered_stdout.ts.out similarity index 100% rename from tests/unbuffered_stdout.ts.out rename to cli/tests/unbuffered_stdout.ts.out diff --git a/tests/v8_flags.js b/cli/tests/v8_flags.js similarity index 100% rename from tests/v8_flags.js rename to cli/tests/v8_flags.js diff --git a/tests/v8_flags.js.out b/cli/tests/v8_flags.js.out similarity index 100% rename from tests/v8_flags.js.out rename to cli/tests/v8_flags.js.out diff --git a/tests/v8_help.out b/cli/tests/v8_help.out similarity index 100% rename from tests/v8_help.out rename to cli/tests/v8_help.out diff --git a/tests/version.out b/cli/tests/version.out similarity index 100% rename from tests/version.out rename to cli/tests/version.out diff --git a/tests/wasm.ts b/cli/tests/wasm.ts similarity index 100% rename from tests/wasm.ts rename to cli/tests/wasm.ts diff --git a/tests/wasm.ts.out b/cli/tests/wasm.ts.out similarity index 100% rename from tests/wasm.ts.out rename to cli/tests/wasm.ts.out diff --git a/tests/wasm_async.js b/cli/tests/wasm_async.js similarity index 100% rename from tests/wasm_async.js rename to cli/tests/wasm_async.js diff --git a/tests/wasm_async.out b/cli/tests/wasm_async.out similarity index 100% rename from tests/wasm_async.out rename to cli/tests/wasm_async.out diff --git a/tests/workers_round_robin_bench.ts b/cli/tests/workers_round_robin_bench.ts similarity index 100% rename from tests/workers_round_robin_bench.ts rename to cli/tests/workers_round_robin_bench.ts diff --git a/tests/workers_startup_bench.ts b/cli/tests/workers_startup_bench.ts similarity index 100% rename from tests/workers_startup_bench.ts rename to cli/tests/workers_startup_bench.ts diff --git a/js/stat_test.ts b/js/stat_test.ts index 1de98f984d..1542f10802 100644 --- a/js/stat_test.ts +++ b/js/stat_test.ts @@ -54,9 +54,9 @@ testPerm({ read: true }, async function lstatSyncSuccess(): Promise { assert(!modulesInfo.isDirectory()); assert(modulesInfo.isSymlink()); - const testsInfo = Deno.lstatSync("tests"); - assert(testsInfo.isDirectory()); - assert(!testsInfo.isSymlink()); + const i = Deno.lstatSync("website"); + assert(i.isDirectory()); + assert(!i.isSymlink()); }); testPerm({ read: false }, async function lstatSyncPerm(): Promise { @@ -96,9 +96,9 @@ testPerm({ read: true }, async function statSuccess(): Promise { assert(modulesInfo.isDirectory()); assert(!modulesInfo.isSymlink()); - const testsInfo = await Deno.stat("tests"); - assert(testsInfo.isDirectory()); - assert(!testsInfo.isSymlink()); + const i = await Deno.stat("tests"); + assert(i.isDirectory()); + assert(!i.isSymlink()); }); testPerm({ read: false }, async function statPerm(): Promise { @@ -138,9 +138,9 @@ testPerm({ read: true }, async function lstatSuccess(): Promise { assert(!modulesInfo.isDirectory()); assert(modulesInfo.isSymlink()); - const testsInfo = await Deno.lstat("tests"); - assert(testsInfo.isDirectory()); - assert(!testsInfo.isSymlink()); + const i = await Deno.lstat("website"); + assert(i.isDirectory()); + assert(!i.isSymlink()); }); testPerm({ read: false }, async function lstatPerm(): Promise { diff --git a/tests b/tests new file mode 120000 index 0000000000..0e706053cf --- /dev/null +++ b/tests @@ -0,0 +1 @@ +cli/tests \ No newline at end of file diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index 2bd294932e..0000000000 --- a/tests/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Integration Tests - -This path contains integration tests. See cli/integration_tests.rs for the -index. - -TODO(ry): Move integration_tests.rs to this directory as described in -https://doc.rust-lang.org/rust-by-example/testing/integration_testing.html