From a183ff6d776d164516a625b27165032c5d58acf5 Mon Sep 17 00:00:00 2001 From: cat_in_136 Date: Wed, 10 Jul 2024 00:19:43 +0900 Subject: [PATCH 1/2] add binary run test to github workflow --- .github/workflows/rust.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index beae7286..8d979cd5 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -21,7 +21,18 @@ jobs: key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Build run: cargo build --verbose + - name: Run tests run: cargo test --verbose + - name: Run binary for test purpose + shell: bash -xe {0} + run: | + cargo run --profile dev -- --profile dev + test -f target/generate-rpm/cargo-generate-rpm-*.rpm + rm -f target/generate-rpm/cargo-generate-rpm-*.rpm + cargo run --release -- generate-rpm + test -f target/generate-rpm/cargo-generate-rpm-*.rpm + rm -f target/generate-rpm/cargo-generate-rpm-*.rpm + - name: Package run: cargo package From e14547e11f31e4b78ea717e4f2339802b20df052 Mon Sep 17 00:00:00 2001 From: cat_in_136 Date: Tue, 9 Jul 2024 23:38:55 +0900 Subject: [PATCH 2/2] Fixed ai degrade bug where running as a cargo subcommand resulted in an error Parsing processing using the derive API for command line arguments was inappropriate when running as a Cargo subcommand. Changed to properly use the CargoWrapper for parsing. --- src/cli.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index e0391cb9..d9d6ccac 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -91,14 +91,15 @@ pub struct Cli { impl Cli { pub fn get_matches_and_try_parse() -> Result<(Self, ArgMatches), clap::Error> { let mut args = std::env::args(); - let mut matches = if let Some("generate-rpm") = args.nth(1).as_deref() { - ::command().get_matches() + if let Some("generate-rpm") = args.nth(1).as_deref() { + let mut matches = ::command().get_matches(); + let CargoWrapper::GenerateRpm(arg) = CargoWrapper::from_arg_matches_mut(&mut matches)?; + Ok((arg, matches)) } else { - ::command().get_matches() - }; - let arg = Self::from_arg_matches_mut(&mut matches)?; - - Ok((arg, matches)) + let mut matches = ::command().get_matches(); + let arg = Self::from_arg_matches_mut(&mut matches)?; + Ok((arg, matches)) + } } }