diff --git a/tests/integration/upgrade_tests.rs b/tests/integration/upgrade_tests.rs index 0eb468a3fa..5132b4ca5b 100644 --- a/tests/integration/upgrade_tests.rs +++ b/tests/integration/upgrade_tests.rs @@ -5,198 +5,9 @@ use std::process::Stdio; use std::time::Instant; use test_util as util; use test_util::assert_starts_with; -use test_util::TempDir; use test_util::TestContext; use util::TestContextBuilder; -// Warning: this test requires internet access. -// TODO(#7412): reenable. test is flaky -#[test] -#[ignore] -fn upgrade_in_tmpdir() { - let temp_dir = TempDir::new(); - let exe_path = temp_dir.path().join("deno"); - util::deno_exe_path().copy(&exe_path); - assert!(exe_path.exists()); - let _mtime1 = std::fs::metadata(&exe_path).unwrap().modified().unwrap(); - let status = Command::new(&exe_path) - .arg("upgrade") - .arg("--force") - .spawn() - .unwrap() - .wait() - .unwrap(); - assert!(status.success()); - let _mtime2 = std::fs::metadata(&exe_path).unwrap().modified().unwrap(); - // TODO(ry) assert!(mtime1 < mtime2); -} - -// Warning: this test requires internet access. -// TODO(#7412): reenable. test is flaky -#[test] -#[ignore] -fn upgrade_with_space_in_path() { - let temp_dir = TempDir::new_with_prefix("directory with spaces"); - let exe_path = temp_dir.path().join("deno"); - util::deno_exe_path().copy(&exe_path); - assert!(exe_path.exists()); - let status = Command::new(&exe_path) - .arg("upgrade") - .arg("--force") - .env("TMP", temp_dir.path()) - .spawn() - .unwrap() - .wait() - .unwrap(); - assert!(status.success()); -} - -// Warning: this test requires internet access. -// TODO(#7412): reenable. test is flaky -#[test] -#[ignore] -fn upgrade_with_version_in_tmpdir() { - let temp_dir = TempDir::new(); - let exe_path = temp_dir.path().join("deno"); - util::deno_exe_path().copy(&exe_path); - assert!(exe_path.exists()); - let _mtime1 = std::fs::metadata(&exe_path).unwrap().modified().unwrap(); - let status = Command::new(&exe_path) - .arg("upgrade") - .arg("--force") - .arg("--version") - .arg("1.11.5") - .spawn() - .unwrap() - .wait() - .unwrap(); - assert!(status.success()); - let upgraded_deno_version = String::from_utf8( - Command::new(&exe_path).arg("-V").output().unwrap().stdout, - ) - .unwrap(); - assert!(upgraded_deno_version.contains("1.11.5")); - let _mtime2 = std::fs::metadata(&exe_path).unwrap().modified().unwrap(); - // TODO(ry) assert!(mtime1 < mtime2); -} - -// Warning: this test requires internet access. -// TODO(#7412): reenable. test is flaky -#[test] -#[ignore] -fn upgrade_with_canary_in_tmpdir() { - let temp_dir = TempDir::new(); - let exe_path = temp_dir.path().join("deno"); - util::deno_exe_path().copy(&exe_path); - assert!(exe_path.exists()); - let _mtime1 = std::fs::metadata(&exe_path).unwrap().modified().unwrap(); - let status = Command::new(&exe_path) - .arg("upgrade") - .arg("--canary") - .arg("--version") - .arg("e6685f0f01b8a11a5eaff020f5babcfde76b3038") - .spawn() - .unwrap() - .wait() - .unwrap(); - assert!(status.success()); - let upgraded_deno_version = String::from_utf8( - Command::new(&exe_path).arg("-V").output().unwrap().stdout, - ) - .unwrap(); - assert!(upgraded_deno_version.contains("e6685f0")); - let _mtime2 = std::fs::metadata(&exe_path).unwrap().modified().unwrap(); - // TODO(ry) assert!(mtime1 < mtime2); -} - -// Warning: this test requires internet access. -// TODO(#7412): reenable. test is flaky -#[test] -#[ignore] -fn upgrade_with_out_in_tmpdir() { - let temp_dir = TempDir::new(); - let exe_path = temp_dir.path().join("deno"); - let new_exe_path = temp_dir.path().join("foo"); - util::deno_exe_path().copy(&exe_path); - assert!(exe_path.exists()); - let mtime1 = std::fs::metadata(&exe_path).unwrap().modified().unwrap(); - let status = Command::new(&exe_path) - .arg("upgrade") - .arg("--version") - .arg("1.11.5") - .arg("--output") - .arg(&new_exe_path) - .spawn() - .unwrap() - .wait() - .unwrap(); - assert!(status.success()); - assert!(new_exe_path.exists()); - let mtime2 = std::fs::metadata(&exe_path).unwrap().modified().unwrap(); - assert_eq!(mtime1, mtime2); // Original exe_path was not changed. - - let v = String::from_utf8( - Command::new(&new_exe_path) - .arg("-V") - .output() - .unwrap() - .stdout, - ) - .unwrap(); - assert!(v.contains("1.11.5")); -} - -#[flaky_test::flaky_test] -fn upgrade_invalid_stable_version() { - let context = upgrade_context(); - let temp_dir = context.temp_dir(); - let exe_path = temp_dir.path().join("deno"); - util::deno_exe_path().copy(&exe_path); - assert!(exe_path.exists()); - exe_path.mark_executable(); - let output = Command::new(&exe_path) - .arg("upgrade") - .arg("--version") - .arg("foobar") - .stderr(Stdio::piped()) - .spawn() - .unwrap() - .wait_with_output() - .unwrap(); - assert!(!output.status.success()); - assert_starts_with!( - &util::strip_ansi_codes(&String::from_utf8(output.stderr.clone()).unwrap()) - .to_string(), - "error: Invalid version passed (foobar)" - ); -} - -#[flaky_test::flaky_test] -fn upgrade_invalid_canary_version() { - let context = upgrade_context(); - let temp_dir = context.temp_dir(); - let exe_path = temp_dir.path().join("deno"); - util::deno_exe_path().copy(&exe_path); - assert!(exe_path.exists()); - exe_path.mark_executable(); - let output = Command::new(&exe_path) - .arg("upgrade") - .arg("--canary") - .arg("--version") - .arg("foobar") - .stderr(Stdio::piped()) - .spawn() - .unwrap() - .wait_with_output() - .unwrap(); - assert!(!output.status.success()); - assert_starts_with!( - &util::strip_ansi_codes(&String::from_utf8(output.stderr.clone()).unwrap()) - .to_string(), - "error: Invalid commit hash passed (foobar)" - ); -} - #[flaky_test::flaky_test] fn upgrade_invalid_lockfile() { let context = upgrade_context(); diff --git a/tests/specs/upgrade/canary/__test__.jsonc b/tests/specs/upgrade/canary/__test__.jsonc new file mode 100644 index 0000000000..1c4ad0a2d2 --- /dev/null +++ b/tests/specs/upgrade/canary/__test__.jsonc @@ -0,0 +1,23 @@ +{ + "tempDir": true, + "steps": [ + { + "args": "eval Deno.copyFileSync(Deno.execPath(),'./deno_copy');", + "exitCode": 0, + "output": "" + }, + { + "commandName": "./deno_copy", + "args": "upgrade --canary", + "output": "upgrade.out", + "exitCode": 0, + "flaky": true + }, + { + "commandName": "./deno_copy", + "args": "--version", + "exitCode": 0, + "output": "version.out" + } + ] +} diff --git a/tests/specs/upgrade/canary/upgrade.out b/tests/specs/upgrade/canary/upgrade.out new file mode 100644 index 0000000000..07daf03d50 --- /dev/null +++ b/tests/specs/upgrade/canary/upgrade.out @@ -0,0 +1,10 @@ +Current Deno version: [WILDCARD] +Looking up canary version + +Found latest canary version [WILDCARD] + +Downloading https://dl.deno.land/canary/[WILDCARD]/deno-[WILDCARD].zip +Deno is upgrading to version [WILDCARD] + +Upgraded successfully to Deno [WILDCARD] (canary) + diff --git a/tests/specs/upgrade/canary/version.out b/tests/specs/upgrade/canary/version.out new file mode 100644 index 0000000000..0cfbb01c46 --- /dev/null +++ b/tests/specs/upgrade/canary/version.out @@ -0,0 +1,3 @@ +deno [WILDCARD]+[WILDCARD] (canary, release, [WILDCARD]) +v8 [WILDCARD] +typescript [WILDCARD] diff --git a/tests/specs/upgrade/out/__test__.jsonc b/tests/specs/upgrade/out/__test__.jsonc new file mode 100644 index 0000000000..1365ec5630 --- /dev/null +++ b/tests/specs/upgrade/out/__test__.jsonc @@ -0,0 +1,29 @@ +{ + "tempDir": true, + "steps": [ + { + "args": "eval Deno.copyFileSync(Deno.execPath(),'./deno_copy');", + "exitCode": 0, + "output": "" + }, + { + "commandName": "./deno_copy", + "args": "upgrade --force --version 1.43.2 --output ./deno_copy2", + "output": "upgrade.out", + "exitCode": 0, + "flaky": true + }, + { + "commandName": "./deno_copy", + "args": ["eval", "if (Deno.version.deno === '1.43.2') { Deno.exit(1); }"], + "exitCode": 0, + "output": "" + }, + { + "commandName": "./deno_copy2", + "args": "--version", + "exitCode": 0, + "output": "version.out" + } + ] +} diff --git a/tests/specs/upgrade/out/upgrade.out b/tests/specs/upgrade/out/upgrade.out new file mode 100644 index 0000000000..a2b47d0ec8 --- /dev/null +++ b/tests/specs/upgrade/out/upgrade.out @@ -0,0 +1,14 @@ +Current Deno version: [WILDCARD] +Downloading https://github.com/denoland/deno/releases/download/v1.43.2/deno-[WILDCARD].zip +Deno is upgrading to version 1.43.2 + +Upgraded successfully to Deno v1.43.2 (stable) + +Release notes: + + https://github.com/denoland/deno/releases/tag/v1.43.2 + +Blog post: + + https://deno.com/blog/v1.43 + diff --git a/tests/specs/upgrade/out/version.out b/tests/specs/upgrade/out/version.out new file mode 100644 index 0000000000..9ddecf67c2 --- /dev/null +++ b/tests/specs/upgrade/out/version.out @@ -0,0 +1,3 @@ +deno 1.43.2 (release, [WILDCARD]) +v8 12.4.254.12 +typescript 5.4.5 diff --git a/tests/specs/upgrade/space_in_tmp/__test__.jsonc b/tests/specs/upgrade/space_in_tmp/__test__.jsonc new file mode 100644 index 0000000000..f54c0bf833 --- /dev/null +++ b/tests/specs/upgrade/space_in_tmp/__test__.jsonc @@ -0,0 +1,30 @@ +{ + "tempDir": true, + "steps": [ + { + "args": "eval Deno.copyFileSync(Deno.execPath(),'./deno_copy');", + "exitCode": 0, + "output": "" + }, + { + "commandName": "mkdir", + "args": ["space in cwd"], + "exitCode": 0, + "output": "" + }, + { + "commandName": "./deno_copy", + "args": "upgrade --force --version 1.43.2", + "envs": { "TMP": "./space in cwd" }, + "output": "upgrade.out", + "exitCode": 0, + "flaky": true + }, + { + "commandName": "./deno_copy", + "args": "--version", + "exitCode": 0, + "output": "version.out" + } + ] +} diff --git a/tests/specs/upgrade/space_in_tmp/upgrade.out b/tests/specs/upgrade/space_in_tmp/upgrade.out new file mode 100644 index 0000000000..a2b47d0ec8 --- /dev/null +++ b/tests/specs/upgrade/space_in_tmp/upgrade.out @@ -0,0 +1,14 @@ +Current Deno version: [WILDCARD] +Downloading https://github.com/denoland/deno/releases/download/v1.43.2/deno-[WILDCARD].zip +Deno is upgrading to version 1.43.2 + +Upgraded successfully to Deno v1.43.2 (stable) + +Release notes: + + https://github.com/denoland/deno/releases/tag/v1.43.2 + +Blog post: + + https://deno.com/blog/v1.43 + diff --git a/tests/specs/upgrade/space_in_tmp/version.out b/tests/specs/upgrade/space_in_tmp/version.out new file mode 100644 index 0000000000..9ddecf67c2 --- /dev/null +++ b/tests/specs/upgrade/space_in_tmp/version.out @@ -0,0 +1,3 @@ +deno 1.43.2 (release, [WILDCARD]) +v8 12.4.254.12 +typescript 5.4.5 diff --git a/tests/specs/upgrade/specific_canary/__test__.jsonc b/tests/specs/upgrade/specific_canary/__test__.jsonc new file mode 100644 index 0000000000..ea86ee117d --- /dev/null +++ b/tests/specs/upgrade/specific_canary/__test__.jsonc @@ -0,0 +1,23 @@ +{ + "tempDir": true, + "steps": [ + { + "args": "eval Deno.copyFileSync(Deno.execPath(),'./deno_copy');", + "exitCode": 0, + "output": "" + }, + { + "commandName": "./deno_copy", + "args": "upgrade --force --canary --version aaf2bf4bfbf90bed0b6e9812f337f057d1d24f93", + "output": "upgrade.out", + "exitCode": 0, + "flaky": true + }, + { + "commandName": "./deno_copy", + "args": "--version", + "exitCode": 0, + "output": "version.out" + } + ] +} diff --git a/tests/specs/upgrade/specific_canary/upgrade.out b/tests/specs/upgrade/specific_canary/upgrade.out new file mode 100644 index 0000000000..d73116777d --- /dev/null +++ b/tests/specs/upgrade/specific_canary/upgrade.out @@ -0,0 +1,6 @@ +Current Deno version: [WILDCARD] +Downloading https://dl.deno.land/canary/aaf2bf4bfbf90bed0b6e9812f337f057d1d24f93/deno-[WILDCARD].zip +Deno is upgrading to version aaf2bf4bfbf90bed0b6e9812f337f057d1d24f93 + +Upgraded successfully to Deno aaf2bf4bfbf90bed0b6e9812f337f057d1d24f93 (canary) + diff --git a/tests/specs/upgrade/specific_canary/version.out b/tests/specs/upgrade/specific_canary/version.out new file mode 100644 index 0000000000..da474c0449 --- /dev/null +++ b/tests/specs/upgrade/specific_canary/version.out @@ -0,0 +1,3 @@ +deno 2.0.0-rc.2+aaf2bf4 (canary, release, [WILDCARD]) +v8 12.9.202.13-rusty +typescript 5.6.2 diff --git a/tests/specs/upgrade/specific_stable/__test__.jsonc b/tests/specs/upgrade/specific_stable/__test__.jsonc new file mode 100644 index 0000000000..9d8f2bd8af --- /dev/null +++ b/tests/specs/upgrade/specific_stable/__test__.jsonc @@ -0,0 +1,23 @@ +{ + "tempDir": true, + "steps": [ + { + "args": "eval Deno.copyFileSync(Deno.execPath(),'./deno_copy');", + "exitCode": 0, + "output": "" + }, + { + "commandName": "./deno_copy", + "args": "upgrade --force --version 1.43.2", + "output": "upgrade.out", + "exitCode": 0, + "flaky": true + }, + { + "commandName": "./deno_copy", + "args": "--version", + "exitCode": 0, + "output": "version.out" + } + ] +} diff --git a/tests/specs/upgrade/specific_stable/upgrade.out b/tests/specs/upgrade/specific_stable/upgrade.out new file mode 100644 index 0000000000..a2b47d0ec8 --- /dev/null +++ b/tests/specs/upgrade/specific_stable/upgrade.out @@ -0,0 +1,14 @@ +Current Deno version: [WILDCARD] +Downloading https://github.com/denoland/deno/releases/download/v1.43.2/deno-[WILDCARD].zip +Deno is upgrading to version 1.43.2 + +Upgraded successfully to Deno v1.43.2 (stable) + +Release notes: + + https://github.com/denoland/deno/releases/tag/v1.43.2 + +Blog post: + + https://deno.com/blog/v1.43 + diff --git a/tests/specs/upgrade/specific_stable/version.out b/tests/specs/upgrade/specific_stable/version.out new file mode 100644 index 0000000000..9ddecf67c2 --- /dev/null +++ b/tests/specs/upgrade/specific_stable/version.out @@ -0,0 +1,3 @@ +deno 1.43.2 (release, [WILDCARD]) +v8 12.4.254.12 +typescript 5.4.5 diff --git a/tests/specs/upgrade/stable/__test__.jsonc b/tests/specs/upgrade/stable/__test__.jsonc new file mode 100644 index 0000000000..97e2ddb3ce --- /dev/null +++ b/tests/specs/upgrade/stable/__test__.jsonc @@ -0,0 +1,23 @@ +{ + "tempDir": true, + "steps": [ + { + "args": "eval Deno.copyFileSync(Deno.execPath(),'./deno_copy');", + "exitCode": 0, + "output": "" + }, + { + "commandName": "./deno_copy", + "args": "upgrade --force", + "output": "upgrade.out", + "exitCode": 0, + "flaky": true + }, + { + "commandName": "./deno_copy", + "args": "--version", + "exitCode": 0, + "output": "version.out" + } + ] +} diff --git a/tests/specs/upgrade/stable/upgrade.out b/tests/specs/upgrade/stable/upgrade.out new file mode 100644 index 0000000000..3fe8f3ee81 --- /dev/null +++ b/tests/specs/upgrade/stable/upgrade.out @@ -0,0 +1,10 @@ +Current Deno version: [WILDCARD] +Looking up stable version + +Found latest stable version [WILDCARD] + +Downloading https://github.com/denoland/deno/releases/download/[WILDCARD]/deno-[WILDCARD].zip +Deno is upgrading to version [WILDCARD] + +Upgraded successfully to Deno [WILDCARD] (stable) + diff --git a/tests/specs/upgrade/stable/version.out b/tests/specs/upgrade/stable/version.out new file mode 100644 index 0000000000..43b90e51ed --- /dev/null +++ b/tests/specs/upgrade/stable/version.out @@ -0,0 +1,3 @@ +deno [WILDCARD] (stable, release, [WILDCARD]) +v8 [WILDCARD] +typescript [WILDCARD]