Skip to content

Commit 7cc10ac

Browse files
authored
Merge pull request #42 from Skgland/allow_workspaces
Allow workspaces
2 parents d873727 + 1b1d39e commit 7cc10ac

File tree

7 files changed

+46
-7
lines changed

7 files changed

+46
-7
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55

66
## Unreleased
77

8+
### Changed
9+
10+
- allow workspaces by having validate_manifest now use `metadata --no-deps` instead of deprecated `read-manifest`
11+
therefor no longer failing on workspaces and TomlTweaker no longer removing the workspace table from `Cargo.toml`
12+
13+
814
## [0.10.0] - 2020-08-08
915

1016
### Added

src/prepare.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<'a> Prepare<'a> {
5959
}
6060

6161
let res = Command::new(self.workspace, self.toolchain.cargo())
62-
.args(&["read-manifest", "--manifest-path", "Cargo.toml"])
62+
.args(&["metadata", "--manifest-path", "Cargo.toml", "--no-deps"])
6363
.cd(self.source_dir)
6464
.log_output(false)
6565
.run();
@@ -196,7 +196,7 @@ impl<'a> TomlTweaker<'a> {
196196

197197
self.remove_missing_items("example");
198198
self.remove_missing_items("test");
199-
self.remove_workspaces();
199+
self.remove_parent_workspaces();
200200
self.remove_unwanted_cargo_features();
201201
self.remove_dependencies();
202202
self.apply_patches();
@@ -237,13 +237,9 @@ impl<'a> TomlTweaker<'a> {
237237
}
238238
}
239239

240-
fn remove_workspaces(&mut self) {
240+
fn remove_parent_workspaces(&mut self) {
241241
let krate = self.krate.to_string();
242242

243-
if self.table.remove("workspace").is_some() {
244-
info!("removed workspace from {}", krate);
245-
}
246-
247243
// Eliminate parent workspaces
248244
if let Some(&mut Value::Table(ref mut package)) = self.table.get_mut("package") {
249245
if package.remove("workspace").is_some() {
@@ -467,6 +463,9 @@ mod tests {
467463

468464
[target."cfg(unix)".dependencies]
469465
quux = { version = "1.0" }
466+
467+
[workspace]
468+
members = []
470469
};
471470

472471
let krate = Crate::local("/dev/null".as_ref());

tests/buildtest/crates/cargo-workspace/Cargo.lock

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[workspace]
2+
members = ["world"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "world"
3+
version = "0.1.0"
4+
authors = ["Skgland <[email protected]>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
}

tests/buildtest/mod.rs

+15
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,21 @@ fn test_cargo_config() {
9797
});
9898
}
9999

100+
#[test]
101+
fn test_cargo_workspace() {
102+
runner::run("cargo-workspace", |run| {
103+
run.build(SandboxBuilder::new().enable_networking(false), |build| {
104+
let storage = rustwide::logging::LogStorage::new(LevelFilter::Info);
105+
rustwide::logging::capture(&storage, || -> Result<_, Error> {
106+
build.cargo().args(&["run"]).run()?;
107+
Ok(())
108+
})?;
109+
Ok(())
110+
})?;
111+
Ok(())
112+
});
113+
}
114+
100115
test_prepare_error!(
101116
test_missing_cargotoml,
102117
"missing-cargotoml",

0 commit comments

Comments
 (0)