mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
TL;DR: cargo clippy|check|... now runs on whole workspace by default. ## Steps - add new workspace member `cloud-hypervisor` - move `./src` to new workspace member - move `./tests` to new workspace member - move relevant parts from Cargo.toml to new workspace member - kept necessary parts in main Cargo.toml, such as profile configurations ## About The main Cargo.toml historically mixes workspace and crate definitions for cloud-hypervisor and ch-remote. This makes it hard to read and requires `--workspace` to run cargo clippy or cargo test on all workspace members, which is counter-intuitive. This patch separates the workspace from the crate definition in the main Cargo.toml file. After this, cargo clippy, cargo test, etc., work on the whole workspace naturally, giving a smoother developer experience. The Cargo.toml without a package definition is also called a virtual workspace or virtual manifest by Cargo [0]. Backporting is not a concern: CHV no longer backports, but the affected files are rarely modified anyway. [0] https://doc.rust-lang.org/cargo/reference/workspaces.html#virtual-workspace Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de> On-behalf-of: SAP philipp.schuster@sap.com
25 lines
624 B
Rust
25 lines
624 B
Rust
// Copyright © 2025 Cyberus Technology GmbH
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
//! Test utilities.
|
|
|
|
use std::cmp::Ordering;
|
|
|
|
use clap::Arg;
|
|
|
|
/// Ensures that all [`Arg`]s are sorted alphabetically.
|
|
pub fn assert_args_sorted<'a, F: Fn() -> R, R: Iterator<Item = &'a Arg>>(get_base_iter: F) {
|
|
let iter = get_base_iter().zip(get_base_iter().skip(1));
|
|
for (arg, next) in iter {
|
|
assert_ne!(
|
|
arg.get_id().cmp(next.get_id()),
|
|
Ordering::Greater,
|
|
"args not alphabetically sorted: arg={}, next={}",
|
|
arg.get_id(),
|
|
next.get_id()
|
|
);
|
|
}
|
|
}
|