summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/integration/upgrade_tests.rs61
-rw-r--r--cli/tools/upgrade.rs5
2 files changed, 65 insertions, 1 deletions
diff --git a/cli/tests/integration/upgrade_tests.rs b/cli/tests/integration/upgrade_tests.rs
index 6eed9e7a1..9b0ad30bd 100644
--- a/cli/tests/integration/upgrade_tests.rs
+++ b/cli/tests/integration/upgrade_tests.rs
@@ -2,8 +2,10 @@
use std::process::Command;
use std::process::Stdio;
+use std::time::Instant;
use test_util as util;
use test_util::TempDir;
+use util::TestContextBuilder;
// Warning: this test requires internet access.
// TODO(#7412): reenable. test is flaky
@@ -192,3 +194,62 @@ fn upgrade_invalid_canary_version() {
util::strip_ansi_codes(&String::from_utf8(output.stderr).unwrap())
);
}
+
+#[test]
+fn upgrade_prompt() {
+ let context = TestContextBuilder::new()
+ .use_http_server()
+ .use_temp_cwd()
+ .env(
+ "DENO_DONT_USE_INTERNAL_BASE_UPGRADE_URL",
+ "http://localhost:4545",
+ )
+ .build();
+ let temp_dir = context.temp_dir();
+ // start a task that goes indefinitely in order to allow
+ // the upgrade check to occur
+ temp_dir.write("main.js", "setInterval(() => {}, 1_000)");
+ let cmd = context
+ .new_command()
+ .args("run --log-level=debug main.js")
+ .env_remove("DENO_NO_UPDATE_CHECK");
+ // run once and wait for the version to be stored
+ cmd.with_pty(|mut pty| {
+ pty.expect("Finished upgrade checker.");
+ });
+ // now check that the upgrade prompt is shown the next time this is run
+ temp_dir.write("main.js", "");
+ cmd.with_pty(|mut pty| {
+ // - We need to use a pty here because the upgrade prompt
+ // doesn't occur except when there's a pty.
+ // - Version comes from the test server.
+ pty.expect(" 99999.99.99 Run `deno upgrade` to install it.");
+ });
+}
+
+#[test]
+fn upgrade_lsp_repl_sleeps() {
+ let context = TestContextBuilder::new()
+ .use_http_server()
+ .use_temp_cwd()
+ .env(
+ "DENO_DONT_USE_INTERNAL_BASE_UPGRADE_URL",
+ "http://localhost:4545/upgrade/sleep",
+ )
+ .build();
+ let start_instant = Instant::now();
+ // ensure this works even though the upgrade check is taking
+ // a long time to complete
+ context
+ .new_command()
+ .args("repl")
+ .env_remove("DENO_NO_UPDATE_CHECK")
+ .with_pty(|mut pty| {
+ pty.write_line("123 + 456\n");
+ pty.expect("579");
+ });
+
+ // the test server will sleep for 45 seconds, so ensure this is less
+ let elapsed_secs = start_instant.elapsed().as_secs();
+ assert!(elapsed_secs < 30, "elapsed_secs: {}", elapsed_secs);
+}
diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs
index c5efa771b..b091c499d 100644
--- a/cli/tools/upgrade.rs
+++ b/cli/tools/upgrade.rs
@@ -263,6 +263,9 @@ pub fn check_for_upgrades(
tokio::time::sleep(UPGRADE_CHECK_FETCH_DELAY).await;
fetch_and_store_latest_version(&env, &version_provider).await;
+
+ // text is used by the test suite
+ log::debug!("Finished upgrade checker.")
});
}
@@ -597,7 +600,7 @@ fn get_url(
}
fn base_upgrade_url() -> Cow<'static, str> {
- // this is used to get the current version
+ // this is used by the test suite
if let Ok(url) = env::var("DENO_DONT_USE_INTERNAL_BASE_UPGRADE_URL") {
Cow::Owned(url)
} else {