1
0
Fork 0
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:
Luca Casonato 2024-09-18 14:08:21 +02:00 committed by GitHub
parent 45b1794778
commit 42e3a49cc7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 237 additions and 189 deletions

View file

@ -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();

View 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"
}
]
}

View 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)

View file

@ -0,0 +1,3 @@
deno [WILDCARD]+[WILDCARD] (canary, release, [WILDCARD])
v8 [WILDCARD]
typescript [WILDCARD]

View 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"
}
]
}

View 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

View file

@ -0,0 +1,3 @@
deno 1.43.2 (release, [WILDCARD])
v8 12.4.254.12
typescript 5.4.5

View 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"
}
]
}

View 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

View file

@ -0,0 +1,3 @@
deno 1.43.2 (release, [WILDCARD])
v8 12.4.254.12
typescript 5.4.5

View 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"
}
]
}

View 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)

View 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

View 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"
}
]
}

View 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

View file

@ -0,0 +1,3 @@
deno 1.43.2 (release, [WILDCARD])
v8 12.4.254.12
typescript 5.4.5

View 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"
}
]
}

View 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)

View file

@ -0,0 +1,3 @@
deno [WILDCARD] (stable, release, [WILDCARD])
v8 [WILDCARD]
typescript [WILDCARD]