summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/production_surface.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/production_surface.rs b/tests/production_surface.rs
index 1fa855f..5ade95b 100644
--- a/tests/production_surface.rs
+++ b/tests/production_surface.rs
@@ -58,6 +58,31 @@ fn no_production_module_references_the_shim_harness() {
}
#[test]
+fn the_served_index_has_exactly_one_serialization_lock() {
+ // §6 M-5: two mutexes in `publish.rs`, each documented as *the* "one publish
+ // per repo" guarantee, with `withdraw_package` taking only one of them, is
+ // worse than either answer — a reader cannot tell whether the guarantee is
+ // redundant or incomplete. There is one lock now, and this keeps it that way.
+ let src = std::fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join("src/pipeline/publish.rs"))
+ .expect("read publish.rs");
+ let mutexes = src
+ .lines()
+ .filter(|l| l.contains("static") && l.contains("Mutex<"))
+ .collect::<Vec<_>>();
+ assert_eq!(mutexes.len(), 1, "publish.rs must declare exactly one serialization mutex, found {mutexes:?}");
+ assert!(!src.contains("PUBLISH_LOCK"), "the second lock must stay deleted");
+ // And both writers of the served index take it, not just one of them.
+ let acquisitions = src
+ .lines()
+ .filter(|l| l.contains("lock_repo()") && !l.trim_start().starts_with("fn "))
+ .count();
+ assert!(
+ acquisitions >= 2,
+ "publish and withdraw_package must both take the repo lock; found {acquisitions} acquisitions"
+ );
+}
+
+#[test]
fn the_shim_binaries_are_test_only() {
let manifest = std::fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join("Cargo.toml"))
.expect("read Cargo.toml");