From 8e252a02daa85dd20cc863141a12d9989857888c Mon Sep 17 00:00:00 2001 From: benr-ml <112846738+benr-ml@users.noreply.github.com> Date: Thu, 9 May 2024 17:57:51 +0300 Subject: [PATCH] Run recursively move tests under examples/ (#17600) - Run recursively move tests under examples/ - Update tests ## Description Describe the changes or additions included in this PR. ## Test plan How did you test the new or updated feature? --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: --- crates/sui-framework-tests/src/unit_tests.rs | 25 ++++++++++++------- .../common/sources/identified_payment.move | 4 +-- .../sources/shared_cash_register.move | 5 +--- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/crates/sui-framework-tests/src/unit_tests.rs b/crates/sui-framework-tests/src/unit_tests.rs index 19ec1e6ef1380..d2616b5842bdd 100644 --- a/crates/sui-framework-tests/src/unit_tests.rs +++ b/crates/sui-framework-tests/src/unit_tests.rs @@ -42,7 +42,7 @@ fn run_deepbook_tests() { #[test] #[cfg_attr(msim, ignore)] -fn run_examples_move_unit_tests() { +fn run_sui_programmability_examples_move_unit_tests() { for example in [ "basics", "capy", @@ -65,22 +65,29 @@ fn run_examples_move_unit_tests() { } } +fn check_packages_recursively(path: &PathBuf) -> io::Result<()> { + for entry in fs::read_dir(path).unwrap() { + let entry = entry?; + if entry.path().join("Move.toml").exists() { + check_package_builds(entry.path()); + check_move_unit_tests(entry.path()); + } else if entry.file_type()?.is_dir() { + check_packages_recursively(&entry.path())?; + } + } + Ok(()) +} + #[test] #[cfg_attr(msim, ignore)] -fn run_docs_examples_move_unit_tests() -> io::Result<()> { +fn run_examples_move_unit_tests() -> io::Result<()> { let examples = { let mut buf = PathBuf::from(env!("CARGO_MANIFEST_DIR")); buf.extend(["..", "..", "examples", "move"]); buf }; - for entry in fs::read_dir(examples)? { - let entry = entry?; - if entry.file_type()?.is_dir() && entry.path().join("Move.toml").exists() { - check_package_builds(entry.path()); - check_move_unit_tests(entry.path()); - } - } + check_packages_recursively(&examples)?; Ok(()) } diff --git a/examples/move/transfer-to-object/common/sources/identified_payment.move b/examples/move/transfer-to-object/common/sources/identified_payment.move index 7f200e6dc61a6..91b46c5917800 100644 --- a/examples/move/transfer-to-object/common/sources/identified_payment.move +++ b/examples/move/transfer-to-object/common/sources/identified_payment.move @@ -5,9 +5,7 @@ module common::identified_payment { use sui::sui::SUI; use sui::coin::{Self, Coin}; - use sui::object::{Self, UID}; - use sui::transfer::{Self, Receiving}; - use sui::tx_context::{Self, TxContext}; + use sui::transfer::Receiving; use sui::event; use sui::dynamic_field; diff --git a/examples/move/transfer-to-object/shared-with-tto/sources/shared_cash_register.move b/examples/move/transfer-to-object/shared-with-tto/sources/shared_cash_register.move index fbefd9d50b7ca..f0c876ad97c8c 100644 --- a/examples/move/transfer-to-object/shared-with-tto/sources/shared_cash_register.move +++ b/examples/move/transfer-to-object/shared-with-tto/sources/shared_cash_register.move @@ -5,11 +5,8 @@ module shared_with_tto::shared_cash_register { use common::identified_payment::{Self, IdentifiedPayment, EarmarkedPayment}; use sui::sui::SUI; use sui::coin::Coin; - use sui::object::{Self, UID}; - use sui::transfer::{Self, Receiving}; - use sui::tx_context::{Self, TxContext}; + use sui::transfer::Receiving; use sui::vec_set::{Self, VecSet}; - use std::vector; use std::string::String; const EInvalidOwner: u64 = 0;