1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

chore: provide error message when a deno.json will be auto-discovered by the test suite (#21315)

This commit is contained in:
David Sherret 2023-11-23 14:24:30 -05:00 committed by GitHub
parent d8961a9dfe
commit aadd369589
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 1 deletions

View file

@ -32,6 +32,37 @@ use crate::testdata_path;
use crate::HttpServerGuard;
use crate::TempDir;
// Gives the developer a nice error message if they have a deno configuration
// file that will be auto-discovered by the tests and cause a lot of failures.
static HAS_DENO_JSON_IN_WORKING_DIR_ERR: once_cell::sync::Lazy<Option<String>> =
once_cell::sync::Lazy::new(|| {
let testdata_path = testdata_path();
let mut current_dir = testdata_path.as_path();
let deno_json_names = ["deno.json", "deno.jsonc"];
loop {
for name in deno_json_names {
let deno_json_path = current_dir.join(name);
if deno_json_path.exists() {
return Some(format!(
concat!(
"Found deno configuration file at {}. The test suite relies on ",
"a deno.json not existing in any ancestor directory. Please ",
"delete this file so the tests won't auto-discover it.",
),
deno_json_path.display(),
));
}
}
if let Some(parent) = current_dir.parent() {
current_dir = parent;
} else {
break;
}
}
None
});
#[derive(Default)]
pub struct TestContextBuilder {
use_http_server: bool,
@ -121,6 +152,10 @@ impl TestContextBuilder {
}
pub fn build(&self) -> TestContext {
if let Some(err) = &*HAS_DENO_JSON_IN_WORKING_DIR_ERR {
panic!("{}", err);
}
let temp_dir_path = self
.temp_dir_path
.clone()

View file

@ -45,7 +45,7 @@ impl Pty {
.contains("exit using ctrl+d, ctrl+c, or close()")
},
// it sometimes takes a while to startup on the CI, so use a longer timeout
Duration::from_secs(30),
Duration::from_secs(60),
);
}