From 646e29abb50678e83b3db303715fe9e9d87731e4 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 23 Oct 2024 15:14:02 -0500 Subject: [PATCH] feat(test): Allow setting edition on published packages --- crates/cargo-test-support/src/registry.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/cargo-test-support/src/registry.rs b/crates/cargo-test-support/src/registry.rs index 18a719a6a..207cf74a6 100644 --- a/crates/cargo-test-support/src/registry.rs +++ b/crates/cargo-test-support/src/registry.rs @@ -571,6 +571,7 @@ pub struct Package { local: bool, alternative: bool, invalid_json: bool, + edition: Option, resolver: Option, proc_macro: bool, links: Option, @@ -1251,6 +1252,7 @@ impl Package { local: false, alternative: false, invalid_json: false, + edition: None, resolver: None, proc_macro: false, links: None, @@ -1387,6 +1389,12 @@ impl Package { self } + /// Specifies `package.edition` + pub fn edition(&mut self, edition: &str) -> &mut Package { + self.edition = Some(edition.to_owned()); + self + } + /// Specifies `package.resolver` pub fn resolver(&mut self, resolver: &str) -> &mut Package { self.resolver = Some(resolver.to_owned()); @@ -1581,6 +1589,10 @@ impl Package { manifest.push_str(&format!("rust-version = \"{}\"\n", version)); } + if let Some(edition) = &self.edition { + manifest.push_str(&format!("edition = \"{}\"\n", edition)); + } + if let Some(resolver) = &self.resolver { manifest.push_str(&format!("resolver = \"{}\"\n", resolver)); }