mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
fix(tests): do not use global env vars in install tests (#14078)
This commit is contained in:
parent
d2c099ce34
commit
e46b5f738d
3 changed files with 124 additions and 138 deletions
|
@ -7,7 +7,7 @@ use test_util as util;
|
|||
|
||||
#[test]
|
||||
fn compile() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let exe = if cfg!(windows) {
|
||||
dir.path().join("welcome.exe")
|
||||
} else {
|
||||
|
@ -36,12 +36,11 @@ fn compile() {
|
|||
assert_eq!(output.stdout, "Welcome to Deno!\n".as_bytes());
|
||||
}
|
||||
|
||||
#[ignore]
|
||||
#[test]
|
||||
#[cfg(windows)]
|
||||
// https://github.com/denoland/deno/issues/9667
|
||||
fn compile_windows_ext() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let exe = dir.path().join("welcome_9667");
|
||||
let output = util::deno_cmd()
|
||||
.current_dir(util::root_path())
|
||||
|
@ -65,7 +64,7 @@ fn compile_windows_ext() {
|
|||
|
||||
#[test]
|
||||
fn standalone_args() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let exe = if cfg!(windows) {
|
||||
dir.path().join("args.exe")
|
||||
} else {
|
||||
|
@ -101,7 +100,7 @@ fn standalone_args() {
|
|||
|
||||
#[test]
|
||||
fn standalone_error() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let exe = if cfg!(windows) {
|
||||
dir.path().join("error.exe")
|
||||
} else {
|
||||
|
@ -143,7 +142,7 @@ fn standalone_error() {
|
|||
|
||||
#[test]
|
||||
fn standalone_error_module_with_imports() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let exe = if cfg!(windows) {
|
||||
dir.path().join("error.exe")
|
||||
} else {
|
||||
|
@ -183,7 +182,7 @@ fn standalone_error_module_with_imports() {
|
|||
|
||||
#[test]
|
||||
fn standalone_load_datauri() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let exe = if cfg!(windows) {
|
||||
dir.path().join("load_datauri.exe")
|
||||
} else {
|
||||
|
@ -215,7 +214,7 @@ fn standalone_load_datauri() {
|
|||
|
||||
#[test]
|
||||
fn standalone_compiler_ops() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let exe = if cfg!(windows) {
|
||||
dir.path().join("standalone_compiler_ops.exe")
|
||||
} else {
|
||||
|
@ -247,7 +246,7 @@ fn standalone_compiler_ops() {
|
|||
|
||||
#[test]
|
||||
fn compile_with_directory_output_flag() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let output_path = if cfg!(windows) {
|
||||
dir.path().join(r"args\random\")
|
||||
} else {
|
||||
|
@ -285,14 +284,14 @@ fn compile_with_directory_output_flag() {
|
|||
|
||||
#[test]
|
||||
fn compile_with_file_exists_error() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let output_path = if cfg!(windows) {
|
||||
dir.path().join(r"args\")
|
||||
} else {
|
||||
dir.path().join("args/")
|
||||
};
|
||||
let file_path = dir.path().join("args");
|
||||
File::create(&file_path).expect("cannot create file");
|
||||
File::create(&file_path).unwrap();
|
||||
let output = util::deno_cmd()
|
||||
.current_dir(util::testdata_path())
|
||||
.arg("compile")
|
||||
|
@ -320,13 +319,13 @@ fn compile_with_file_exists_error() {
|
|||
|
||||
#[test]
|
||||
fn compile_with_directory_exists_error() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let exe = if cfg!(windows) {
|
||||
dir.path().join("args.exe")
|
||||
} else {
|
||||
dir.path().join("args")
|
||||
};
|
||||
std::fs::create_dir(&exe).expect("cannot create directory");
|
||||
std::fs::create_dir(&exe).unwrap();
|
||||
let output = util::deno_cmd()
|
||||
.current_dir(util::testdata_path())
|
||||
.arg("compile")
|
||||
|
@ -354,14 +353,13 @@ fn compile_with_directory_exists_error() {
|
|||
|
||||
#[test]
|
||||
fn compile_with_conflict_file_exists_error() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let exe = if cfg!(windows) {
|
||||
dir.path().join("args.exe")
|
||||
} else {
|
||||
dir.path().join("args")
|
||||
};
|
||||
std::fs::write(&exe, b"SHOULD NOT BE OVERWRITTEN")
|
||||
.expect("cannot create file");
|
||||
std::fs::write(&exe, b"SHOULD NOT BE OVERWRITTEN").unwrap();
|
||||
let output = util::deno_cmd()
|
||||
.current_dir(util::testdata_path())
|
||||
.arg("compile")
|
||||
|
@ -387,13 +385,13 @@ fn compile_with_conflict_file_exists_error() {
|
|||
dbg!(&stderr);
|
||||
assert!(stderr.contains(&expected_stderr));
|
||||
assert!(std::fs::read(&exe)
|
||||
.expect("cannot read file")
|
||||
.unwrap()
|
||||
.eq(b"SHOULD NOT BE OVERWRITTEN"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compile_and_overwrite_file() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let exe = if cfg!(windows) {
|
||||
dir.path().join("args.exe")
|
||||
} else {
|
||||
|
@ -431,7 +429,7 @@ fn compile_and_overwrite_file() {
|
|||
|
||||
#[test]
|
||||
fn standalone_runtime_flags() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let exe = if cfg!(windows) {
|
||||
dir.path().join("flags.exe")
|
||||
} else {
|
||||
|
@ -470,7 +468,7 @@ fn standalone_runtime_flags() {
|
|||
|
||||
#[test]
|
||||
fn standalone_import_map() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let exe = if cfg!(windows) {
|
||||
dir.path().join("import_map.exe")
|
||||
} else {
|
||||
|
@ -505,7 +503,7 @@ fn standalone_import_map() {
|
|||
#[test]
|
||||
// https://github.com/denoland/deno/issues/12670
|
||||
fn skip_rebundle() {
|
||||
let dir = TempDir::new().expect("tempdir fail");
|
||||
let dir = TempDir::new().unwrap();
|
||||
let exe = if cfg!(windows) {
|
||||
dir.path().join("hello_world.exe")
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue