6333823236
## Summary This PR changes the definition of `--locked` from: > Produces the same `Lock` To: > Passes `Lock::satisfies` This is a subtle but important difference. Previous, if `Lock::satisfies` failed, we would run a resolution, then do `existing_lock == lock`. If the two weren't equal, and `--locked` was specified, we'd throw an error. The equality check is hard to get right. For example, it means that we can't ship #6076 without changing our marker representation, since the deserialized lockfile "loses" some of the internal marker state that gets accumulated during resolution. The downside of this change is that there could be scenarios in which `uv lock --locked` fails even though the lockfile would actually work and the exact TOML would be unchanged. But... I think it's ok if `--locked` fails after the user modifies something?
88 lines
2.0 KiB
Plaintext
88 lines
2.0 KiB
Plaintext
//! DO NOT EDIT
|
|
//!
|
|
//! Generated with `{{generated_with}}`
|
|
//! Scenarios from <{{generated_from}}>
|
|
//!
|
|
#![cfg(all(feature = "python", feature = "pypi"))]
|
|
#![allow(clippy::needless_raw_string_hashes)]
|
|
|
|
use anyhow::Result;
|
|
use assert_cmd::assert::OutputAssertExt;
|
|
use assert_fs::prelude::*;
|
|
use insta::assert_snapshot;
|
|
|
|
use common::{packse_index_url, TestContext, uv_snapshot};
|
|
|
|
mod common;
|
|
|
|
{{#scenarios}}
|
|
|
|
/// {{description}}
|
|
///
|
|
/// ```text
|
|
/// {{name}}
|
|
{{#tree}}
|
|
/// {{.}}
|
|
{{/tree}}
|
|
/// ```
|
|
#[test]
|
|
fn {{module_name}}() -> Result<()> {
|
|
let context = TestContext::new("{{environment.python}}");
|
|
|
|
// In addition to the standard filters, swap out package names for shorter messages
|
|
let mut filters = context.filters();
|
|
filters.push((r"{{name}}-", "package-"));
|
|
|
|
let pyproject_toml = context.temp_dir.child("pyproject.toml");
|
|
pyproject_toml.write_str(
|
|
r###"
|
|
[project]
|
|
name = "project"
|
|
version = "0.1.0"
|
|
dependencies = [
|
|
{{#root.requires}}
|
|
'''{{requirement}}''',
|
|
{{/root.requires}}
|
|
]
|
|
{{#root.requires_python}}
|
|
requires-python = "{{.}}"
|
|
{{/root.requires_python}}
|
|
"###
|
|
)?;
|
|
|
|
let mut cmd = context.lock();
|
|
cmd.env_remove("UV_EXCLUDE_NEWER");
|
|
cmd.arg("--index-url").arg(packse_index_url());
|
|
{{#expected.explanation}}
|
|
// {{expected.explanation}}
|
|
{{/expected.explanation}}
|
|
uv_snapshot!(filters, cmd, @r###"<snapshot>
|
|
"###
|
|
);
|
|
|
|
{{#expected.satisfiable}}
|
|
let lock = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
|
|
insta::with_settings!({
|
|
filters => filters,
|
|
}, {
|
|
assert_snapshot!(
|
|
lock, @r###"<snapshot>
|
|
"###
|
|
);
|
|
});
|
|
|
|
// Assert the idempotence of `uv lock` when resolving from the lockfile (`--locked`).
|
|
context
|
|
.lock()
|
|
.arg("--locked")
|
|
.env_remove("UV_EXCLUDE_NEWER")
|
|
.arg("--index-url")
|
|
.arg(packse_index_url())
|
|
.assert()
|
|
.success();
|
|
{{/expected.satisfiable}}
|
|
|
|
Ok(())
|
|
}
|
|
{{/scenarios}}
|