2022-01-07 22:09:52 -05:00
|
|
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
2021-06-27 13:27:36 -04:00
|
|
|
|
2022-01-10 23:24:39 -05:00
|
|
|
use std::fs::File;
|
2021-06-27 13:27:36 -04:00
|
|
|
use std::process::Command;
|
|
|
|
use tempfile::TempDir;
|
|
|
|
use test_util as util;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn compile() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2021-06-27 13:27:36 -04:00
|
|
|
let exe = if cfg!(windows) {
|
|
|
|
dir.path().join("welcome.exe")
|
|
|
|
} else {
|
|
|
|
dir.path().join("welcome")
|
|
|
|
};
|
|
|
|
let output = util::deno_cmd()
|
|
|
|
.current_dir(util::root_path())
|
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&exe)
|
|
|
|
.arg("./test_util/std/examples/welcome.ts")
|
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
let output = Command::new(exe)
|
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
assert_eq!(output.stdout, "Welcome to Deno!\n".as_bytes());
|
|
|
|
}
|
|
|
|
|
2022-03-23 21:45:45 -04:00
|
|
|
// this is ignored, because when building on a release build, the test attempts
|
|
|
|
// to download a binary of a yet to be published version.
|
|
|
|
// TODO(@kitsonk) https://github.com/denoland/deno/issues/14103
|
|
|
|
#[ignore]
|
2021-06-27 13:27:36 -04:00
|
|
|
#[test]
|
|
|
|
#[cfg(windows)]
|
|
|
|
// https://github.com/denoland/deno/issues/9667
|
|
|
|
fn compile_windows_ext() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2021-06-27 13:27:36 -04:00
|
|
|
let exe = dir.path().join("welcome_9667");
|
|
|
|
let output = util::deno_cmd()
|
|
|
|
.current_dir(util::root_path())
|
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&exe)
|
|
|
|
.arg("--target")
|
|
|
|
.arg("x86_64-unknown-linux-gnu")
|
|
|
|
.arg("./test_util/std/examples/welcome.ts")
|
|
|
|
// TODO(kt3k): Prints command output to the test log for debugging purpose.
|
|
|
|
// Uncomment this line when this test become stable.
|
|
|
|
//.stdout(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
assert!(std::path::Path::new(&exe).exists());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn standalone_args() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2021-06-27 13:27:36 -04:00
|
|
|
let exe = if cfg!(windows) {
|
|
|
|
dir.path().join("args.exe")
|
|
|
|
} else {
|
|
|
|
dir.path().join("args")
|
|
|
|
};
|
|
|
|
let output = util::deno_cmd()
|
2021-08-11 10:20:47 -04:00
|
|
|
.current_dir(util::testdata_path())
|
2021-06-27 13:27:36 -04:00
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&exe)
|
2021-08-11 10:20:47 -04:00
|
|
|
.arg("./028_args.ts")
|
2021-06-27 13:27:36 -04:00
|
|
|
.arg("a")
|
|
|
|
.arg("b")
|
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
let output = Command::new(exe)
|
|
|
|
.arg("foo")
|
|
|
|
.arg("--bar")
|
|
|
|
.arg("--unstable")
|
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
assert_eq!(output.stdout, b"a\nb\nfoo\n--bar\n--unstable\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn standalone_error() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2021-06-27 13:27:36 -04:00
|
|
|
let exe = if cfg!(windows) {
|
|
|
|
dir.path().join("error.exe")
|
|
|
|
} else {
|
|
|
|
dir.path().join("error")
|
|
|
|
};
|
2022-02-15 07:33:46 -05:00
|
|
|
let testdata_path = util::testdata_path();
|
2021-06-27 13:27:36 -04:00
|
|
|
let output = util::deno_cmd()
|
2022-02-15 07:33:46 -05:00
|
|
|
.current_dir(&testdata_path)
|
2021-06-27 13:27:36 -04:00
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&exe)
|
2021-08-11 10:20:47 -04:00
|
|
|
.arg("./standalone_error.ts")
|
2021-06-27 13:27:36 -04:00
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
let output = Command::new(exe)
|
|
|
|
.env("NO_COLOR", "1")
|
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(!output.status.success());
|
|
|
|
assert_eq!(output.stdout, b"");
|
|
|
|
let stderr = String::from_utf8(output.stderr).unwrap();
|
2022-02-15 07:33:46 -05:00
|
|
|
// On Windows, we cannot assert the file path (because '\').
|
|
|
|
// Instead we just check for relevant output.
|
|
|
|
assert!(stderr.contains("error: Error: boom!\n at boom (file://"));
|
|
|
|
assert!(stderr.contains("standalone_error.ts:2:11"));
|
|
|
|
assert!(stderr.contains("at foo (file://"));
|
|
|
|
assert!(stderr.contains("standalone_error.ts:5:5"));
|
|
|
|
assert!(stderr.contains("standalone_error.ts:7:1"));
|
2021-06-27 13:27:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2022-02-15 07:33:46 -05:00
|
|
|
fn standalone_error_module_with_imports() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2021-06-27 13:27:36 -04:00
|
|
|
let exe = if cfg!(windows) {
|
2022-02-15 07:33:46 -05:00
|
|
|
dir.path().join("error.exe")
|
2021-06-27 13:27:36 -04:00
|
|
|
} else {
|
2022-02-15 07:33:46 -05:00
|
|
|
dir.path().join("error")
|
2021-06-27 13:27:36 -04:00
|
|
|
};
|
2022-02-15 07:33:46 -05:00
|
|
|
let testdata_path = util::testdata_path();
|
2021-06-27 13:27:36 -04:00
|
|
|
let output = util::deno_cmd()
|
2022-02-15 07:33:46 -05:00
|
|
|
.current_dir(&testdata_path)
|
2021-06-27 13:27:36 -04:00
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&exe)
|
2022-02-15 07:33:46 -05:00
|
|
|
.arg("./standalone_error_module_with_imports_1.ts")
|
2021-06-27 13:27:36 -04:00
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
let output = Command::new(exe)
|
2022-02-15 07:33:46 -05:00
|
|
|
.env("NO_COLOR", "1")
|
2021-06-27 13:27:36 -04:00
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(!output.status.success());
|
2022-02-15 07:33:46 -05:00
|
|
|
println!("{:#?}", &output);
|
|
|
|
assert_eq!(output.stdout, b"hello\n");
|
|
|
|
let stderr = String::from_utf8(output.stderr).unwrap();
|
|
|
|
// On Windows, we cannot assert the file path (because '\').
|
|
|
|
// Instead we just check for relevant output.
|
|
|
|
assert!(stderr.contains("error: Error: boom!\n at file://"));
|
|
|
|
assert!(stderr.contains("standalone_error_module_with_imports_2.ts:2:7"));
|
2021-06-27 13:27:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn standalone_load_datauri() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2021-06-27 13:27:36 -04:00
|
|
|
let exe = if cfg!(windows) {
|
|
|
|
dir.path().join("load_datauri.exe")
|
|
|
|
} else {
|
|
|
|
dir.path().join("load_datauri")
|
|
|
|
};
|
|
|
|
let output = util::deno_cmd()
|
2021-08-11 10:20:47 -04:00
|
|
|
.current_dir(util::testdata_path())
|
2021-06-27 13:27:36 -04:00
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&exe)
|
2021-08-11 10:20:47 -04:00
|
|
|
.arg("./standalone_import_datauri.ts")
|
2021-06-27 13:27:36 -04:00
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
let output = Command::new(exe)
|
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
assert_eq!(output.stdout, b"Hello Deno!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn standalone_compiler_ops() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2021-06-27 13:27:36 -04:00
|
|
|
let exe = if cfg!(windows) {
|
|
|
|
dir.path().join("standalone_compiler_ops.exe")
|
|
|
|
} else {
|
|
|
|
dir.path().join("standalone_compiler_ops")
|
|
|
|
};
|
|
|
|
let output = util::deno_cmd()
|
2021-08-11 10:20:47 -04:00
|
|
|
.current_dir(util::testdata_path())
|
2021-06-27 13:27:36 -04:00
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&exe)
|
2021-08-11 10:20:47 -04:00
|
|
|
.arg("./standalone_compiler_ops.ts")
|
2021-06-27 13:27:36 -04:00
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
let output = Command::new(exe)
|
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
assert_eq!(output.stdout, b"Hello, Compiler API!\n");
|
|
|
|
}
|
|
|
|
|
2022-01-10 23:24:39 -05:00
|
|
|
#[test]
|
|
|
|
fn compile_with_directory_output_flag() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2022-01-10 23:24:39 -05:00
|
|
|
let output_path = if cfg!(windows) {
|
|
|
|
dir.path().join(r"args\random\")
|
|
|
|
} else {
|
|
|
|
dir.path().join("args/random/")
|
|
|
|
};
|
|
|
|
let output = util::deno_cmd()
|
|
|
|
.current_dir(util::testdata_path())
|
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&output_path)
|
|
|
|
.arg("./standalone_compiler_ops.ts")
|
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
let exe = if cfg!(windows) {
|
|
|
|
output_path.join("standalone_compiler_ops.exe")
|
|
|
|
} else {
|
|
|
|
output_path.join("standalone_compiler_ops")
|
|
|
|
};
|
|
|
|
assert!(&exe.exists());
|
|
|
|
let output = Command::new(exe)
|
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
assert_eq!(output.stdout, b"Hello, Compiler API!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn compile_with_file_exists_error() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2022-01-10 23:24:39 -05:00
|
|
|
let output_path = if cfg!(windows) {
|
|
|
|
dir.path().join(r"args\")
|
|
|
|
} else {
|
|
|
|
dir.path().join("args/")
|
|
|
|
};
|
|
|
|
let file_path = dir.path().join("args");
|
2022-03-22 13:37:15 -04:00
|
|
|
File::create(&file_path).unwrap();
|
2022-01-10 23:24:39 -05:00
|
|
|
let output = util::deno_cmd()
|
|
|
|
.current_dir(util::testdata_path())
|
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&output_path)
|
|
|
|
.arg("./028_args.ts")
|
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(!output.status.success());
|
2022-03-18 19:18:50 -04:00
|
|
|
let expected_stderr = format!(
|
|
|
|
concat!(
|
|
|
|
"Could not compile to file '{}' because its parent directory ",
|
|
|
|
"is an existing file. You can use the `--output <file-path>` flag to ",
|
|
|
|
"provide an alternative name.\n",
|
|
|
|
),
|
|
|
|
file_path.display(),
|
|
|
|
);
|
2022-01-10 23:24:39 -05:00
|
|
|
let stderr = String::from_utf8(output.stderr).unwrap();
|
|
|
|
assert!(stderr.contains(&expected_stderr));
|
|
|
|
}
|
|
|
|
|
2021-06-27 13:27:36 -04:00
|
|
|
#[test]
|
|
|
|
fn compile_with_directory_exists_error() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2021-06-27 13:27:36 -04:00
|
|
|
let exe = if cfg!(windows) {
|
|
|
|
dir.path().join("args.exe")
|
|
|
|
} else {
|
|
|
|
dir.path().join("args")
|
|
|
|
};
|
2022-03-22 13:37:15 -04:00
|
|
|
std::fs::create_dir(&exe).unwrap();
|
2021-06-27 13:27:36 -04:00
|
|
|
let output = util::deno_cmd()
|
2021-08-11 10:20:47 -04:00
|
|
|
.current_dir(util::testdata_path())
|
2021-06-27 13:27:36 -04:00
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&exe)
|
2021-08-11 10:20:47 -04:00
|
|
|
.arg("./028_args.ts")
|
2021-06-27 13:27:36 -04:00
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(!output.status.success());
|
2022-03-18 19:18:50 -04:00
|
|
|
let expected_stderr = format!(
|
|
|
|
concat!(
|
|
|
|
"Could not compile to file '{}' because a directory exists with ",
|
|
|
|
"the same name. You can use the `--output <file-path>` flag to ",
|
|
|
|
"provide an alternative name."
|
|
|
|
),
|
|
|
|
exe.display()
|
|
|
|
);
|
2021-06-27 13:27:36 -04:00
|
|
|
let stderr = String::from_utf8(output.stderr).unwrap();
|
|
|
|
assert!(stderr.contains(&expected_stderr));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn compile_with_conflict_file_exists_error() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2021-06-27 13:27:36 -04:00
|
|
|
let exe = if cfg!(windows) {
|
|
|
|
dir.path().join("args.exe")
|
|
|
|
} else {
|
|
|
|
dir.path().join("args")
|
|
|
|
};
|
2022-03-22 13:37:15 -04:00
|
|
|
std::fs::write(&exe, b"SHOULD NOT BE OVERWRITTEN").unwrap();
|
2021-06-27 13:27:36 -04:00
|
|
|
let output = util::deno_cmd()
|
2021-08-11 10:20:47 -04:00
|
|
|
.current_dir(util::testdata_path())
|
2021-06-27 13:27:36 -04:00
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&exe)
|
2021-08-11 10:20:47 -04:00
|
|
|
.arg("./028_args.ts")
|
2021-06-27 13:27:36 -04:00
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(!output.status.success());
|
2022-03-18 19:18:50 -04:00
|
|
|
let expected_stderr = format!(
|
|
|
|
concat!(
|
|
|
|
"Could not compile to file '{}' because the file already exists ",
|
|
|
|
"and cannot be overwritten. Please delete the existing file or ",
|
|
|
|
"use the `--output <file-path` flag to provide an alternative name."
|
|
|
|
),
|
|
|
|
exe.display()
|
|
|
|
);
|
2021-06-27 13:27:36 -04:00
|
|
|
let stderr = String::from_utf8(output.stderr).unwrap();
|
|
|
|
dbg!(&stderr);
|
|
|
|
assert!(stderr.contains(&expected_stderr));
|
|
|
|
assert!(std::fs::read(&exe)
|
2022-03-22 13:37:15 -04:00
|
|
|
.unwrap()
|
2021-06-27 13:27:36 -04:00
|
|
|
.eq(b"SHOULD NOT BE OVERWRITTEN"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn compile_and_overwrite_file() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2021-06-27 13:27:36 -04:00
|
|
|
let exe = if cfg!(windows) {
|
|
|
|
dir.path().join("args.exe")
|
|
|
|
} else {
|
|
|
|
dir.path().join("args")
|
|
|
|
};
|
|
|
|
let output = util::deno_cmd()
|
2021-08-11 10:20:47 -04:00
|
|
|
.current_dir(util::testdata_path())
|
2021-06-27 13:27:36 -04:00
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&exe)
|
2021-08-11 10:20:47 -04:00
|
|
|
.arg("./028_args.ts")
|
2021-06-27 13:27:36 -04:00
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
assert!(&exe.exists());
|
|
|
|
|
|
|
|
let recompile_output = util::deno_cmd()
|
2021-08-11 10:20:47 -04:00
|
|
|
.current_dir(util::testdata_path())
|
2021-06-27 13:27:36 -04:00
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&exe)
|
2021-08-11 10:20:47 -04:00
|
|
|
.arg("./028_args.ts")
|
2021-06-27 13:27:36 -04:00
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(recompile_output.status.success());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn standalone_runtime_flags() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2021-06-27 13:27:36 -04:00
|
|
|
let exe = if cfg!(windows) {
|
|
|
|
dir.path().join("flags.exe")
|
|
|
|
} else {
|
|
|
|
dir.path().join("flags")
|
|
|
|
};
|
|
|
|
let output = util::deno_cmd()
|
2021-08-11 10:20:47 -04:00
|
|
|
.current_dir(util::testdata_path())
|
2021-06-27 13:27:36 -04:00
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--allow-read")
|
|
|
|
.arg("--seed")
|
|
|
|
.arg("1")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&exe)
|
2021-08-11 10:20:47 -04:00
|
|
|
.arg("./standalone_runtime_flags.ts")
|
2021-06-27 13:27:36 -04:00
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
let output = Command::new(exe)
|
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(!output.status.success());
|
|
|
|
let stdout_str = String::from_utf8(output.stdout).unwrap();
|
|
|
|
assert_eq!(util::strip_ansi_codes(&stdout_str), "0.147205063401058\n");
|
|
|
|
let stderr_str = String::from_utf8(output.stderr).unwrap();
|
|
|
|
assert!(util::strip_ansi_codes(&stderr_str)
|
|
|
|
.contains("PermissionDenied: Requires write access"));
|
|
|
|
}
|
2021-11-23 17:59:17 -05:00
|
|
|
|
2022-02-24 08:28:00 -05:00
|
|
|
#[test]
|
|
|
|
fn standalone_import_map() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2022-02-24 08:28:00 -05:00
|
|
|
let exe = if cfg!(windows) {
|
|
|
|
dir.path().join("import_map.exe")
|
|
|
|
} else {
|
|
|
|
dir.path().join("import_map")
|
|
|
|
};
|
|
|
|
let output = util::deno_cmd()
|
|
|
|
.current_dir(util::testdata_path())
|
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--allow-read")
|
|
|
|
.arg("--import-map")
|
|
|
|
.arg("standalone_import_map.json")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&exe)
|
|
|
|
.arg("./standalone_import_map.ts")
|
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
let output = Command::new(exe)
|
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
}
|
|
|
|
|
2021-11-23 17:59:17 -05:00
|
|
|
#[test]
|
|
|
|
// https://github.com/denoland/deno/issues/12670
|
|
|
|
fn skip_rebundle() {
|
2022-03-22 13:37:15 -04:00
|
|
|
let dir = TempDir::new().unwrap();
|
2021-11-23 17:59:17 -05:00
|
|
|
let exe = if cfg!(windows) {
|
|
|
|
dir.path().join("hello_world.exe")
|
|
|
|
} else {
|
|
|
|
dir.path().join("hello_world")
|
|
|
|
};
|
|
|
|
let output = util::deno_cmd()
|
|
|
|
.current_dir(util::testdata_path())
|
|
|
|
.arg("compile")
|
|
|
|
.arg("--unstable")
|
|
|
|
.arg("--output")
|
|
|
|
.arg(&exe)
|
|
|
|
.arg("./001_hello.js")
|
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
|
|
|
|
//no "Bundle testdata_path/001_hello.js" in output
|
|
|
|
assert!(!String::from_utf8(output.stderr).unwrap().contains("Bundle"));
|
|
|
|
|
|
|
|
let output = Command::new(exe)
|
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
assert!(output.status.success());
|
|
|
|
assert_eq!(output.stdout, "Hello World\n".as_bytes());
|
|
|
|
}
|