Skip to content

Commit

Permalink
Check idempotence in packse lock scenarios (#5485)
Browse files Browse the repository at this point in the history
Add tests for the instabilities fix.

Part of
#5180 (comment)

Closes #5180
  • Loading branch information
konstin authored Jul 31, 2024
1 parent 38c6033 commit 2247b0f
Show file tree
Hide file tree
Showing 2 changed files with 244 additions and 0 deletions.
232 changes: 232 additions & 0 deletions crates/uv/tests/lock_scenarios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#![allow(clippy::needless_raw_string_hashes)]

use anyhow::Result;
use assert_cmd::assert::OutputAssertExt;
use assert_fs::prelude::*;
use insta::assert_snapshot;

Expand Down Expand Up @@ -108,6 +109,17 @@ fn fork_allows_non_conflicting_non_overlapping_dependencies() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -203,6 +215,17 @@ fn fork_allows_non_conflicting_repeated_dependencies() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -308,6 +331,17 @@ fn fork_basic() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -627,6 +661,17 @@ fn fork_filter_sibling_dependencies() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -766,6 +811,17 @@ fn fork_incomplete_markers() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -885,6 +941,17 @@ fn fork_marker_accrue() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -1112,6 +1179,17 @@ fn fork_marker_inherit_combined_allowed() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -1264,6 +1342,17 @@ fn fork_marker_inherit_combined_disallowed() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -1417,6 +1506,17 @@ fn fork_marker_inherit_combined() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -1544,6 +1644,17 @@ fn fork_marker_inherit_isolated() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -1688,6 +1799,17 @@ fn fork_marker_inherit_transitive() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -1803,6 +1925,17 @@ fn fork_marker_inherit() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -1945,6 +2078,17 @@ fn fork_marker_limited_inherit() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -2072,6 +2216,17 @@ fn fork_marker_selection() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -2222,6 +2377,17 @@ fn fork_marker_track() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -2340,6 +2506,17 @@ fn fork_non_fork_marker_transitive() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -2755,6 +2932,17 @@ fn preferences_dependent_forking() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -2825,6 +3013,17 @@ fn fork_requires_python_full_prerelease() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -2896,6 +3095,17 @@ fn fork_requires_python_full() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -2982,6 +3192,17 @@ fn fork_requires_python_patch_overlap() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}

Expand Down Expand Up @@ -3051,5 +3272,16 @@ fn fork_requires_python() -> Result<()> {
);
});

// Assert the idempotence of `uv lock`
context
.lock()
.env_remove("UV_EXCLUDE_NEWER")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
.assert()
.success();
let lock2 = fs_err::read_to_string(context.temp_dir.join("uv.lock"))?;
assert_eq!(lock2, lock);

Ok(())
}
Loading

0 comments on commit 2247b0f

Please sign in to comment.