mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
tests: re-enable upgrade tests (#25680)
This commit is contained in:
parent
45b1794778
commit
42e3a49cc7
19 changed files with 237 additions and 189 deletions
|
@ -5,198 +5,9 @@ use std::process::Stdio;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
use test_util::assert_starts_with;
|
use test_util::assert_starts_with;
|
||||||
use test_util::TempDir;
|
|
||||||
use test_util::TestContext;
|
use test_util::TestContext;
|
||||||
use util::TestContextBuilder;
|
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]
|
#[flaky_test::flaky_test]
|
||||||
fn upgrade_invalid_lockfile() {
|
fn upgrade_invalid_lockfile() {
|
||||||
let context = upgrade_context();
|
let context = upgrade_context();
|
||||||
|
|
23
tests/specs/upgrade/canary/__test__.jsonc
Normal file
23
tests/specs/upgrade/canary/__test__.jsonc
Normal file
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
10
tests/specs/upgrade/canary/upgrade.out
Normal file
10
tests/specs/upgrade/canary/upgrade.out
Normal file
|
@ -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)
|
||||||
|
|
3
tests/specs/upgrade/canary/version.out
Normal file
3
tests/specs/upgrade/canary/version.out
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
deno [WILDCARD]+[WILDCARD] (canary, release, [WILDCARD])
|
||||||
|
v8 [WILDCARD]
|
||||||
|
typescript [WILDCARD]
|
29
tests/specs/upgrade/out/__test__.jsonc
Normal file
29
tests/specs/upgrade/out/__test__.jsonc
Normal file
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
14
tests/specs/upgrade/out/upgrade.out
Normal file
14
tests/specs/upgrade/out/upgrade.out
Normal file
|
@ -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
|
||||||
|
|
3
tests/specs/upgrade/out/version.out
Normal file
3
tests/specs/upgrade/out/version.out
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
deno 1.43.2 (release, [WILDCARD])
|
||||||
|
v8 12.4.254.12
|
||||||
|
typescript 5.4.5
|
30
tests/specs/upgrade/space_in_tmp/__test__.jsonc
Normal file
30
tests/specs/upgrade/space_in_tmp/__test__.jsonc
Normal file
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
14
tests/specs/upgrade/space_in_tmp/upgrade.out
Normal file
14
tests/specs/upgrade/space_in_tmp/upgrade.out
Normal file
|
@ -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
|
||||||
|
|
3
tests/specs/upgrade/space_in_tmp/version.out
Normal file
3
tests/specs/upgrade/space_in_tmp/version.out
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
deno 1.43.2 (release, [WILDCARD])
|
||||||
|
v8 12.4.254.12
|
||||||
|
typescript 5.4.5
|
23
tests/specs/upgrade/specific_canary/__test__.jsonc
Normal file
23
tests/specs/upgrade/specific_canary/__test__.jsonc
Normal file
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
6
tests/specs/upgrade/specific_canary/upgrade.out
Normal file
6
tests/specs/upgrade/specific_canary/upgrade.out
Normal file
|
@ -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)
|
||||||
|
|
3
tests/specs/upgrade/specific_canary/version.out
Normal file
3
tests/specs/upgrade/specific_canary/version.out
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
deno 2.0.0-rc.2+aaf2bf4 (canary, release, [WILDCARD])
|
||||||
|
v8 12.9.202.13-rusty
|
||||||
|
typescript 5.6.2
|
23
tests/specs/upgrade/specific_stable/__test__.jsonc
Normal file
23
tests/specs/upgrade/specific_stable/__test__.jsonc
Normal file
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
14
tests/specs/upgrade/specific_stable/upgrade.out
Normal file
14
tests/specs/upgrade/specific_stable/upgrade.out
Normal file
|
@ -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
|
||||||
|
|
3
tests/specs/upgrade/specific_stable/version.out
Normal file
3
tests/specs/upgrade/specific_stable/version.out
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
deno 1.43.2 (release, [WILDCARD])
|
||||||
|
v8 12.4.254.12
|
||||||
|
typescript 5.4.5
|
23
tests/specs/upgrade/stable/__test__.jsonc
Normal file
23
tests/specs/upgrade/stable/__test__.jsonc
Normal file
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
10
tests/specs/upgrade/stable/upgrade.out
Normal file
10
tests/specs/upgrade/stable/upgrade.out
Normal file
|
@ -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)
|
||||||
|
|
3
tests/specs/upgrade/stable/version.out
Normal file
3
tests/specs/upgrade/stable/version.out
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
deno [WILDCARD] (stable, release, [WILDCARD])
|
||||||
|
v8 [WILDCARD]
|
||||||
|
typescript [WILDCARD]
|
Loading…
Reference in a new issue