mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Add a dedicated error for missing RECORD files (#762)
Related to: https://github.com/astral-sh/puffin/issues/716
This commit is contained in:
parent
2d1d6ac0dd
commit
286145bc7f
3 changed files with 74 additions and 2 deletions
|
@ -5,6 +5,7 @@ use assert_cmd::prelude::*;
|
|||
use assert_fs::prelude::*;
|
||||
use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};
|
||||
|
||||
use crate::common::create_venv_py312;
|
||||
use common::{BIN_NAME, INSTA_FILTERS};
|
||||
|
||||
mod common;
|
||||
|
@ -283,6 +284,69 @@ fn uninstall() -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_record() -> Result<()> {
|
||||
let temp_dir = assert_fs::TempDir::new()?;
|
||||
let cache_dir = assert_fs::TempDir::new()?;
|
||||
let venv = create_venv_py312(&temp_dir, &cache_dir);
|
||||
|
||||
let requirements_txt = temp_dir.child("requirements.txt");
|
||||
requirements_txt.touch()?;
|
||||
requirements_txt.write_str("MarkupSafe==2.1.3")?;
|
||||
|
||||
Command::new(get_cargo_bin(BIN_NAME))
|
||||
.arg("pip-sync")
|
||||
.arg("requirements.txt")
|
||||
.arg("--cache-dir")
|
||||
.arg(cache_dir.path())
|
||||
.env("VIRTUAL_ENV", venv.as_os_str())
|
||||
.current_dir(&temp_dir)
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
Command::new(venv.join("bin").join("python"))
|
||||
.arg("-c")
|
||||
.arg("import markupsafe")
|
||||
.current_dir(&temp_dir)
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
// Delete the RECORD file.
|
||||
let dist_info = venv
|
||||
.join("lib")
|
||||
.join("python3.12")
|
||||
.join("site-packages")
|
||||
.join("MarkupSafe-2.1.3.dist-info");
|
||||
std::fs::remove_file(dist_info.join("RECORD"))?;
|
||||
|
||||
let mut filters = INSTA_FILTERS.to_vec();
|
||||
filters.push((
|
||||
"RECORD file not found at: .*/.venv",
|
||||
"RECORD file not found at: [VENV_PATH]",
|
||||
));
|
||||
|
||||
insta::with_settings!({
|
||||
filters => filters,
|
||||
}, {
|
||||
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
|
||||
.arg("pip-uninstall")
|
||||
.arg("MarkupSafe")
|
||||
.arg("--cache-dir")
|
||||
.arg(cache_dir.path())
|
||||
.env("VIRTUAL_ENV", venv.as_os_str())
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: false
|
||||
exit_code: 2
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
error: Cannot uninstall package; RECORD file not found at: [VENV_PATH]/lib/python3.12/site-packages/MarkupSafe-2.1.3.dist-info/RECORD
|
||||
"###);
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uninstall_editable_by_name() -> Result<()> {
|
||||
let temp_dir = assert_fs::TempDir::new()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue