summaryrefslogtreecommitdiff
path: root/test_util/src
diff options
context:
space:
mode:
Diffstat (limited to 'test_util/src')
-rw-r--r--test_util/src/builders.rs20
-rw-r--r--test_util/src/lib.rs40
2 files changed, 42 insertions, 18 deletions
diff --git a/test_util/src/builders.rs b/test_util/src/builders.rs
index 769c054bf..17871baa1 100644
--- a/test_util/src/builders.rs
+++ b/test_util/src/builders.rs
@@ -15,7 +15,8 @@ use os_pipe::pipe;
use crate::assertions::assert_wildcard_match;
use crate::deno_exe_path;
-use crate::env_vars_for_npm_tests_no_sync_download;
+use crate::env_vars_for_jsr_tests;
+use crate::env_vars_for_npm_tests;
use crate::fs::PathRef;
use crate::http_server;
use crate::lsp::LspClientBuilder;
@@ -50,6 +51,10 @@ impl TestContextBuilder {
Self::new().use_http_server().add_npm_env_vars()
}
+ pub fn for_jsr() -> Self {
+ Self::new().use_http_server().add_jsr_env_vars()
+ }
+
pub fn temp_dir_path(mut self, path: impl AsRef<Path>) -> Self {
self.temp_dir_path = Some(path.as_ref().to_path_buf());
self
@@ -98,18 +103,17 @@ impl TestContextBuilder {
}
pub fn add_npm_env_vars(mut self) -> Self {
- for (key, value) in env_vars_for_npm_tests_no_sync_download() {
+ for (key, value) in env_vars_for_npm_tests() {
self = self.env(key, value);
}
self
}
- pub fn use_sync_npm_download(self) -> Self {
- self.env(
- // make downloads deterministic
- "DENO_UNSTABLE_NPM_SYNC_DOWNLOAD",
- "1",
- )
+ pub fn add_jsr_env_vars(mut self) -> Self {
+ for (key, value) in env_vars_for_jsr_tests() {
+ self = self.env(key, value);
+ }
+ self
}
pub fn build(&self) -> TestContext {
diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs
index 635520b44..07ed55822 100644
--- a/test_util/src/lib.rs
+++ b/test_util/src/lib.rs
@@ -114,21 +114,18 @@ pub const PERMISSION_DENIED_PATTERN: &str = "PermissionDenied";
static GUARD: Lazy<Mutex<HttpServerCount>> =
Lazy::new(|| Mutex::new(HttpServerCount::default()));
-pub fn env_vars_for_npm_tests_no_sync_download() -> Vec<(String, String)> {
+pub fn env_vars_for_npm_tests() -> Vec<(String, String)> {
vec![
("NPM_CONFIG_REGISTRY".to_string(), npm_registry_url()),
("NO_COLOR".to_string(), "1".to_string()),
]
}
-pub fn env_vars_for_npm_tests() -> Vec<(String, String)> {
- let mut env_vars = env_vars_for_npm_tests_no_sync_download();
- env_vars.push((
- // make downloads deterministic
- "DENO_UNSTABLE_NPM_SYNC_DOWNLOAD".to_string(),
- "1".to_string(),
- ));
- env_vars
+pub fn env_vars_for_jsr_tests() -> Vec<(String, String)> {
+ vec![
+ ("DENO_REGISTRY_URL".to_string(), jsr_registry_url()),
+ ("NO_COLOR".to_string(), "1".to_string()),
+ ]
}
pub fn root_path() -> PathRef {
@@ -168,6 +165,10 @@ pub fn npm_registry_unset_url() -> String {
"http://NPM_CONFIG_REGISTRY.is.unset".to_string()
}
+pub fn jsr_registry_url() -> String {
+ "http://localhost:4545/jsr/registry/".to_string()
+}
+
pub fn std_path() -> PathRef {
root_path().join("test_util").join("std")
}
@@ -2620,6 +2621,21 @@ pub fn wildcard_match_detailed(
))
));
}
+ let actual_next_text = &current_text[max_found_index..];
+ let max_next_text_len = 40;
+ let next_text_len =
+ std::cmp::min(max_next_text_len, actual_next_text.len());
+ output_lines.push(format!(
+ "==== NEXT ACTUAL TEXT ====\n{}{}",
+ colors::red(annotate_whitespace(
+ &actual_next_text[..next_text_len]
+ )),
+ if actual_next_text.len() > max_next_text_len {
+ "[TRUNCATED]"
+ } else {
+ ""
+ },
+ ));
return WildcardMatchResult::Fail(output_lines.join("\n"));
}
}
@@ -2673,9 +2689,13 @@ pub fn wildcard_match_detailed(
colors::green(annotate_whitespace(expected))
));
return WildcardMatchResult::Fail(output_lines.join("\n"));
+ } else {
+ output_lines.push(format!(
+ "<FOUND>{}</FOUND>",
+ colors::gray(annotate_whitespace(expected))
+ ));
}
}
- output_lines.push("# Found matching unordered lines".to_string());
}
}
was_last_wildcard = matches!(part, WildcardPatternPart::Wildcard);