feat: with rust workspaces
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-08-07 13:34:58 +02:00
parent 56b44cf2e2
commit b711258790
7 changed files with 179 additions and 2 deletions

View File

@@ -0,0 +1,60 @@
use cargo_metadata::{
camino::{Utf8Path, Utf8PathBuf},
Package,
};
use cuddle_please_release_strategy::RustWorkspaceOptions;
use serde_json::json;
use tracing_test::traced_test;
#[test]
#[traced_test]
fn test_can_read_manifest() {
let temp = tempdir::TempDir::new("test_rust_workspace_can_read_manifest").unwrap();
let temp_path = temp.path();
std::fs::write(
temp_path.join("Cargo.toml"),
r#"
[workspace]
members = [
"nested"
]
[workspace.dependencies]
nested = { path = "nested" }
"#,
)
.unwrap();
std::fs::create_dir_all(temp_path.join("nested")).unwrap();
std::fs::write(
temp_path.join("nested").join("Cargo.toml"),
r#"
[package]
name = "nested"
version = "0.1.0"
edition = "2021"
[dependencies]
nested.workspace = true
"#,
)
.unwrap();
std::fs::create_dir_all(temp_path.join("nested").join("src")).unwrap();
std::fs::write(
temp_path.join("nested").join("src").join("lib.rs"),
r#"
#[test]
test () {}
"#,
)
.unwrap();
let options = RustWorkspaceOptions { lock_step: true };
let members = options.get_workspace(temp_path).unwrap();
assert!(!members.is_empty());
let first = members.first().unwrap();
pretty_assertions::assert_eq!("nested", &first.name);
}