From 391b8112681e936e532b4ae36634a9faec861f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9=20=28WSL=20Win11=20Pro=29?= Date: Thu, 14 Sep 2023 17:51:28 +0100 Subject: [PATCH] Disable `--test` flag with `sui client publish` --- crates/sui/src/client_commands.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/sui/src/client_commands.rs b/crates/sui/src/client_commands.rs index 169f2a01dbb3b..a31105a38d042 100644 --- a/crates/sui/src/client_commands.rs +++ b/crates/sui/src/client_commands.rs @@ -732,6 +732,19 @@ impl SuiClientCommands { serialize_signed_transaction, lint, } => { + if build_config.test_mode { + return Err(SuiError::ModulePublishFailure { + error: format!( + "The `publish` subcommand should not be used with the `--test` flag\n\ + \n\ + Library code in published packages must not depend on test code.\n\ + In order to fix this and publish the package without `--test`, search for, and remove \ + instances of e.g. test modules declared as `friend`s of modules from `sources/`." + ), + } + .into()); + } + let sender = context.try_get_object_owner(&gas).await?; let sender = sender.unwrap_or(context.active_address()?);