From 6e827fce97e739e8b1cabd27edec2b984198aa68 Mon Sep 17 00:00:00 2001 From: Christoph Herzog Date: Thu, 11 May 2023 15:00:16 +0200 Subject: [PATCH] fix: Fix conflicts_with settings in config command Clap 4 requires the conflicting arg name to the Rust name, instead of the user-visible arg name. --- lib/cache/src/filesystem.rs | 2 +- lib/cli-compiler/src/commands/config.rs | 12 ++++++------ lib/cli/src/commands/config.rs | 14 +++++++------- tests/integration/cli/tests/config.rs | 9 ++++----- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/lib/cache/src/filesystem.rs b/lib/cache/src/filesystem.rs index 237390c61cc..97f59212fe3 100644 --- a/lib/cache/src/filesystem.rs +++ b/lib/cache/src/filesystem.rs @@ -103,7 +103,7 @@ impl Cache for FileSystemCache { key.to_string() }; let path = self.path.join(filename); - let ret = Module::deserialize_from_file(engine, path.clone()); + let ret = Module::deserialize_from_file_checked(engine, path.clone()); if ret.is_err() { // If an error occurs while deserializing then we can not trust it anymore // so delete the cache file diff --git a/lib/cli-compiler/src/commands/config.rs b/lib/cli-compiler/src/commands/config.rs index 2137f6e0caa..0826e94212f 100644 --- a/lib/cli-compiler/src/commands/config.rs +++ b/lib/cli-compiler/src/commands/config.rs @@ -8,27 +8,27 @@ use std::path::PathBuf; /// The options for the `wasmer config` subcommand pub struct Config { /// Print the installation prefix. - #[clap(long, conflicts_with = "pkg-config")] + #[clap(long, conflicts_with = "pkg_config")] prefix: bool, /// Directory containing Wasmer executables. - #[clap(long, conflicts_with = "pkg-config")] + #[clap(long, conflicts_with = "pkg_config")] bindir: bool, /// Directory containing Wasmer headers. - #[clap(long, conflicts_with = "pkg-config")] + #[clap(long, conflicts_with = "pkg_config")] includedir: bool, /// Directory containing Wasmer libraries. - #[clap(long, conflicts_with = "pkg-config")] + #[clap(long, conflicts_with = "pkg_config")] libdir: bool, /// Libraries needed to link against Wasmer components. - #[clap(long, conflicts_with = "pkg-config")] + #[clap(long, conflicts_with = "pkg_config")] libs: bool, /// C compiler flags for files that include Wasmer headers. - #[clap(long, conflicts_with = "pkg-config")] + #[clap(long, conflicts_with = "pkg_config")] cflags: bool, /// It outputs the necessary details for compiling diff --git a/lib/cli/src/commands/config.rs b/lib/cli/src/commands/config.rs index 6867acd21d0..70b701448b9 100644 --- a/lib/cli/src/commands/config.rs +++ b/lib/cli/src/commands/config.rs @@ -20,31 +20,31 @@ pub struct Config { #[derive(Debug, Parser)] pub struct Flags { /// Print the installation prefix. - #[clap(long, conflicts_with = "pkg-config")] + #[clap(long, conflicts_with = "pkg_config")] prefix: bool, /// Directory containing Wasmer executables. - #[clap(long, conflicts_with = "pkg-config")] + #[clap(long, conflicts_with = "pkg_config")] bindir: bool, /// Directory containing Wasmer headers. - #[clap(long, conflicts_with = "pkg-config")] + #[clap(long, conflicts_with = "pkg_config")] includedir: bool, /// Directory containing Wasmer libraries. - #[clap(long, conflicts_with = "pkg-config")] + #[clap(long, conflicts_with = "pkg_config")] libdir: bool, /// Libraries needed to link against Wasmer components. - #[clap(long, conflicts_with = "pkg-config")] + #[clap(long, conflicts_with = "pkg_config")] libs: bool, /// C compiler flags for files that include Wasmer headers. - #[clap(long, conflicts_with = "pkg-config")] + #[clap(long, conflicts_with = "pkg_config")] cflags: bool, /// Print the path to the wasmer configuration file where all settings are stored - #[clap(long, conflicts_with = "pkg-config")] + #[clap(long, conflicts_with = "pkg_config")] config_path: bool, /// Outputs the necessary details for compiling diff --git a/tests/integration/cli/tests/config.rs b/tests/integration/cli/tests/config.rs index 21e9f58b2e1..9bbfcb122ce 100644 --- a/tests/integration/cli/tests/config.rs +++ b/tests/integration/cli/tests/config.rs @@ -65,17 +65,16 @@ fn wasmer_config_error() -> anyhow::Result<()> { .map(|s| s.trim().to_string()) .collect::>(); #[cfg(not(windows))] - let expected_1 = "wasmer config --bindir --cflags"; + let expected_1 = "Usage: wasmer config --bindir --cflags"; #[cfg(windows)] - let expected_1 = "wasmer.exe config --bindir --cflags"; + let expected_1 = "Usage: wasmer.exe config --bindir --cflags"; let expected = vec![ - "error: The argument '--bindir' cannot be used with '--pkg-config'", + "error: the argument '--bindir' cannot be used with '--pkg-config'", "", - "USAGE:", expected_1, "", - "For more information try --help", + "For more information, try '--help'.", ]; assert_eq!(lines, expected);