diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2021-08-11 10:20:47 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-11 10:20:47 -0400 |
commit | 15a763152f9d392cb80692262f8de5ef8ae15495 (patch) | |
tree | fcd1a59777f95920bf3502519983d6cc0d882a9a /cli/tools | |
parent | a0285e2eb88f6254f6494b0ecd1878db3a3b2a58 (diff) |
chore: move test files to testdata directory (#11601)
Diffstat (limited to 'cli/tools')
-rw-r--r-- | cli/tools/installer.rs | 91 | ||||
-rw-r--r-- | cli/tools/test_runner.rs | 7 |
2 files changed, 48 insertions, 50 deletions
diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index b6bb8bbb2..4d4709e28 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -320,7 +320,7 @@ mod tests { use deno_core::parking_lot::Mutex; use std::process::Command; use tempfile::TempDir; - use test_util::tests_path; + use test_util::testdata_path; lazy_static::lazy_static! { pub static ref ENV_LOCK: Mutex<()> = Mutex::new(()); @@ -417,7 +417,7 @@ mod tests { install( Flags::default(), - "http://localhost:4545/cli/tests/echo_server.ts", + "http://localhost:4545/echo_server.ts", vec![], Some("echo_test".to_string()), None, @@ -437,11 +437,11 @@ mod tests { assert_eq!(content.chars().last().unwrap(), '\n'); if cfg!(windows) { - assert!(content - .contains(r#""run" "http://localhost:4545/cli/tests/echo_server.ts""#)); + assert!( + content.contains(r#""run" "http://localhost:4545/echo_server.ts""#) + ); } else { - assert!(content - .contains(r#"run 'http://localhost:4545/cli/tests/echo_server.ts'"#)); + assert!(content.contains(r#"run 'http://localhost:4545/echo_server.ts'"#)); } if let Some(home) = original_home { env::set_var("HOME", home); @@ -465,7 +465,7 @@ mod tests { unstable: true, ..Flags::default() }, - "http://localhost:4545/cli/tests/echo_server.ts", + "http://localhost:4545/echo_server.ts", vec![], Some("echo_test".to_string()), Some(temp_dir.path().to_path_buf()), @@ -484,12 +484,11 @@ mod tests { println!("this is the file path {:?}", content); if cfg!(windows) { assert!(content.contains( - r#""run" "--unstable" "http://localhost:4545/cli/tests/echo_server.ts""# + r#""run" "--unstable" "http://localhost:4545/echo_server.ts""# )); } else { - assert!(content.contains( - r#"run --unstable 'http://localhost:4545/cli/tests/echo_server.ts'"# - )); + assert!(content + .contains(r#"run --unstable 'http://localhost:4545/echo_server.ts'"#)); } } @@ -501,7 +500,7 @@ mod tests { install( Flags::default(), - "http://localhost:4545/cli/tests/echo_server.ts", + "http://localhost:4545/echo_server.ts", vec![], None, Some(temp_dir.path().to_path_buf()), @@ -517,11 +516,11 @@ mod tests { assert!(file_path.exists()); let content = fs::read_to_string(file_path).unwrap(); if cfg!(windows) { - assert!(content - .contains(r#""run" "http://localhost:4545/cli/tests/echo_server.ts""#)); + assert!( + content.contains(r#""run" "http://localhost:4545/echo_server.ts""#) + ); } else { - assert!(content - .contains(r#"run 'http://localhost:4545/cli/tests/echo_server.ts'"#)); + assert!(content.contains(r#"run 'http://localhost:4545/echo_server.ts'"#)); } } @@ -533,7 +532,7 @@ mod tests { install( Flags::default(), - "http://localhost:4545/cli/tests/subdir/main.ts", + "http://localhost:4545/subdir/main.ts", vec![], None, Some(temp_dir.path().to_path_buf()), @@ -549,11 +548,11 @@ mod tests { assert!(file_path.exists()); let content = fs::read_to_string(file_path).unwrap(); if cfg!(windows) { - assert!(content - .contains(r#""run" "http://localhost:4545/cli/tests/subdir/main.ts""#)); + assert!( + content.contains(r#""run" "http://localhost:4545/subdir/main.ts""#) + ); } else { - assert!(content - .contains(r#"run 'http://localhost:4545/cli/tests/subdir/main.ts'"#)); + assert!(content.contains(r#"run 'http://localhost:4545/subdir/main.ts'"#)); } } @@ -565,7 +564,7 @@ mod tests { install( Flags::default(), - "http://localhost:4545/cli/tests/echo_server.ts", + "http://localhost:4545/echo_server.ts", vec![], Some("echo_test".to_string()), Some(temp_dir.path().to_path_buf()), @@ -581,11 +580,11 @@ mod tests { assert!(file_path.exists()); let content = fs::read_to_string(file_path).unwrap(); if cfg!(windows) { - assert!(content - .contains(r#""run" "http://localhost:4545/cli/tests/echo_server.ts""#)); + assert!( + content.contains(r#""run" "http://localhost:4545/echo_server.ts""#) + ); } else { - assert!(content - .contains(r#"run 'http://localhost:4545/cli/tests/echo_server.ts'"#)); + assert!(content.contains(r#"run 'http://localhost:4545/echo_server.ts'"#)); } } @@ -600,7 +599,7 @@ mod tests { install( Flags::default(), - "http://localhost:4545/cli/tests/echo_server.ts", + "http://localhost:4545/echo_server.ts", vec![], Some("echo_test".to_string()), None, @@ -616,11 +615,11 @@ mod tests { assert!(file_path.exists()); let content = fs::read_to_string(file_path).unwrap(); if cfg!(windows) { - assert!(content - .contains(r#""run" "http://localhost:4545/cli/tests/echo_server.ts""#)); + assert!( + content.contains(r#""run" "http://localhost:4545/echo_server.ts""#) + ); } else { - assert!(content - .contains(r#"run 'http://localhost:4545/cli/tests/echo_server.ts'"#)); + assert!(content.contains(r#"run 'http://localhost:4545/echo_server.ts'"#)); } if let Some(install_root) = original_install_root { env::set_var("DENO_INSTALL_ROOT", install_root); @@ -641,7 +640,7 @@ mod tests { log_level: Some(Level::Error), ..Flags::default() }, - "http://localhost:4545/cli/tests/echo_server.ts", + "http://localhost:4545/echo_server.ts", vec!["--foobar".to_string()], Some("echo_test".to_string()), Some(temp_dir.path().to_path_buf()), @@ -657,9 +656,9 @@ mod tests { assert!(file_path.exists()); let content = fs::read_to_string(file_path).unwrap(); if cfg!(windows) { - assert!(content.contains(r#""run" "--allow-read" "--allow-net" "--quiet" "--no-check" "http://localhost:4545/cli/tests/echo_server.ts" "--foobar""#)); + assert!(content.contains(r#""run" "--allow-read" "--allow-net" "--quiet" "--no-check" "http://localhost:4545/echo_server.ts" "--foobar""#)); } else { - assert!(content.contains(r#"run --allow-read --allow-net --quiet --no-check 'http://localhost:4545/cli/tests/echo_server.ts' --foobar"#)); + assert!(content.contains(r#"run --allow-read --allow-net --quiet --no-check 'http://localhost:4545/echo_server.ts' --foobar"#)); } } @@ -700,7 +699,7 @@ mod tests { install( Flags::default(), - "http://localhost:4545/cli/tests/echo_server.ts", + "http://localhost:4545/echo_server.ts", vec![], Some("echo_test".to_string()), Some(temp_dir.path().to_path_buf()), @@ -717,7 +716,7 @@ mod tests { // No force. Install failed. let no_force_result = install( Flags::default(), - "http://localhost:4545/cli/tests/cat.ts", // using a different URL + "http://localhost:4545/cat.ts", // using a different URL vec![], Some("echo_test".to_string()), Some(temp_dir.path().to_path_buf()), @@ -735,7 +734,7 @@ mod tests { // Force. Install success. let force_result = install( Flags::default(), - "http://localhost:4545/cli/tests/cat.ts", // using a different URL + "http://localhost:4545/cat.ts", // using a different URL vec![], Some("echo_test".to_string()), Some(temp_dir.path().to_path_buf()), @@ -762,7 +761,7 @@ mod tests { config_path: Some(config_file_path.to_string_lossy().to_string()), ..Flags::default() }, - "http://localhost:4545/cli/tests/cat.ts", + "http://localhost:4545/cat.ts", vec![], Some("echo_test".to_string()), Some(temp_dir.path().to_path_buf()), @@ -789,7 +788,7 @@ mod tests { install( Flags::default(), - "http://localhost:4545/cli/tests/echo_server.ts", + "http://localhost:4545/echo_server.ts", vec!["\"".to_string()], Some("echo_test".to_string()), Some(temp_dir.path().to_path_buf()), @@ -808,9 +807,9 @@ mod tests { if cfg!(windows) { // TODO: see comment above this test } else { - assert!(content.contains( - r#"run 'http://localhost:4545/cli/tests/echo_server.ts' '"'"# - )); + assert!( + content.contains(r#"run 'http://localhost:4545/echo_server.ts' '"'"#) + ); } } @@ -864,7 +863,7 @@ mod tests { import_map_path: Some(import_map_path.to_string_lossy().to_string()), ..Flags::default() }, - "http://localhost:4545/cli/tests/cat.ts", + "http://localhost:4545/cat.ts", vec![], Some("echo_test".to_string()), Some(temp_dir.path().to_path_buf()), @@ -879,12 +878,12 @@ mod tests { assert!(file_path.exists()); let mut expected_string = format!( - "--import-map '{}' 'http://localhost:4545/cli/tests/cat.ts'", + "--import-map '{}' 'http://localhost:4545/cat.ts'", import_map_url.to_string() ); if cfg!(windows) { expected_string = format!( - "\"--import-map\" \"{}\" \"http://localhost:4545/cli/tests/cat.ts\"", + "\"--import-map\" \"{}\" \"http://localhost:4545/cat.ts\"", import_map_url.to_string() ); } @@ -898,7 +897,7 @@ mod tests { fn install_file_url() { let temp_dir = TempDir::new().expect("tempdir fail"); let bin_dir = temp_dir.path().join("bin"); - let module_path = fs::canonicalize(tests_path().join("cat.ts")).unwrap(); + let module_path = fs::canonicalize(testdata_path().join("cat.ts")).unwrap(); let file_module_string = Url::from_file_path(module_path).unwrap().to_string(); assert!(file_module_string.starts_with("file:///")); diff --git a/cli/tools/test_runner.rs b/cli/tools/test_runner.rs index 106555f7d..b0cf0c845 100644 --- a/cli/tools/test_runner.rs +++ b/cli/tools/test_runner.rs @@ -708,7 +708,7 @@ mod tests { #[test] fn test_collect_test_module_specifiers() { - let test_data_path = test_util::root_path().join("cli/tests/subdir"); + let sub_dir_path = test_util::testdata_path().join("subdir"); let mut matched_urls = collect_test_module_specifiers( vec![ "https://example.com/colors_test.ts".to_string(), @@ -717,12 +717,11 @@ mod tests { "subdir2/mod2.ts".to_string(), "http://example.com/printf_test.ts".to_string(), ], - &test_data_path, + &sub_dir_path, is_supported, ) .unwrap(); - let test_data_url = - Url::from_file_path(test_data_path).unwrap().to_string(); + let test_data_url = Url::from_file_path(sub_dir_path).unwrap().to_string(); let expected: Vec<Url> = vec![ format!("{}/mod1.ts", test_data_url), |