diff --git a/Cargo.lock b/Cargo.lock index 9ec667b..a8990d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1487,7 +1487,7 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zepter" -version = "1.3.1" +version = "1.4.0" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 65515be..3c0f407 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zepter" -version = "1.3.1" +version = "1.4.0" edition = "2021" authors = [ "Oliver Tale-Yazdi" ] description = "Analyze, Fix and Format features in your Rust workspace." diff --git a/src/autofix.rs b/src/autofix.rs index ec4ffdd..ad28553 100644 --- a/src/autofix.rs +++ b/src/autofix.rs @@ -9,7 +9,7 @@ use std::{ collections::BTreeMap as Map, path::{Path, PathBuf}, }; -use toml_edit::{table, value, Array, Document, Formatted, InlineTable, Item, Table, Value}; +use toml_edit::{table, value, Array, DocumentMut, Formatted, InlineTable, Item, Table, Value}; #[derive(Debug, clap::Parser)] #[cfg_attr(feature = "testing", derive(Default))] @@ -21,7 +21,7 @@ pub struct AutoFixerArgs { pub struct AutoFixer { pub manifest: Option, - doc: Option, + doc: Option, raw: String, } @@ -29,12 +29,12 @@ impl AutoFixer { pub fn from_manifest>(manifest: P) -> Result { let raw = std::fs::read_to_string(&manifest) .map_err(|e| format!("Failed to read manifest: {e}"))?; - let doc = raw.parse::().map_err(|e| format!("Failed to parse manifest: {e}"))?; + let doc = raw.parse::().map_err(|e| format!("Failed to parse manifest: {e}"))?; Ok(Self { raw, manifest: Some(manifest.as_ref().to_path_buf()), doc: Some(doc) }) } pub fn from_raw(raw: &str) -> Result { - let doc = raw.parse::().map_err(|e| format!("Failed to parse manifest: {e}"))?; + let doc = raw.parse::().map_err(|e| format!("Failed to parse manifest: {e}"))?; Ok(Self { raw: raw.into(), manifest: None, doc: Some(doc) }) } @@ -237,7 +237,7 @@ impl AutoFixer { fn get_all_features(&self) -> Vec { let mut found = Vec::new(); - let doc: &Document = self.doc.as_ref().unwrap(); + let doc: &DocumentMut = self.doc.as_ref().unwrap(); if !doc.contains_table("features") { return found } @@ -251,7 +251,7 @@ impl AutoFixer { } fn get_feature(&self, name: &str) -> Option<&Array> { - let doc: &Document = self.doc.as_ref().unwrap(); + let doc: &DocumentMut = self.doc.as_ref().unwrap(); if !doc.contains_table("features") { return None } @@ -265,7 +265,7 @@ impl AutoFixer { } pub(crate) fn get_feature_mut(&mut self, name: &str) -> Result<&mut Array, ()> { - let doc: &mut Document = self.doc.as_mut().unwrap(); + let doc: &mut DocumentMut = self.doc.as_mut().unwrap(); if !doc.contains_table("features") { return Err(()) } @@ -358,7 +358,7 @@ impl AutoFixer { } pub fn add_feature(&mut self, feature: &str) -> Result<(), String> { - let doc: &mut Document = self.doc.as_mut().unwrap(); + let doc: &mut DocumentMut = self.doc.as_mut().unwrap(); if !doc.contains_table("features") { doc.as_table_mut().insert("features", table()); @@ -375,7 +375,7 @@ impl AutoFixer { /// Add something to a feature. Creates that feature if it does not exist. pub fn add_to_feature(&mut self, feature: &str, v: &str) -> Result<(), String> { - let doc: &mut Document = self.doc.as_mut().unwrap(); + let doc: &mut DocumentMut = self.doc.as_mut().unwrap(); if !doc.contains_table("features") { doc.as_table_mut().insert("features", table()); @@ -454,7 +454,7 @@ impl AutoFixer { default_feats: Option, ) -> Result<(), String> { let kind = crate::kind_to_str(kind); - let doc: &mut Document = self.doc.as_mut().unwrap(); + let doc: &mut DocumentMut = self.doc.as_mut().unwrap(); if !doc.contains_table(kind) { return Ok(()) @@ -520,7 +520,7 @@ impl AutoFixer { ) -> Result<(), String> { // The carrot is implicit in cargo. let version_str = dep_version.to_string().trim_start_matches('^').to_string(); - let doc: &mut Document = self.doc.as_mut().unwrap(); + let doc: &mut DocumentMut = self.doc.as_mut().unwrap(); if !doc.contains_table("workspace") { return Err("No workspace entry found".into()) @@ -578,7 +578,7 @@ impl AutoFixer { } pub fn remove_feature(&mut self, name: &str) { - let doc: &mut Document = self.doc.as_mut().unwrap(); + let doc: &mut DocumentMut = self.doc.as_mut().unwrap(); if !doc.contains_table("features") { return @@ -601,6 +601,26 @@ impl AutoFixer { } } + pub fn disable_default_features(&mut self, dep: &str) -> Result<(), String> { + let doc: &mut DocumentMut = self.doc.as_mut().unwrap(); + + if !doc.contains_table("dependencies") { + return Err("No dependencies entry found".into()) + } + + let deps = doc["dependencies"].as_table_mut().unwrap(); + let Some(dep) = deps.get_mut(dep) else { + return Err(format!("Dependency '{}' not found", dep)) + }; + + if let Some(dep) = dep.as_inline_table_mut() { + dep.insert("default-features", Value::Boolean(Formatted::new(false))); + Ok(()) + } else { + Err(format!("Dependency '{}' is not an inline table", dep)) + } + } + pub fn modified(&self) -> bool { self.doc.as_ref().unwrap().to_string() != self.raw } diff --git a/src/cmd/lint.rs b/src/cmd/lint.rs index ca26056..c954e41 100644 --- a/src/cmd/lint.rs +++ b/src/cmd/lint.rs @@ -3,6 +3,9 @@ //! Lint your feature usage by analyzing crate metadata. +pub mod nostd; +pub use nostd::*; + use crate::{ autofix::*, cmd::{parse_key_val, resolve_dep, RenamedPackage}, @@ -43,6 +46,8 @@ pub enum SubCommand { /// A specific feature is only implied by a specific set of other features. OnlyEnables(OnlyEnablesCmd), WhyEnabled(WhyEnabledCmd), + /// Check the crates for sane no-std feature configuration. + NoStd(NoStdCmd), } #[derive(Debug, clap::Parser)] @@ -272,6 +277,7 @@ impl LintCmd { cmd.run(global); Ok(()) }, + SubCommand::NoStd(cmd) => cmd.run(global), } } } diff --git a/src/cmd/lint/nostd.rs b/src/cmd/lint/nostd.rs new file mode 100644 index 0000000..3adaa06 --- /dev/null +++ b/src/cmd/lint/nostd.rs @@ -0,0 +1,137 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: Oliver Tale-Yazdi + +use std::collections::BTreeMap; +use crate::cmd::{lint::AutoFixer, CargoArgs}; +use crate::cmd::GlobalArgs; +use cargo_metadata::{DependencyKind, Package}; +use crate::cmd::resolve_dep; +use crate::grammar::plural; +use std::collections::btree_map::Entry; +use std::fs::canonicalize; +use crate::log; + +#[derive(Debug, clap::Parser)] +pub struct NoStdCmd { + #[clap(subcommand)] + sub: NoStdSubCmd, +} + +#[derive(Debug, clap::Subcommand)] +pub enum NoStdSubCmd { + /// Default features of no-std dependencies are disabled if the crate itself supports no-std. + #[clap(name = "default-features-of-nostd-dependencies-disabled")] + DefaultFeaturesDisabled(DefaultFeaturesDisabledCmd), +} + +#[derive(Debug, clap::Parser)] +pub struct DefaultFeaturesDisabledCmd { + #[allow(missing_docs)] + #[clap(flatten)] + cargo_args: CargoArgs, + + /// Whether to fix the issues. + #[clap(long, short)] + fix: bool, +} + +impl NoStdCmd { + pub(crate) fn run(&self, global: &GlobalArgs) -> Result<(), String> { + match &self.sub { + NoStdSubCmd::DefaultFeaturesDisabled(cmd) => cmd.run(global), + } + } +} + +impl DefaultFeaturesDisabledCmd { + pub(crate) fn run(&self, _: &GlobalArgs) -> Result<(), String> { + let meta = self.cargo_args.clone().with_workspace(true).load_metadata()?; + let pkgs = &meta.packages; + let mut cache = BTreeMap::new(); + let mut autofixer = BTreeMap::new(); + let mut issues = 0; + // Dir that we are allowed to write to. + let allowed_dir = canonicalize(meta.workspace_root.as_std_path()).unwrap(); + + for lhs in pkgs.iter() { + // check if lhs supports no-std builds + if !Self::supports_nostd(lhs, &mut cache)? { + continue; + } + + for dep in lhs.dependencies.iter() { + if dep.kind != DependencyKind::Normal { + continue; + } + + let Some(rhs) = resolve_dep(lhs, dep, &meta) else { + continue + }; + + if !Self::supports_nostd(&rhs.pkg, &mut cache)? { + continue; + } + + if !dep.uses_default_features { + continue; + } + + println!("Default features not disabled for dependency: {} -> {}", lhs.name, rhs.pkg.name); + + let fixer = match autofixer.entry(lhs.manifest_path.clone()) { + Entry::Occupied(e) => e.into_mut(), + Entry::Vacant(e) => { + let krate_path = canonicalize(lhs.manifest_path.clone().into_std_path_buf()).unwrap(); + + if !krate_path.starts_with(&allowed_dir) { + return Err(format!("Cannot write to path: {}", krate_path.display())) + } + e.insert(AutoFixer::from_manifest(&lhs.manifest_path)?) + }, + }; + + fixer.disable_default_features(&rhs.name())?; + issues += 1; + } + } + + let s = plural(autofixer.len()); + print!("Found {} issue{} in {} crate{s} ", issues, plural(issues), autofixer.len()); + if self.fix { + for (_, fixer) in autofixer.iter_mut() { + fixer.save()?; + } + println!("and fixed all of them."); + Ok(()) + } else { + println!("and fixed none. Re-run with --fix to apply fixes."); + Err(format!("Several issues were not fixed.")) + } + } + + fn supports_nostd(krate: &Package, cache: &mut BTreeMap) -> Result { + log::debug!("Checking if crate supports no-std: {}", krate.name); + if let Some(res) = cache.get(krate.manifest_path.as_str()) { + return Ok(*res) + } + + // try to find the lib.rs + let krate_root = krate.manifest_path.parent().ok_or_else(|| format!("Could not find parent of manifest: {}", krate.manifest_path))?; + let lib_rs = krate_root.join("src/lib.rs"); + + if !lib_rs.exists() { + return Ok(false) + } + let content = std::fs::read_to_string(&lib_rs).map_err(|e| format!("Could not read lib.rs: {}", e))?; + + let ret = if content.contains("#![cfg_attr(not(feature = \"std\"), no_std)]") || content.contains("#![no_std]") { + log::debug!("Crate supports no-std: {} (path={})", krate.name, krate.manifest_path); + true + } else { + false + }; + + cache.insert(krate.manifest_path.as_str().into(), ret); + Ok(ret) + } +} diff --git a/tests/integration/sdk/nostd.yaml b/tests/integration/sdk/nostd.yaml new file mode 100644 index 0000000..32b2b9c --- /dev/null +++ b/tests/integration/sdk/nostd.yaml @@ -0,0 +1,144 @@ +repo: + name: paritytech/polkadot-sdk + ref: 70ab64bd1593dc15e6813de71f8ba280f2fb56f1 +cases: +- cmd: lint no-std default-features-of-nostd-dependencies-disabled + stdout: | + Default features not disabled for dependency: sp-core -> sp-externalities + Default features not disabled for dependency: sp-session -> sp-runtime + Default features not disabled for dependency: sp-consensus-babe -> sp-timestamp + Default features not disabled for dependency: pallet-contracts -> pallet-contracts-proc-macro + Default features not disabled for dependency: pallet-nomination-pools -> pallet-balances + Default features not disabled for dependency: pallet-nomination-pools -> sp-tracing + Default features not disabled for dependency: sp-transaction-storage-proof -> sp-core + Default features not disabled for dependency: sp-transaction-storage-proof -> sp-trie + Default features not disabled for dependency: cumulus-primitives-parachain-inherent -> sp-api + Default features not disabled for dependency: cumulus-primitives-parachain-inherent -> sp-runtime + Default features not disabled for dependency: cumulus-primitives-parachain-inherent -> sp-state-machine + Default features not disabled for dependency: cumulus-primitives-parachain-inherent -> sp-storage + Default features not disabled for dependency: xcm-executor-integration-tests -> frame-system + Default features not disabled for dependency: xcm-executor-integration-tests -> pallet-xcm + Default features not disabled for dependency: xcm-executor-integration-tests -> polkadot-test-runtime + Default features not disabled for dependency: xcm-executor-integration-tests -> sp-state-machine + Default features not disabled for dependency: xcm-executor-integration-tests -> sp-tracing + Default features not disabled for dependency: xcm-executor-integration-tests -> xcm-executor + Default features not disabled for dependency: pallet-root-offences -> sp-runtime + Found 19 issues in 9 crates and fixed none. Re-run with --fix to apply fixes. + stderr: | + Several issues were not fixed. + Error: () + code: 1 +- cmd: lint no-std default-features-of-nostd-dependencies-disabled --fix + stdout: | + Default features not disabled for dependency: sp-core -> sp-externalities + Default features not disabled for dependency: sp-session -> sp-runtime + Default features not disabled for dependency: sp-consensus-babe -> sp-timestamp + Default features not disabled for dependency: pallet-contracts -> pallet-contracts-proc-macro + Default features not disabled for dependency: pallet-nomination-pools -> pallet-balances + Default features not disabled for dependency: pallet-nomination-pools -> sp-tracing + Default features not disabled for dependency: sp-transaction-storage-proof -> sp-core + Default features not disabled for dependency: sp-transaction-storage-proof -> sp-trie + Default features not disabled for dependency: cumulus-primitives-parachain-inherent -> sp-api + Default features not disabled for dependency: cumulus-primitives-parachain-inherent -> sp-runtime + Default features not disabled for dependency: cumulus-primitives-parachain-inherent -> sp-state-machine + Default features not disabled for dependency: cumulus-primitives-parachain-inherent -> sp-storage + Default features not disabled for dependency: xcm-executor-integration-tests -> frame-system + Default features not disabled for dependency: xcm-executor-integration-tests -> pallet-xcm + Default features not disabled for dependency: xcm-executor-integration-tests -> polkadot-test-runtime + Default features not disabled for dependency: xcm-executor-integration-tests -> sp-state-machine + Default features not disabled for dependency: xcm-executor-integration-tests -> sp-tracing + Default features not disabled for dependency: xcm-executor-integration-tests -> xcm-executor + Default features not disabled for dependency: pallet-root-offences -> sp-runtime + Found 19 issues in 9 crates and fixed all of them. + code: 0 + diff: | + diff --git cumulus/primitives/parachain-inherent/Cargo.toml cumulus/primitives/parachain-inherent/Cargo.toml + index ffcc0a47cc..1cfc9e3feb 100644 + --- cumulus/primitives/parachain-inherent/Cargo.toml + +++ cumulus/primitives/parachain-inherent/Cargo.toml + @@ -15 +15 @@ sc-client-api = { path = "../../../substrate/client/api", optional = true} + -sp-api = { path = "../../../substrate/primitives/api", optional = true} + +sp-api = { path = "../../../substrate/primitives/api", optional = true, default-features = false } + @@ -18,2 +18,2 @@ sp-inherents = { path = "../../../substrate/primitives/inherents", default-featu + -sp-runtime = { path = "../../../substrate/primitives/runtime", optional = true} + -sp-state-machine = { path = "../../../substrate/primitives/state-machine", optional = true} + +sp-runtime = { path = "../../../substrate/primitives/runtime", optional = true, default-features = false } + +sp-state-machine = { path = "../../../substrate/primitives/state-machine", optional = true, default-features = false } + @@ -21 +21 @@ sp-std = { path = "../../../substrate/primitives/std", default-features = false} + -sp-storage = { path = "../../../substrate/primitives/storage", optional = true} + +sp-storage = { path = "../../../substrate/primitives/storage", optional = true, default-features = false } + diff --git polkadot/xcm/xcm-executor/integration-tests/Cargo.toml polkadot/xcm/xcm-executor/integration-tests/Cargo.toml + index ecd7096c58..0f49bf3df0 100644 + --- polkadot/xcm/xcm-executor/integration-tests/Cargo.toml + +++ polkadot/xcm/xcm-executor/integration-tests/Cargo.toml + @@ -13 +13 @@ frame-support = { path = "../../../../substrate/frame/support", default-features + -frame-system = { path = "../../../../substrate/frame/system" } + +frame-system = { path = "../../../../substrate/frame/system" , default-features = false } + @@ -15 +15 @@ futures = "0.3.21" + -pallet-xcm = { path = "../../pallet-xcm" } + +pallet-xcm = { path = "../../pallet-xcm" , default-features = false } + @@ -17 +17 @@ polkadot-test-client = { path = "../../../node/test/client" } + -polkadot-test-runtime = { path = "../../../runtime/test-runtime" } + +polkadot-test-runtime = { path = "../../../runtime/test-runtime" , default-features = false } + @@ -22 +22 @@ sp-runtime = { path = "../../../../substrate/primitives/runtime", default-featur + -sp-state-machine = { path = "../../../../substrate/primitives/state-machine" } + +sp-state-machine = { path = "../../../../substrate/primitives/state-machine" , default-features = false } + @@ -24,2 +24,2 @@ xcm = { path = "../..", default-features = false } + -xcm-executor = { path = ".." } + -sp-tracing = { path = "../../../../substrate/primitives/tracing" } + +xcm-executor = { path = ".." , default-features = false } + +sp-tracing = { path = "../../../../substrate/primitives/tracing" , default-features = false } + diff --git substrate/frame/contracts/Cargo.toml substrate/frame/contracts/Cargo.toml + index f1bbe38a87..319fde8486 100644 + --- substrate/frame/contracts/Cargo.toml + +++ substrate/frame/contracts/Cargo.toml + @@ -44 +44 @@ pallet-contracts-primitives = { path = "primitives", default-features = false} + -pallet-contracts-proc-macro = { path = "proc-macro" } + +pallet-contracts-proc-macro = { path = "proc-macro" , default-features = false } + diff --git substrate/frame/nomination-pools/Cargo.toml substrate/frame/nomination-pools/Cargo.toml + index 01e998a521..c074ea3452 100644 + --- substrate/frame/nomination-pools/Cargo.toml + +++ substrate/frame/nomination-pools/Cargo.toml + @@ -30,2 +30,2 @@ log = { version = "0.4.0", default-features = false } + -pallet-balances = { path = "../balances", optional = true } + -sp-tracing = { path = "../../primitives/tracing", optional = true } + +pallet-balances = { path = "../balances", optional = true , default-features = false } + +sp-tracing = { path = "../../primitives/tracing", optional = true , default-features = false } + diff --git substrate/frame/root-offences/Cargo.toml substrate/frame/root-offences/Cargo.toml + index c2df0a79e6..d68fe6ffb9 100644 + --- substrate/frame/root-offences/Cargo.toml + +++ substrate/frame/root-offences/Cargo.toml + @@ -24 +24 @@ frame-system = { path = "../system", default-features = false} + -sp-runtime = { path = "../../primitives/runtime" } + +sp-runtime = { path = "../../primitives/runtime" , default-features = false } + diff --git substrate/primitives/consensus/babe/Cargo.toml substrate/primitives/consensus/babe/Cargo.toml + index efa455b8df..426838503c 100644 + --- substrate/primitives/consensus/babe/Cargo.toml + +++ substrate/primitives/consensus/babe/Cargo.toml + @@ -27 +27 @@ sp-std = { path = "../../std", default-features = false} + -sp-timestamp = { path = "../../timestamp", optional = true} + +sp-timestamp = { path = "../../timestamp", optional = true, default-features = false } + diff --git substrate/primitives/core/Cargo.toml substrate/primitives/core/Cargo.toml + index 12360472a4..343f00e524 100644 + --- substrate/primitives/core/Cargo.toml + +++ substrate/primitives/core/Cargo.toml + @@ -39 +39 @@ sp-storage = { path = "../storage", default-features = false} + -sp-externalities = { path = "../externalities", optional = true} + +sp-externalities = { path = "../externalities", optional = true, default-features = false } + diff --git substrate/primitives/session/Cargo.toml substrate/primitives/session/Cargo.toml + index a4326dab7b..d9442f5dba 100644 + --- substrate/primitives/session/Cargo.toml + +++ substrate/primitives/session/Cargo.toml + @@ -20 +20 @@ sp-core = { path = "../core", default-features = false} + -sp-runtime = { path = "../runtime", optional = true} + +sp-runtime = { path = "../runtime", optional = true, default-features = false } + diff --git substrate/primitives/transaction-storage-proof/Cargo.toml substrate/primitives/transaction-storage-proof/Cargo.toml + index 1683fea254..48c45ebbe3 100644 + --- substrate/primitives/transaction-storage-proof/Cargo.toml + +++ substrate/primitives/transaction-storage-proof/Cargo.toml + @@ -19 +19 @@ scale-info = { version = "2.5.0", default-features = false, features = ["derive" + -sp-core = { path = "../core", optional = true} + +sp-core = { path = "../core", optional = true, default-features = false } + @@ -23 +23 @@ sp-std = { path = "../std", default-features = false} + -sp-trie = { path = "../trie", optional = true} + +sp-trie = { path = "../trie", optional = true, default-features = false } diff --git a/tests/ui/config/v1/basic.yaml b/tests/ui/config/v1/basic.yaml index 895b37b..b7344c6 100644 --- a/tests/ui/config/v1/basic.yaml +++ b/tests/ui/config/v1/basic.yaml @@ -3,25 +3,25 @@ crates: cases: - cmd: run default stdout: | - zepter 1.3.1 + zepter 1.4.0 stderr: | [INFO] Running workflow 'default' [INFO] 1/1 --version - cmd: run stdout: | - zepter 1.3.1 + zepter 1.4.0 stderr: | [INFO] Running workflow 'default' [INFO] 1/1 --version - cmd: '' stdout: | - zepter 1.3.1 + zepter 1.4.0 stderr: | [INFO] Running workflow 'default' [INFO] 1/1 --version - cmd: run my_version stdout: | - zepter 1.3.1 + zepter 1.4.0 stderr: | [INFO] Running workflow 'my_version' [INFO] 1/1 --version @@ -36,7 +36,7 @@ cases: [INFO] 1/1 debug --no-benchmark - cmd: run both stdout: | - zepter 1.3.1 + zepter 1.4.0 Num workspace members: 1 Num dependencies: 1 DAG nodes: 0, links: 0 diff --git a/tests/ui/config/v1/finds_all.yaml b/tests/ui/config/v1/finds_all.yaml index ae10dcd..417296b 100644 --- a/tests/ui/config/v1/finds_all.yaml +++ b/tests/ui/config/v1/finds_all.yaml @@ -3,7 +3,7 @@ crates: cases: - cmd: '' stdout: | - zepter 1.3.1 + zepter 1.4.0 stderr: | [INFO] Running workflow 'default' [INFO] 1/1 --version @@ -19,7 +19,7 @@ cases: - [ '--version' ] - cmd: '' stdout: | - zepter 1.3.1 + zepter 1.4.0 stderr: | [INFO] Running workflow 'default' [INFO] 1/1 --version @@ -35,7 +35,7 @@ cases: - [ '--version' ] - cmd: '' stdout: | - zepter 1.3.1 + zepter 1.4.0 stderr: | [INFO] Running workflow 'default' [INFO] 1/1 --version @@ -51,7 +51,7 @@ cases: - [ '--version' ] - cmd: run default stdout: | - zepter 1.3.1 + zepter 1.4.0 stderr: | [INFO] Running workflow 'default' [INFO] 1/1 --version @@ -67,7 +67,7 @@ cases: - [ '--version' ] - cmd: run default stdout: | - zepter 1.3.1 + zepter 1.4.0 stderr: | [INFO] Running workflow 'default' [INFO] 1/1 --version @@ -83,7 +83,7 @@ cases: - [ '--version' ] - cmd: run default stdout: | - zepter 1.3.1 + zepter 1.4.0 stderr: | [INFO] Running workflow 'default' [INFO] 1/1 --version @@ -99,7 +99,7 @@ cases: - [ '--version' ] - cmd: run default --config .cargo/polkadot.yaml stdout: | - zepter 1.3.1 + zepter 1.4.0 stderr: | [INFO] Running workflow 'default' [INFO] 1/1 --version @@ -115,7 +115,7 @@ cases: - [ '--version' ] - cmd: run default -c .cargo/polkadot.yaml stdout: | - zepter 1.3.1 + zepter 1.4.0 stderr: | [INFO] Running workflow 'default' [INFO] 1/1 --version diff --git a/tests/ui/config/v1/version_bin.yaml b/tests/ui/config/v1/version_bin.yaml index 5566f77..a3681d8 100644 --- a/tests/ui/config/v1/version_bin.yaml +++ b/tests/ui/config/v1/version_bin.yaml @@ -4,7 +4,7 @@ cases: - cmd: run default stderr: | thread 'main' panicked at src/cmd/run.rs:27:46: - Invalid config file: "Config file version is too new. The file requires at least version 2.0.0, but the current version is 1.3.1. Please update Zepter or ignore this check with `--check-cfg-compatibility=off`." + Invalid config file: "Config file version is too new. The file requires at least version 2.0.0, but the current version is 1.4.0. Please update Zepter or ignore this check with `--check-cfg-compatibility=off`." note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace code: 101 - cmd: run default --check-cfg-compatibility=off @@ -13,7 +13,7 @@ cases: stderr: | [INFO] Running workflow 'default' thread 'main' panicked at src/cmd/run.rs:27:46: - Invalid config file: "Config file version is too new. The file requires at least version 2.0.0, but the current version is 1.3.1. Please update Zepter or ignore this check with `--check-cfg-compatibility=off`." + Invalid config file: "Config file version is too new. The file requires at least version 2.0.0, but the current version is 1.4.0. Please update Zepter or ignore this check with `--check-cfg-compatibility=off`." note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace code: 1 configs: diff --git a/tests/ui/root-args/help.yaml b/tests/ui/root-args/help.yaml index 07d1f36..b055084 100644 --- a/tests/ui/root-args/help.yaml +++ b/tests/ui/root-args/help.yaml @@ -3,6 +3,6 @@ cases: - cmd: --help stdout: "Analyze, Fix and Format features in your Rust workspace.\n\nUsage: zepter [OPTIONS] [COMMAND]\n\nCommands:\n trace Trace the dependency path from one crate to another\n lint Lint your feature usage by analyzing crate metadata\n format Format the features in your manifest files\n run \n debug Arguments for how to load cargo metadata from a workspace\n help Print this message or the help of the given subcommand(s)\n\nOptions:\n -q, --quiet\n Only print errors. Supersedes `--log`\n\n --log \n Log level to use\n \n [default: info]\n\n --color\n Use ANSI terminal colors\n\n --exit-code-zero\n Try to exit with code zero if the intended check failed.\n \n Will still return 1 in case of an actual error (eg. failed to find some file) or a panic\n (aka software bug).\n\n --fix-hint \n Dont print any hints on how to fix the error.\n \n This is mostly used internally when dispatching, workflows since they come with their\n hints.\n \n [default: on]\n\n Possible values:\n - on: Prints some hint that is (hopefully) helpful\n - off: Prints no hint at all\n\n -h, --help\n Print help (see a summary with '-h')\n\n -V, --version\n Print version\n" - cmd: lint --help - stdout: "Lint your feature usage by analyzing crate metadata\n\nUsage: zepter lint [OPTIONS] \n\nCommands:\n propagate-feature Check whether features are properly propagated\n never-enables A specific feature never enables a specific other feature\n never-implies A specific feature never implies a specific other feature\n only-enables A specific feature is only implied by a specific set of other features\n why-enabled Arguments for how to load cargo metadata from a workspace\n help Print this message or the help of the given subcommand(s)\n\nOptions:\n -q, --quiet\n Only print errors. Supersedes `--log`\n\n --log \n Log level to use\n \n [default: info]\n\n --color\n Use ANSI terminal colors\n\n --exit-code-zero\n Try to exit with code zero if the intended check failed.\n \n Will still return 1 in case of an actual error (eg. failed to find some file) or a panic\n (aka software bug).\n\n --fix-hint \n Dont print any hints on how to fix the error.\n \n This is mostly used internally when dispatching, workflows since they come with their\n hints.\n \n [default: on]\n\n Possible values:\n - on: Prints some hint that is (hopefully) helpful\n - off: Prints no hint at all\n\n -h, --help\n Print help (see a summary with '-h')\n" + stdout: "Lint your feature usage by analyzing crate metadata\n\nUsage: zepter lint [OPTIONS] \n\nCommands:\n propagate-feature Check whether features are properly propagated\n never-enables A specific feature never enables a specific other feature\n never-implies A specific feature never implies a specific other feature\n only-enables A specific feature is only implied by a specific set of other features\n why-enabled Arguments for how to load cargo metadata from a workspace\n no-std Check the crates for sane no-std feature configuration\n help Print this message or the help of the given subcommand(s)\n\nOptions:\n -q, --quiet\n Only print errors. Supersedes `--log`\n\n --log \n Log level to use\n \n [default: info]\n\n --color\n Use ANSI terminal colors\n\n --exit-code-zero\n Try to exit with code zero if the intended check failed.\n \n Will still return 1 in case of an actual error (eg. failed to find some file) or a panic\n (aka software bug).\n\n --fix-hint \n Dont print any hints on how to fix the error.\n \n This is mostly used internally when dispatching, workflows since they come with their\n hints.\n \n [default: on]\n\n Possible values:\n - on: Prints some hint that is (hopefully) helpful\n - off: Prints no hint at all\n\n -h, --help\n Print help (see a summary with '-h')\n" - cmd: lint propagate-feature --help stdout: "Check whether features are properly propagated\n\nUsage: zepter lint propagate-feature [OPTIONS] --features \n\nOptions:\n --manifest-path \n Cargo manifest path or directory.\n \n For directories it appends a `Cargo.toml`.\n\n --workspace\n Whether to only consider workspace crates\n\n --offline\n Whether to use offline mode\n\n --locked\n Whether to use all the locked dependencies from the `Cargo.lock`.\n \n Otherwise it may update some dependencies. For CI usage its a good idea to use it.\n\n --all-features\n \n\n --features \n The feature to check\n\n -p, --packages [...]\n The packages to check. If empty, all packages are checked\n\n -q, --quiet\n Only print errors. Supersedes `--log`\n\n --feature-enables-dep \n The auto-fixer will enables the feature of the dependencies as non-optional.\n \n This can be used in case that a dependency should not be enabled like `dep?/feature` but\n like `dep/feature` instead. In this case you would pass `--feature-enables-dep\n feature:dep`. The option can be passed multiple times, or multiple key-value pairs can be\n passed at once by separating them with a comma like: `--feature-enables-dep\n feature:dep,feature2:dep2`. (TODO: Duplicate entries are undefined).\n\n --log \n Log level to use\n \n [default: info]\n\n --color\n Use ANSI terminal colors\n\n --left-side-feature-missing \n Overwrite the behaviour when the left side dependency is missing the feature.\n \n This can be used to ignore missing features, treat them as warning or error. A \"missing\n feature\" here means that if `A` has a dependency `B` which has a feature `F`, and the\n propagation is checked then normally it would error if `A` is not forwarding `F` to `B`.\n Now this option modifies the behaviour if `A` does not have the feature in the first place.\n The default behaviour is to require `A` to also have `F`.\n \n [default: fix]\n\n Possible values:\n - ignore: Ignore this behaviour\n - report: Only report but do not fix\n - fix: Fix if `--fix` is passed\n\n --exit-code-zero\n Try to exit with code zero if the intended check failed.\n \n Will still return 1 in case of an actual error (eg. failed to find some file) or a panic\n (aka software bug).\n\n --ignore-missing-propagate \n Ignore single missing links in the feature propagation chain.\n\n --fix-hint \n Dont print any hints on how to fix the error.\n \n This is mostly used internally when dispatching, workflows since they come with their\n hints.\n \n [default: on]\n\n Possible values:\n - on: Prints some hint that is (hopefully) helpful\n - off: Prints no hint at all\n\n --left-side-outside-workspace \n How to handle the case that the LHS is outside the workspace.\n \n [default: fix]\n\n Possible values:\n - ignore: Ignore this behaviour\n - report: Only report but do not fix\n - fix: Fix if `--fix` is passed\n\n --dep-kinds \n How to handle dev-dependencies.\n \n [default: normal:check,dev:check,build:check]\n\n --show-version\n Show crate versions in the output\n\n --show-path\n Show crate manifest paths in the output\n\n --fix\n Try to automatically fix the problems\n\n --modify-paths \n \n\n --fix-dependency \n Fix only issues with this package as dependency\n\n --fix-package \n Fix only issues with this package as feature source\n\n -h, --help\n Print help (see a summary with '-h')\n" diff --git a/tests/ui/root-args/version.yaml b/tests/ui/root-args/version.yaml index 2a0c114..8d15761 100644 --- a/tests/ui/root-args/version.yaml +++ b/tests/ui/root-args/version.yaml @@ -2,7 +2,7 @@ crates: [] cases: - cmd: --version stdout: | - zepter 1.3.1 + zepter 1.4.0 - cmd: -V stdout: | - zepter 1.3.1 + zepter 1.4.0