61 lines
1.3 KiB
Rust
61 lines
1.3 KiB
Rust
|
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);
|
||
|
}
|