diff --git a/.cargo/config.toml b/.cargo/config.toml index 38ed1d83cd..70aeac4add 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,7 +1,14 @@ +# qqq : xxx : explain purpose of each line [env] MODULES_PATH = { value = "module", relative = true } WORKSPACE_PATH = { value = ".", relative = true } [net] # offline = true + +# [build] +# rustdocflags = [ "--cfg", "feature=\"normal_build\"" ] + +# [alias] +# test = "test --doc --features normal_build,enabled" diff --git a/Cargo.toml b/Cargo.toml index d919f94184..1b95384bd0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,7 +80,7 @@ path = "module/alias/std_x" ## data_type [workspace.dependencies.data_type] -version = "~0.12.0" +version = "~0.13.0" path = "module/core/data_type" default-features = false @@ -98,7 +98,7 @@ default-features = false # path = "module/core/type_constructor_derive_pair_meta" [workspace.dependencies.interval_adapter] -version = "~0.27.0" +version = "~0.28.0" path = "module/core/interval_adapter" default-features = false # features = [ "enabled" ] @@ -110,7 +110,7 @@ default-features = false # features = [ "enabled" ] [workspace.dependencies.collection_tools] -version = "~0.15.0" +version = "~0.17.0" path = "module/core/collection_tools" default-features = false @@ -118,31 +118,31 @@ default-features = false ## derive [workspace.dependencies.derive_tools] -version = "~0.32.0" +version = "~0.33.0" path = "module/core/derive_tools" default-features = false # features = [ "enabled" ] [workspace.dependencies.derive_tools_meta] -version = "~0.31.0" +version = "~0.32.0" path = "module/core/derive_tools_meta" default-features = false # features = [ "enabled" ] [workspace.dependencies.reflect_tools] -version = "~0.3.0" +version = "~0.4.0" path = "module/core/reflect_tools" default-features = false # features = [ "enabled" ] [workspace.dependencies.reflect_tools_meta] -version = "~0.3.0" +version = "~0.4.0" path = "module/core/reflect_tools_meta" default-features = false # features = [ "enabled" ] [workspace.dependencies.format_tools] -version = "~0.2.0" +version = "~0.3.0" path = "module/core/format_tools" default-features = false # features = [ "enabled" ] @@ -166,24 +166,24 @@ path = "module/alias/fundamental_data_type" default-features = false [workspace.dependencies.variadic_from] -version = "~0.27.0" +version = "~0.28.0" path = "module/core/variadic_from" default-features = false # features = [ "enabled" ] [workspace.dependencies.clone_dyn] -version = "~0.29.0" +version = "~0.30.0" path = "module/core/clone_dyn" default-features = false # features = [ "enabled" ] [workspace.dependencies.clone_dyn_meta] -version = "~0.27.0" +version = "~0.28.0" path = "module/core/clone_dyn_meta" # features = [ "enabled" ] [workspace.dependencies.clone_dyn_types] -version = "~0.26.0" +version = "~0.28.0" path = "module/core/clone_dyn_types" default-features = false # features = [ "enabled" ] @@ -208,7 +208,7 @@ default-features = false ## iter [workspace.dependencies.iter_tools] -version = "~0.24.0" +version = "~0.26.0" path = "module/core/iter_tools" default-features = false @@ -226,7 +226,7 @@ path = "module/core/for_each" default-features = false [workspace.dependencies.former] -version = "~2.11.0" +version = "~2.12.0" path = "module/core/former" default-features = false @@ -236,12 +236,12 @@ default-features = false # default-features = false [workspace.dependencies.former_meta] -version = "~2.11.0" +version = "~2.12.0" path = "module/core/former_meta" default-features = false [workspace.dependencies.former_types] -version = "~2.12.0" +version = "~2.14.0" path = "module/core/former_types" default-features = false @@ -251,16 +251,16 @@ path = "module/core/impls_index" default-features = false [workspace.dependencies.impls_index_meta] -version = "~0.9.0" +version = "~0.10.0" path = "module/core/impls_index_meta" [workspace.dependencies.mod_interface] -version = "~0.30.0" +version = "~0.31.0" path = "module/core/mod_interface" default-features = false [workspace.dependencies.mod_interface_meta] -version = "~0.29.0" +version = "~0.30.0" path = "module/core/mod_interface_meta" default-features = false @@ -286,7 +286,7 @@ default-features = false ## macro tools [workspace.dependencies.macro_tools] -version = "~0.44.0" +version = "~0.46.0" path = "module/core/macro_tools" default-features = false @@ -317,7 +317,7 @@ path = "module/core/typing_tools" default-features = false [workspace.dependencies.implements] -version = "~0.10.0" +version = "~0.11.0" path = "module/core/implements" default-features = false @@ -327,12 +327,12 @@ path = "module/alias/instance_of" default-features = false [workspace.dependencies.inspect_type] -version = "~0.12.0" +version = "~0.13.0" path = "module/core/inspect_type" default-features = false [workspace.dependencies.is_slice] -version = "~0.11.0" +version = "~0.12.0" path = "module/core/is_slice" default-features = false @@ -340,7 +340,7 @@ default-features = false ## error [workspace.dependencies.error_tools] -version = "~0.19.0" +version = "~0.20.0" path = "module/core/error_tools" default-features = false @@ -374,7 +374,7 @@ path = "module/alias/file_tools" default-features = false [workspace.dependencies.pth] -version = "~0.21.0" +version = "~0.22.0" path = "module/core/pth" default-features = false @@ -387,7 +387,7 @@ default-features = false ## process tools [workspace.dependencies.process_tools] -version = "~0.12.0" +version = "~0.13.0" path = "module/core/process_tools" default-features = false @@ -404,14 +404,14 @@ version = "~0.4.0" path = "module/alias/wtest" [workspace.dependencies.test_tools] -version = "~0.11.0" +version = "~0.12.0" path = "module/core/test_tools" features = [ "full" ] -[workspace.dependencies.test_tools_stable] -package = "test_tools" -version = "~0.10.0" -features = [ "full" ] +# [workspace.dependencies.test_tools_stable] +# package = "test_tools" +# version = "~0.10.0" +# features = [ "full" ] [workspace.dependencies.wtest_basic] version = "~0.4.0" @@ -449,7 +449,7 @@ default-features = false ## ca [workspace.dependencies.wca] -version = "~0.23.0" +version = "~0.24.0" path = "module/move/wca" @@ -463,7 +463,7 @@ path = "module/move/wcensor" ## willbe [workspace.dependencies.willbe] -version = "~0.20.0" +version = "~0.21.0" path = "module/move/willbe" @@ -503,9 +503,17 @@ version = "~0.6.0" path = "module/move/deterministic_rand" [workspace.dependencies.crates_tools] -version = "~0.14.0" +version = "~0.15.0" path = "module/move/crates_tools" +[workspace.dependencies.assistant] +version = "~0.1.0" +path = "module/move/assistant" + +[workspace.dependencies.llm_tools] +version = "~0.2.0" +path = "module/move/llm_tools" + ## steps @@ -555,6 +563,11 @@ version = "~1.0" # features = [] # default-features = false +[workspace.dependencies.pretty_assertions] +version = "~1.4.0" +# features = [] +# default-features = false + [workspace.dependencies.hashbrown] version = "~0.14.3" # optional = true @@ -576,3 +589,6 @@ version = "~0.2" [workspace.dependencies.rand] version = "0.8.5" + +[workspace.dependencies.trybuild] +version = "1.0.85" diff --git a/module/alias/cargo_will/tests/smoke_test.rs b/module/alias/cargo_will/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/alias/cargo_will/tests/smoke_test.rs +++ b/module/alias/cargo_will/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/alias/file_tools/tests/smoke_test.rs b/module/alias/file_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/alias/file_tools/tests/smoke_test.rs +++ b/module/alias/file_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/alias/fundamental_data_type/tests/smoke_test.rs b/module/alias/fundamental_data_type/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/alias/fundamental_data_type/tests/smoke_test.rs +++ b/module/alias/fundamental_data_type/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/alias/instance_of/tests/smoke_test.rs b/module/alias/instance_of/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/alias/instance_of/tests/smoke_test.rs +++ b/module/alias/instance_of/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/alias/multilayer/tests/smoke_test.rs b/module/alias/multilayer/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/alias/multilayer/tests/smoke_test.rs +++ b/module/alias/multilayer/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/alias/proc_macro_tools/tests/smoke_test.rs b/module/alias/proc_macro_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/alias/proc_macro_tools/tests/smoke_test.rs +++ b/module/alias/proc_macro_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/alias/proper_tools/tests/smoke_test.rs b/module/alias/proper_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/alias/proper_tools/tests/smoke_test.rs +++ b/module/alias/proper_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/alias/werror/tests/smoke_test.rs b/module/alias/werror/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/alias/werror/tests/smoke_test.rs +++ b/module/alias/werror/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/alias/willbe2/tests/smoke_test.rs b/module/alias/willbe2/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/alias/willbe2/tests/smoke_test.rs +++ b/module/alias/willbe2/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/alias/wproc_macro/tests/smoke_test.rs b/module/alias/wproc_macro/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/alias/wproc_macro/tests/smoke_test.rs +++ b/module/alias/wproc_macro/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/alias/wstring_tools/tests/smoke_test.rs b/module/alias/wstring_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/alias/wstring_tools/tests/smoke_test.rs +++ b/module/alias/wstring_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/draw_lang/tests/smoke_test.rs b/module/blank/draw_lang/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/draw_lang/tests/smoke_test.rs +++ b/module/blank/draw_lang/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/drawboard/tests/smoke_test.rs b/module/blank/drawboard/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/drawboard/tests/smoke_test.rs +++ b/module/blank/drawboard/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/drawql/tests/smoke_test.rs b/module/blank/drawql/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/drawql/tests/smoke_test.rs +++ b/module/blank/drawql/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/exe_tools/tests/smoke_test.rs b/module/blank/exe_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/exe_tools/tests/smoke_test.rs +++ b/module/blank/exe_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/image_tools/tests/smoke_test.rs b/module/blank/image_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/image_tools/tests/smoke_test.rs +++ b/module/blank/image_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/math_tools/tests/smoke_test.rs b/module/blank/math_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/math_tools/tests/smoke_test.rs +++ b/module/blank/math_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/mindx12/tests/smoke_test.rs b/module/blank/mindx12/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/mindx12/tests/smoke_test.rs +++ b/module/blank/mindx12/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/mingl/tests/smoke_test.rs b/module/blank/mingl/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/mingl/tests/smoke_test.rs +++ b/module/blank/mingl/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/minmetal/tests/smoke_test.rs b/module/blank/minmetal/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/minmetal/tests/smoke_test.rs +++ b/module/blank/minmetal/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/minopengl/tests/smoke_test.rs b/module/blank/minopengl/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/minopengl/tests/smoke_test.rs +++ b/module/blank/minopengl/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/minvulkan/tests/smoke_test.rs b/module/blank/minvulkan/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/minvulkan/tests/smoke_test.rs +++ b/module/blank/minvulkan/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/minwebgl/tests/smoke_test.rs b/module/blank/minwebgl/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/minwebgl/tests/smoke_test.rs +++ b/module/blank/minwebgl/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/minwebgpu/tests/smoke_test.rs b/module/blank/minwebgpu/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/minwebgpu/tests/smoke_test.rs +++ b/module/blank/minwebgpu/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/minwgpu/tests/smoke_test.rs b/module/blank/minwgpu/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/minwgpu/tests/smoke_test.rs +++ b/module/blank/minwgpu/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/rustql/tests/smoke_test.rs b/module/blank/rustql/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/rustql/tests/smoke_test.rs +++ b/module/blank/rustql/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/blank/w4d/tests/smoke_test.rs b/module/blank/w4d/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/blank/w4d/tests/smoke_test.rs +++ b/module/blank/w4d/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/clone_dyn/Cargo.toml b/module/core/clone_dyn/Cargo.toml index 400ba0e1fb..2be1b57e42 100644 --- a/module/core/clone_dyn/Cargo.toml +++ b/module/core/clone_dyn/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clone_dyn" -version = "0.29.0" +version = "0.30.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/clone_dyn/tests/smoke_test.rs b/module/core/clone_dyn/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/clone_dyn/tests/smoke_test.rs +++ b/module/core/clone_dyn/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/clone_dyn_meta/Cargo.toml b/module/core/clone_dyn_meta/Cargo.toml index d77ad96088..09eb717e23 100644 --- a/module/core/clone_dyn_meta/Cargo.toml +++ b/module/core/clone_dyn_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clone_dyn_meta" -version = "0.27.0" +version = "0.28.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/clone_dyn_meta/tests/smoke_test.rs b/module/core/clone_dyn_meta/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/clone_dyn_meta/tests/smoke_test.rs +++ b/module/core/clone_dyn_meta/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/clone_dyn_types/Cargo.toml b/module/core/clone_dyn_types/Cargo.toml index 4a145d0c13..4debc74c8c 100644 --- a/module/core/clone_dyn_types/Cargo.toml +++ b/module/core/clone_dyn_types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clone_dyn_types" -version = "0.26.0" +version = "0.28.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/clone_dyn_types/tests/smoke_test.rs b/module/core/clone_dyn_types/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/clone_dyn_types/tests/smoke_test.rs +++ b/module/core/clone_dyn_types/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/collection_tools/Cargo.toml b/module/core/collection_tools/Cargo.toml index d69009a758..816578bb00 100644 --- a/module/core/collection_tools/Cargo.toml +++ b/module/core/collection_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "collection_tools" -version = "0.15.0" +version = "0.17.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/collection_tools/src/collection/mod.rs b/module/core/collection_tools/src/collection/mod.rs index 22e59e8aae..5508e1263e 100644 --- a/module/core/collection_tools/src/collection/mod.rs +++ b/module/core/collection_tools/src/collection/mod.rs @@ -49,22 +49,10 @@ pub mod own #[ allow( clippy::wildcard_imports ) ] use super::*; - #[ allow( clippy::useless_attribute, clippy::pub_use ) ] - pub use super:: - { - btree_map, - btree_set, - binary_heap, - hash_map, - hash_set, - linked_list, - vector, - vec_deque, - }; - #[ doc( inline ) ] #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use orphan::*; + // xxx2 : check } @@ -96,6 +84,20 @@ pub mod exposed #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use super::super::collection; + #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] + pub use super:: + { + btree_map, + btree_set, + binary_heap, + hash_map, + hash_set, + linked_list, + vector, + vec_deque, + }; + #[ doc( inline ) ] #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] #[ cfg( feature = "collection_constructors" ) ] diff --git a/module/core/collection_tools/tests/inc/mod.rs b/module/core/collection_tools/tests/inc/mod.rs index 86855a9d84..6e7902f291 100644 --- a/module/core/collection_tools/tests/inc/mod.rs +++ b/module/core/collection_tools/tests/inc/mod.rs @@ -1,5 +1,8 @@ use super::*; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + mod bmap; mod bset; mod heap; diff --git a/module/core/collection_tools/tests/smoke_test.rs b/module/core/collection_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/collection_tools/tests/smoke_test.rs +++ b/module/core/collection_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/collection_tools/tests/tests.rs b/module/core/collection_tools/tests/tests.rs index ecc936c445..ec7c6d3063 100644 --- a/module/core/collection_tools/tests/tests.rs +++ b/module/core/collection_tools/tests/tests.rs @@ -1,10 +1,12 @@ +//! All tests. + #![ allow( unused_imports ) ] #[ path="../../../../module/step/meta/src/module/aggregating.rs" ] mod aggregating; -#[ allow( unused_imports ) ] -use test_tools::exposed::*; +// #[ allow( unused_imports ) ] +// use test_tools::exposed::*; #[ allow( unused_imports ) ] use ::collection_tools as the_module; diff --git a/module/core/data_type/Cargo.toml b/module/core/data_type/Cargo.toml index c5f7155d97..91971e6b8e 100644 --- a/module/core/data_type/Cargo.toml +++ b/module/core/data_type/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "data_type" -version = "0.12.0" +version = "0.13.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/data_type/tests/smoke_test.rs b/module/core/data_type/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/data_type/tests/smoke_test.rs +++ b/module/core/data_type/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/derive_tools/Cargo.toml b/module/core/derive_tools/Cargo.toml index a2d1e31fb4..ed323a7b1e 100644 --- a/module/core/derive_tools/Cargo.toml +++ b/module/core/derive_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "derive_tools" -version = "0.32.0" +version = "0.33.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/derive_tools/tests/smoke_test.rs b/module/core/derive_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/derive_tools/tests/smoke_test.rs +++ b/module/core/derive_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/derive_tools_meta/Cargo.toml b/module/core/derive_tools_meta/Cargo.toml index ce3e0ce395..5e3804d996 100644 --- a/module/core/derive_tools_meta/Cargo.toml +++ b/module/core/derive_tools_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "derive_tools_meta" -version = "0.31.0" +version = "0.32.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/diagnostics_tools/Cargo.toml b/module/core/diagnostics_tools/Cargo.toml index 6b48adc190..6103e7fb9c 100644 --- a/module/core/diagnostics_tools/Cargo.toml +++ b/module/core/diagnostics_tools/Cargo.toml @@ -43,12 +43,12 @@ no_std = [] use_alloc = [ "no_std" ] enabled = [] -diagnostics_runtime_assertions = [ "pretty_assertions" ] # run-time assertions +diagnostics_runtime_assertions = [ "dep:pretty_assertions" ] # run-time assertions diagnostics_compiletime_assertions = [] # compile-time assertions diagnostics_memory_layout = [] # [dependencies] -pretty_assertions = { version = "~1.4.0", optional = true } +pretty_assertions = { workspace = true, optional = true } [dev-dependencies] test_tools = { workspace = true } diff --git a/module/core/diagnostics_tools/tests/diagnostics_tests.rs b/module/core/diagnostics_tools/tests/all_tests.rs similarity index 61% rename from module/core/diagnostics_tools/tests/diagnostics_tests.rs rename to module/core/diagnostics_tools/tests/all_tests.rs index 46138a3acb..cce190c203 100644 --- a/module/core/diagnostics_tools/tests/diagnostics_tests.rs +++ b/module/core/diagnostics_tools/tests/all_tests.rs @@ -1,3 +1,5 @@ +//! All tests. + // #![ deny( rust_2018_idioms ) ] // #![ deny( missing_debug_implementations ) ] // #![ deny( missing_docs ) ] @@ -5,11 +7,9 @@ // #![ cfg_attr( feature = "type_name_of_val", feature( type_name_of_val ) ) ] // #![ feature( trace_macros ) ] -#[ allow( unused_imports ) ] -use diagnostics_tools as the_module; -#[ allow( unused_imports ) ] -use test_tools::exposed::*; -// #[ path="../../../../module/step/meta/src/module/terminal.rs" ] -// mod terminal; +#![ allow( unused_imports ) ] +#[ path="../../../../module/step/meta/src/module/terminal.rs" ] +mod terminal; +use diagnostics_tools as the_module; mod inc; diff --git a/module/core/diagnostics_tools/tests/inc/layout_test.rs b/module/core/diagnostics_tools/tests/inc/layout_test.rs index 37cd393f46..c0b92f743f 100644 --- a/module/core/diagnostics_tools/tests/inc/layout_test.rs +++ b/module/core/diagnostics_tools/tests/inc/layout_test.rs @@ -64,10 +64,9 @@ tests_impls! } -#[ path = "../../../../step/meta/src/module/aggregating.rs" ] -mod aggregating; - -use crate::only_for_terminal_module; +// #[ path = "../../../../step/meta/src/module/aggregating.rs" ] +// mod aggregating; +// use crate::only_for_terminal_module; only_for_terminal_module! { diff --git a/module/core/diagnostics_tools/tests/inc/mod.rs b/module/core/diagnostics_tools/tests/inc/mod.rs index 68dc070886..4016c1dc8a 100644 --- a/module/core/diagnostics_tools/tests/inc/mod.rs +++ b/module/core/diagnostics_tools/tests/inc/mod.rs @@ -1,4 +1,5 @@ use super::*; +use test_tools::exposed::*; #[ cfg( any( feature = "diagnostics_runtime_assertions", feature = "diagnostics_runtime_assertions" ) ) ] mod cta_test; diff --git a/module/core/diagnostics_tools/tests/smoke_test.rs b/module/core/diagnostics_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/diagnostics_tools/tests/smoke_test.rs +++ b/module/core/diagnostics_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/error_tools/Cargo.toml b/module/core/error_tools/Cargo.toml index dafae99166..670b1fd2b5 100644 --- a/module/core/error_tools/Cargo.toml +++ b/module/core/error_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "error_tools" -version = "0.19.0" +version = "0.20.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/error_tools/src/error/mod.rs b/module/core/error_tools/src/error/mod.rs index 9c22df98c3..46d48b7c35 100644 --- a/module/core/error_tools/src/error/mod.rs +++ b/module/core/error_tools/src/error/mod.rs @@ -26,9 +26,9 @@ mod private /// /// A `Result` of type `ReportOk` if the original result is `Ok`, or a tuple `(ReportErr, E)` containing the additional /// context and the original error if the original result is `Err`. - /// + /// /// # Errors - /// + /// /// qqq: errors /// /// # Example @@ -55,9 +55,9 @@ mod private /// /// A `Result` of type `ReportOk` if the original result is `Ok`, or a tuple `(ReportErr, E)` containing the additional /// context and the original error if the original result is `Err`. - /// + /// /// # Errors - /// + /// /// qqq: Errors /// /// # Example diff --git a/module/core/error_tools/src/error/untyped.rs b/module/core/error_tools/src/error/untyped.rs index d4d65afe67..8a57019dc0 100644 --- a/module/core/error_tools/src/error/untyped.rs +++ b/module/core/error_tools/src/error/untyped.rs @@ -43,6 +43,7 @@ pub mod orphan { #[ allow( clippy::wildcard_imports ) ] use super::*; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use super::super::untyped; #[ allow( clippy::useless_attribute, clippy::pub_use ) ] diff --git a/module/core/error_tools/tests/inc/err_with_test.rs b/module/core/error_tools/tests/inc/err_with_test.rs index 7b3a65516f..3e50ac7d08 100644 --- a/module/core/error_tools/tests/inc/err_with_test.rs +++ b/module/core/error_tools/tests/inc/err_with_test.rs @@ -20,7 +20,7 @@ fn err_with() fn err_with_report() { - use error_tools::ErrWith; + use the_module::ErrWith; let result : Result< (), std::io::Error > = Err( std::io::Error::new( std::io::ErrorKind::Other, "an error occurred" ) ); let report = "additional context"; let got : Result< (), ( &str, std::io::Error ) > = result.err_with_report( &report ); diff --git a/module/core/error_tools/tests/inc/mod.rs b/module/core/error_tools/tests/inc/mod.rs index dc239e680e..5e78c0b4c1 100644 --- a/module/core/error_tools/tests/inc/mod.rs +++ b/module/core/error_tools/tests/inc/mod.rs @@ -1,6 +1,8 @@ #[ allow( unused_imports ) ] use super::*; +use test_tools::exposed::*; + mod basic_test; mod namespace_test; diff --git a/module/core/error_tools/tests/inc/untyped_test.rs b/module/core/error_tools/tests/inc/untyped_test.rs index f1db8e77a9..6e92b663e7 100644 --- a/module/core/error_tools/tests/inc/untyped_test.rs +++ b/module/core/error_tools/tests/inc/untyped_test.rs @@ -10,8 +10,8 @@ tests_impls! { // test.case( "from parse usize error" ); - let err = the_module::untyped::format_err!( "err" ); - a_id!( the_module::untyped::Error::is::< &str >( &err ), true ); + let err = the_module::error::untyped::format_err!( "err" ); + a_id!( the_module::error::untyped::Error::is::< &str >( &err ), true ); a_id!( err.is::< &str >(), true ); a_id!( err.to_string(), "err" ); } diff --git a/module/core/error_tools/tests/smoke_test.rs b/module/core/error_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/error_tools/tests/smoke_test.rs +++ b/module/core/error_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/error_tools/tests/tests.rs b/module/core/error_tools/tests/tests.rs index f217bd0119..4feacbc8fb 100644 --- a/module/core/error_tools/tests/tests.rs +++ b/module/core/error_tools/tests/tests.rs @@ -1,6 +1,8 @@ +//! All tests. + #![ allow( unused_imports ) ] use error_tools as the_module; -use test_tools::exposed::*; +// use test_tools::exposed::*; mod inc; diff --git a/module/core/for_each/tests/smoke_test.rs b/module/core/for_each/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/for_each/tests/smoke_test.rs +++ b/module/core/for_each/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/format_tools/Cargo.toml b/module/core/format_tools/Cargo.toml index 8cd8b79c01..2f29469253 100644 --- a/module/core/format_tools/Cargo.toml +++ b/module/core/format_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "format_tools" -version = "0.2.0" +version = "0.3.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/former/Cargo.toml b/module/core/former/Cargo.toml index df2a419b2b..7c5efd5073 100644 --- a/module/core/former/Cargo.toml +++ b/module/core/former/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "former" -version = "2.11.0" +version = "2.12.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -63,7 +63,6 @@ former_meta = { workspace = true } former_types = { workspace = true } # collection_tools = { workspace = true, features = [ "collection_constructors" ] } - [dev-dependencies] test_tools = { workspace = true } collection_tools = { workspace = true, features = [ "collection_constructors" ] } diff --git a/module/core/former/examples/former_custom_collection.rs b/module/core/former/examples/former_custom_collection.rs index a3b1e1b667..1f275425d3 100644 --- a/module/core/former/examples/former_custom_collection.rs +++ b/module/core/former/examples/former_custom_collection.rs @@ -44,7 +44,7 @@ fn main() K : core::cmp::Eq + std::hash::Hash, { type Item = K; - type IntoIter = collection_tools::hset::IntoIter< K >; + type IntoIter = collection_tools::hash_set::IntoIter< K >; fn into_iter( self ) -> Self::IntoIter { @@ -58,7 +58,7 @@ fn main() K : core::cmp::Eq + std::hash::Hash, { type Item = &'a K; - type IntoIter = collection_tools::hset::Iter< 'a, K >; + type IntoIter = collection_tools::hash_set::Iter< 'a, K >; fn into_iter( self ) -> Self::IntoIter { diff --git a/module/core/former/tests/experimental.rs b/module/core/former/tests/experimental.rs index fe640ab353..9713734b7b 100644 --- a/module/core/former/tests/experimental.rs +++ b/module/core/former/tests/experimental.rs @@ -1,9 +1,8 @@ +//! For experimenting. +#![ allow( unused_imports ) ] include!( "../../../../module/step/meta/src/module/terminal.rs" ); -#[ allow( unused_imports ) ] -use test_tools::exposed::*; -#[ allow( unused_imports ) ] use former as the_module; // #[ path = "./inc/components_composite.rs" ] diff --git a/module/core/former/tests/inc/former_tests/attribute_feature.rs b/module/core/former/tests/inc/former_tests/attribute_feature.rs index 20dea37cf8..937e0f36cc 100644 --- a/module/core/former/tests/inc/former_tests/attribute_feature.rs +++ b/module/core/former/tests/inc/former_tests/attribute_feature.rs @@ -1,4 +1,5 @@ -#[ allow( unused_imports ) ] +#![ allow( unexpected_cfgs ) ] + use super::*; #[ derive( Debug, PartialEq ) ] diff --git a/module/core/former/tests/inc/former_tests/parametrized_dyn.rs b/module/core/former/tests/inc/former_tests/parametrized_dyn.rs index 813f06f165..04006d88c7 100644 --- a/module/core/former/tests/inc/former_tests/parametrized_dyn.rs +++ b/module/core/former/tests/inc/former_tests/parametrized_dyn.rs @@ -1,405 +1,412 @@ -use super::*; - -pub trait FilterCol : fmt::Debug -{ - fn filter_col( &self, key : &str ) -> bool; -} - -#[ derive( Debug, Default, PartialEq, Clone, Copy ) ] -pub struct All; - -impl All -{ - pub fn instance() -> & 'static dyn FilterCol - { - static INSTANCE : All = All; - &INSTANCE - } -} - -impl Default for &'static dyn FilterCol -{ - #[ inline( always ) ] - fn default() -> Self - { - All::instance() - } -} - -impl FilterCol for All -{ - #[ inline( always ) ] - fn filter_col( &self, _key : &str ) -> bool - { - true - } -} - -#[ derive( Default ) ] -// #[ derive( former::Former ) ] // xxx : qqq : uncomment and fix problem with lifetime -// #[ derive( former::Former ) ] #[ debug ] -pub struct Styles< 'callback > -{ - - // pub output_format : &'static dyn AsRef< str >, - pub filter : &'callback dyn FilterCol, - -} - -// === begin_coercing of generated - -#[automatically_derived] -impl< 'callback > Styles< 'callback > where -{ - #[doc = r""] - #[doc = r" Provides a mechanism to initiate the formation process with a default completion behavior."] - #[doc = r""] - #[inline(always)] - pub fn former() -> StylesFormer< 'callback, StylesFormerDefinition< 'callback, (), Styles< 'callback >, former::ReturnPreformed > > - { - StylesFormer::< 'callback, StylesFormerDefinition< 'callback, (), Styles< 'callback >, former::ReturnPreformed > >::new_coercing(former::ReturnPreformed) - } -} - -impl< 'callback, Definition > former::EntityToFormer< Definition > for Styles< 'callback > -where - Definition : former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, -{ - type Former = StylesFormer< 'callback, Definition >; -} - -impl< 'callback > former::EntityToStorage for Styles< 'callback > -where -{ - type Storage = StylesFormerStorage< 'callback >; -} - -impl< 'callback, __Context, __Formed, __End > former::EntityToDefinition< __Context, __Formed, __End > for Styles< 'callback > -where - __End : former::FormingEnd< StylesFormerDefinitionTypes< 'callback, __Context, __Formed > >, -{ - type Definition = StylesFormerDefinition< 'callback, __Context, __Formed, __End >; - type Types = StylesFormerDefinitionTypes< 'callback, __Context, __Formed >; -} - -impl< 'callback, __Context, __Formed > former::EntityToDefinitionTypes< __Context, __Formed > for Styles< 'callback > -where -{ - type Types = StylesFormerDefinitionTypes< 'callback, __Context, __Formed >; -} - -#[doc = r" Defines the generic parameters for formation behavior including context, form, and end conditions."] -#[derive(Debug)] -pub struct StylesFormerDefinitionTypes< 'callback, __Context = (), __Formed = Styles< 'callback > > -where -{ - _phantom: ::core::marker::PhantomData< ( & 'callback (), * const __Context, * const __Formed ) >, -} - -impl< 'callback, __Context, __Formed > ::core::default::Default for StylesFormerDefinitionTypes< 'callback, __Context, __Formed > -where -{ - fn default() -> Self - { - Self { _phantom: ::core::marker::PhantomData } - } -} - -impl< 'callback, __Context, __Formed > former::FormerDefinitionTypes for StylesFormerDefinitionTypes< 'callback, __Context, __Formed > -where -{ - type Storage = StylesFormerStorage< 'callback >; - type Formed = __Formed; - type Context = __Context; -} - -#[doc = r" Holds the definition types used during the formation process."] -#[derive(Debug)] -pub struct StylesFormerDefinition< 'callback, __Context = (), __Formed = Styles< 'callback >, __End = former::ReturnPreformed > -where -{ - _phantom: ::core::marker::PhantomData< ( & 'callback (), * const __Context, * const __Formed, * const __End ) >, -} - -impl< 'callback, __Context, __Formed, __End > ::core::default::Default for StylesFormerDefinition< 'callback, __Context, __Formed, __End > -where -{ - fn default() -> Self - { - Self { _phantom: ::core::marker::PhantomData } - } -} - -impl< 'callback, __Context, __Formed, __End > former::FormerDefinition for StylesFormerDefinition< 'callback, __Context, __Formed, __End > -where - __End : former::FormingEnd< StylesFormerDefinitionTypes< 'callback, __Context, __Formed > >, -{ - type Types = StylesFormerDefinitionTypes< 'callback, __Context, __Formed >; - type End = __End; - type Storage = StylesFormerStorage< 'callback >; - type Formed = __Formed; - type Context = __Context; -} - -impl< 'callback, __Context, __Formed > former::FormerMutator for StylesFormerDefinitionTypes< 'callback, __Context, __Formed > -where -{} - -#[doc = "Stores potential values for fields during the formation process."] -#[allow(explicit_outlives_requirements)] -pub struct StylesFormerStorage< 'callback > -where -{ - #[doc = r" A field"] - pub filter: ::core::option::Option< & 'callback dyn FilterCol >, -} - -impl< 'callback > ::core::default::Default for StylesFormerStorage< 'callback > -where -{ - #[inline(always)] - fn default() -> Self - { - Self { filter: ::core::option::Option::None } - } -} - -impl< 'callback > former::Storage for StylesFormerStorage< 'callback > -where -{ - type Preformed = Styles< 'callback >; -} - -impl< 'callback > former::StoragePreform for StylesFormerStorage< 'callback > -where -{ - fn preform(mut self) -> Self::Preformed - { - let filter = if self.filter.is_some() - { - self.filter.take().unwrap() - } - else - { - { - trait MaybeDefault - { - fn maybe_default(self: &Self) -> T - { - panic!("Field 'filter' isn't initialized") - } - } - impl MaybeDefault for &::core::marker::PhantomData - {} - impl MaybeDefault for ::core::marker::PhantomData - where - T: ::core::default::Default, - { - fn maybe_default(self: &Self) -> T - { - T::default() - } - } - (&::core::marker::PhantomData::<&'callback dyn FilterCol>).maybe_default() - } - }; - let result = Styles::< 'callback > { filter }; - return result; - } -} - -#[doc = "\nStructure to form [Styles]. Represents a forming entity designed to construct objects through a builder pattern.\n\nThis structure holds temporary storage and context during the formation process and\nutilizes a defined end strategy to finalize the object creation.\n"] -pub struct StylesFormer< 'callback, Definition = StylesFormerDefinition< 'callback, (), Styles< 'callback >, former::ReturnPreformed > > -where - Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, - Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback > >, -{ - #[doc = r" Temporary storage for all fields during the formation process. It contains"] - #[doc = r" partial data that progressively builds up to the final object."] - pub storage: Definition::Storage, - #[doc = r" An optional context providing additional data or state necessary for custom"] - #[doc = r" formation logic or to facilitate this former's role as a subformer within another former."] - pub context: ::core::option::Option< Definition::Context >, - #[doc = r" An optional closure or handler that is invoked to transform the accumulated"] - #[doc = r" temporary storage into the final object structure once formation is complete."] - pub on_end: ::core::option::Option< Definition::End >, -} - -#[automatically_derived] -impl< 'callback, Definition > StylesFormer< 'callback, Definition > -where - Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, - Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback > >, -{ - #[doc = r""] - #[doc = r" Initializes a former with an end condition and default storage."] - #[doc = r""] - #[inline(always)] - pub fn new(on_end: Definition::End) -> Self - { - Self::begin_coercing(::core::option::Option::None, ::core::option::Option::None, on_end) - } - - #[doc = r""] - #[doc = r" Initializes a former with a coercible end condition."] - #[doc = r""] - #[inline(always)] - pub fn new_coercing(end: IntoEnd) -> Self - where - IntoEnd: ::core::convert::Into, - { - Self::begin_coercing(::core::option::Option::None, ::core::option::Option::None, end) - } - - #[doc = r""] - #[doc = r" Begins the formation process with specified context and termination logic."] - #[doc = r""] - #[inline(always)] - pub fn begin( - mut storage: ::core::option::Option, - context: ::core::option::Option, - on_end: ::End, - ) -> Self - { - if storage.is_none() - { - storage = ::core::option::Option::Some(::core::default::Default::default()); - } - Self - { - storage: storage.unwrap(), - context: context, - on_end: ::core::option::Option::Some(on_end), - } - } - - #[doc = r""] - #[doc = r" Starts the formation process with coercible end condition and optional initial values."] - #[doc = r""] - #[inline(always)] - pub fn begin_coercing( - mut storage: ::core::option::Option, - context: ::core::option::Option, - on_end: IntoEnd, - ) -> Self - where - IntoEnd: ::core::convert::Into<::End>, - { - if storage.is_none() - { - storage = ::core::option::Option::Some(::core::default::Default::default()); - } - Self - { - storage: storage.unwrap(), - context: context, - on_end: ::core::option::Option::Some(::core::convert::Into::into(on_end)), - } - } - - #[doc = r""] - #[doc = r" Wrapper for `end` to align with common builder pattern terminologies."] - #[doc = r""] - #[inline(always)] - pub fn form(self) -> ::Formed - { - self.end() - } - - #[doc = r""] - #[doc = r" Completes the formation and returns the formed object."] - #[doc = r""] - #[inline(always)] - pub fn end(mut self) -> ::Formed - { - let on_end = self.on_end.take().unwrap(); - let mut context = self.context.take(); - ::form_mutation(&mut self.storage, &mut context); - former::FormingEnd::::call(&on_end, self.storage, context) - } - - #[doc = "Scalar setter for the 'filter' field."] - #[inline] - pub fn filter(mut self, src: Src) -> Self - where - Src: ::core::convert::Into<& 'callback dyn FilterCol>, - { - debug_assert!(self.storage.filter.is_none()); - self.storage.filter = ::core::option::Option::Some(::core::convert::Into::into(src)); - self - } -} - -impl< 'callback, Definition > StylesFormer< 'callback, Definition > -where - Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback >, Formed = Styles< 'callback > >, - Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback >, Formed = Styles< 'callback > >, - Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, - Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback > >, -{ - #[doc = r" Executes the transformation from the former's storage state to the preformed object as specified by the definition."] - pub fn preform(self) -> ::Formed - { - former::StoragePreform::preform(self.storage) - } -} - -#[automatically_derived] -impl< 'callback, Definition > StylesFormer< 'callback, Definition > -where - Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback >, Formed = Styles< 'callback > >, - Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback >, Formed = Styles< 'callback > >, -{ - #[doc = r""] - #[doc = r" Finish setting options and call perform on formed entity."] - #[doc = r""] - #[doc = r" If `perform` defined then associated method is called and its result returned instead of entity."] - #[doc = r" For example `perform()` of structure with : `#[ perform( fn after1() -> &str > )` returns `&str`."] - #[doc = r""] - #[inline(always)] - pub fn perform(self) -> Definition::Formed - { - let result = self.form(); - return result; - } -} - -impl< 'callback, Definition > former::FormerBegin< Definition > for StylesFormer< 'callback, Definition > -where - Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, -{ - #[inline(always)] - fn former_begin( - storage: ::core::option::Option, - context: ::core::option::Option, - on_end: Definition::End, - ) -> Self - { - debug_assert!(storage.is_none()); - Self::begin(::core::option::Option::None, context, on_end) - } -} - -#[doc = r" Provides a specialized former for structure using predefined settings for superformer and end conditions."] -#[doc = r""] -#[doc = r" This type alias configures former of the structure with a specific definition to streamline its usage in broader contexts,"] -#[doc = r" especially where structure needs to be integrated into larger structures with a clear termination condition."] -pub type StylesAsSubformer< 'callback, __Superformer, __End > = StylesFormer< 'callback, StylesFormerDefinition< 'callback, __Superformer, __Superformer, __End > >; - -#[doc = "\nRepresents an end condition for former of [`$Styles`], tying the lifecycle of forming processes to a broader context.\n\nThis trait is intended for use with subformer alias, ensuring that end conditions are met according to the\nspecific needs of the broader forming context. It mandates the implementation of `former::FormingEnd`.\n "] -pub trait StylesAsSubformerEnd< 'callback, SuperFormer > -where - Self: former::FormingEnd< StylesFormerDefinitionTypes< 'callback, SuperFormer, SuperFormer > >, -{} -impl< 'callback, SuperFormer, __T > StylesAsSubformerEnd< 'callback, SuperFormer > for __T -where - Self: former::FormingEnd< StylesFormerDefinitionTypes< 'callback, SuperFormer, SuperFormer > >, -{} - -// === end of generated - -#[ test ] -fn basic() -{ -} \ No newline at end of file +// xxx2 : qqq2 : +// - uncomment code +// - duplicate the file and actually use macro Former +// - make macro working taking into account this corner case +// - for your conveniency there expansion of macro is below + +// use super::*; +// use core::fmt; +// +// pub trait FilterCol : fmt::Debug +// { +// fn filter_col( &self, key : &str ) -> bool; +// } +// +// #[ derive( Debug, Default, PartialEq, Clone, Copy ) ] +// pub struct All; +// +// impl All +// { +// pub fn instance() -> & 'static dyn FilterCol +// { +// static INSTANCE : All = All; +// &INSTANCE +// } +// } +// +// impl Default for &'static dyn FilterCol +// { +// #[ inline( always ) ] +// fn default() -> Self +// { +// All::instance() +// } +// } +// +// impl FilterCol for All +// { +// #[ inline( always ) ] +// fn filter_col( &self, _key : &str ) -> bool +// { +// true +// } +// } +// +// #[ derive( Default ) ] +// // #[ derive( former::Former ) ] // xxx : qqq : uncomment and fix problem with lifetime +// // #[ derive( former::Former ) ] #[ debug ] +// pub struct Styles< 'callback > +// { +// +// // pub output_format : &'static dyn AsRef< str >, +// pub filter : &'callback dyn FilterCol, +// +// } +// +// // === begin_coercing of generated +// +// #[automatically_derived] +// impl< 'callback > Styles< 'callback > where +// { +// #[doc = r""] +// #[doc = r" Provides a mechanism to initiate the formation process with a default completion behavior."] +// #[doc = r""] +// #[inline(always)] +// pub fn former() -> StylesFormer< 'callback, StylesFormerDefinition< 'callback, (), Styles< 'callback >, former::ReturnPreformed > > +// { +// StylesFormer::< 'callback, StylesFormerDefinition< 'callback, (), Styles< 'callback >, former::ReturnPreformed > >::new_coercing(former::ReturnPreformed) +// } +// } +// +// impl< 'callback, Definition > former::EntityToFormer< Definition > for Styles< 'callback > +// where +// Definition : former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, +// { +// type Former = StylesFormer< 'callback, Definition >; +// } +// +// impl< 'callback > former::EntityToStorage for Styles< 'callback > +// where +// { +// type Storage = StylesFormerStorage< 'callback >; +// } +// +// impl< 'callback, __Context, __Formed, __End > former::EntityToDefinition< __Context, __Formed, __End > for Styles< 'callback > +// where +// __End : former::FormingEnd< StylesFormerDefinitionTypes< 'callback, __Context, __Formed > >, +// { +// type Definition = StylesFormerDefinition< 'callback, __Context, __Formed, __End >; +// type Types = StylesFormerDefinitionTypes< 'callback, __Context, __Formed >; +// } +// +// impl< 'callback, __Context, __Formed > former::EntityToDefinitionTypes< __Context, __Formed > for Styles< 'callback > +// where +// { +// type Types = StylesFormerDefinitionTypes< 'callback, __Context, __Formed >; +// } +// +// #[doc = r" Defines the generic parameters for formation behavior including context, form, and end conditions."] +// #[derive(Debug)] +// pub struct StylesFormerDefinitionTypes< 'callback, __Context = (), __Formed = Styles< 'callback > > +// where +// { +// _phantom: ::core::marker::PhantomData< ( & 'callback (), * const __Context, * const __Formed ) >, +// } +// +// impl< 'callback, __Context, __Formed > ::core::default::Default for StylesFormerDefinitionTypes< 'callback, __Context, __Formed > +// where +// { +// fn default() -> Self +// { +// Self { _phantom: ::core::marker::PhantomData } +// } +// } +// +// impl< 'callback, __Context, __Formed > former::FormerDefinitionTypes for StylesFormerDefinitionTypes< 'callback, __Context, __Formed > +// where +// { +// type Storage = StylesFormerStorage< 'callback >; +// type Formed = __Formed; +// type Context = __Context; +// } +// +// #[doc = r" Holds the definition types used during the formation process."] +// #[derive(Debug)] +// pub struct StylesFormerDefinition< 'callback, __Context = (), __Formed = Styles< 'callback >, __End = former::ReturnPreformed > +// where +// { +// _phantom: ::core::marker::PhantomData< ( & 'callback (), * const __Context, * const __Formed, * const __End ) >, +// } +// +// impl< 'callback, __Context, __Formed, __End > ::core::default::Default for StylesFormerDefinition< 'callback, __Context, __Formed, __End > +// where +// { +// fn default() -> Self +// { +// Self { _phantom: ::core::marker::PhantomData } +// } +// } +// +// impl< 'callback, __Context, __Formed, __End > former::FormerDefinition for StylesFormerDefinition< 'callback, __Context, __Formed, __End > +// where +// __End : former::FormingEnd< StylesFormerDefinitionTypes< 'callback, __Context, __Formed > >, +// { +// type Types = StylesFormerDefinitionTypes< 'callback, __Context, __Formed >; +// type End = __End; +// type Storage = StylesFormerStorage< 'callback >; +// type Formed = __Formed; +// type Context = __Context; +// } +// +// impl< 'callback, __Context, __Formed > former::FormerMutator for StylesFormerDefinitionTypes< 'callback, __Context, __Formed > +// where +// {} +// +// #[doc = "Stores potential values for fields during the formation process."] +// #[allow(explicit_outlives_requirements)] +// pub struct StylesFormerStorage< 'callback > +// where +// { +// #[doc = r" A field"] +// pub filter: ::core::option::Option< & 'callback dyn FilterCol >, +// } +// +// impl< 'callback > ::core::default::Default for StylesFormerStorage< 'callback > +// where +// { +// #[inline(always)] +// fn default() -> Self +// { +// Self { filter: ::core::option::Option::None } +// } +// } +// +// impl< 'callback > former::Storage for StylesFormerStorage< 'callback > +// where +// { +// type Preformed = Styles< 'callback >; +// } +// +// impl< 'callback > former::StoragePreform for StylesFormerStorage< 'callback > +// where +// { +// fn preform(mut self) -> Self::Preformed +// { +// let filter = if self.filter.is_some() +// { +// self.filter.take().unwrap() +// } +// else +// { +// { +// trait MaybeDefault +// { +// fn maybe_default(self: &Self) -> T +// { +// panic!("Field 'filter' isn't initialized") +// } +// } +// impl MaybeDefault for &::core::marker::PhantomData +// {} +// impl MaybeDefault for ::core::marker::PhantomData +// where +// T: ::core::default::Default, +// { +// fn maybe_default(self: &Self) -> T +// { +// T::default() +// } +// } +// (&::core::marker::PhantomData::<&'callback dyn FilterCol>).maybe_default() +// } +// }; +// let result = Styles::< 'callback > { filter }; +// return result; +// } +// } +// +// #[doc = "\nStructure to form [Styles]. Represents a forming entity designed to construct objects through a builder pattern.\n\nThis structure holds temporary storage and context during the formation process and\nutilizes a defined end strategy to finalize the object creation.\n"] +// pub struct StylesFormer< 'callback, Definition = StylesFormerDefinition< 'callback, (), Styles< 'callback >, former::ReturnPreformed > > +// where +// Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, +// Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback > >, +// { +// #[doc = r" Temporary storage for all fields during the formation process. It contains"] +// #[doc = r" partial data that progressively builds up to the final object."] +// pub storage: Definition::Storage, +// #[doc = r" An optional context providing additional data or state necessary for custom"] +// #[doc = r" formation logic or to facilitate this former's role as a subformer within another former."] +// pub context: ::core::option::Option< Definition::Context >, +// #[doc = r" An optional closure or handler that is invoked to transform the accumulated"] +// #[doc = r" temporary storage into the final object structure once formation is complete."] +// pub on_end: ::core::option::Option< Definition::End >, +// } +// +// #[automatically_derived] +// impl< 'callback, Definition > StylesFormer< 'callback, Definition > +// where +// Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, +// Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback > >, +// { +// #[doc = r""] +// #[doc = r" Initializes a former with an end condition and default storage."] +// #[doc = r""] +// #[inline(always)] +// pub fn new(on_end: Definition::End) -> Self +// { +// Self::begin_coercing(::core::option::Option::None, ::core::option::Option::None, on_end) +// } +// +// #[doc = r""] +// #[doc = r" Initializes a former with a coercible end condition."] +// #[doc = r""] +// #[inline(always)] +// pub fn new_coercing(end: IntoEnd) -> Self +// where +// IntoEnd: ::core::convert::Into, +// { +// Self::begin_coercing(::core::option::Option::None, ::core::option::Option::None, end) +// } +// +// #[doc = r""] +// #[doc = r" Begins the formation process with specified context and termination logic."] +// #[doc = r""] +// #[inline(always)] +// pub fn begin( +// mut storage: ::core::option::Option, +// context: ::core::option::Option, +// on_end: ::End, +// ) -> Self +// { +// if storage.is_none() +// { +// storage = ::core::option::Option::Some(::core::default::Default::default()); +// } +// Self +// { +// storage: storage.unwrap(), +// context: context, +// on_end: ::core::option::Option::Some(on_end), +// } +// } +// +// #[doc = r""] +// #[doc = r" Starts the formation process with coercible end condition and optional initial values."] +// #[doc = r""] +// #[inline(always)] +// pub fn begin_coercing( +// mut storage: ::core::option::Option, +// context: ::core::option::Option, +// on_end: IntoEnd, +// ) -> Self +// where +// IntoEnd: ::core::convert::Into<::End>, +// { +// if storage.is_none() +// { +// storage = ::core::option::Option::Some(::core::default::Default::default()); +// } +// Self +// { +// storage: storage.unwrap(), +// context: context, +// on_end: ::core::option::Option::Some(::core::convert::Into::into(on_end)), +// } +// } +// +// #[doc = r""] +// #[doc = r" Wrapper for `end` to align with common builder pattern terminologies."] +// #[doc = r""] +// #[inline(always)] +// pub fn form(self) -> ::Formed +// { +// self.end() +// } +// +// #[doc = r""] +// #[doc = r" Completes the formation and returns the formed object."] +// #[doc = r""] +// #[inline(always)] +// pub fn end(mut self) -> ::Formed +// { +// let on_end = self.on_end.take().unwrap(); +// let mut context = self.context.take(); +// ::form_mutation(&mut self.storage, &mut context); +// former::FormingEnd::::call(&on_end, self.storage, context) +// } +// +// #[doc = "Scalar setter for the 'filter' field."] +// #[inline] +// pub fn filter(mut self, src: Src) -> Self +// where +// Src: ::core::convert::Into<& 'callback dyn FilterCol>, +// { +// debug_assert!(self.storage.filter.is_none()); +// self.storage.filter = ::core::option::Option::Some(::core::convert::Into::into(src)); +// self +// } +// } +// +// impl< 'callback, Definition > StylesFormer< 'callback, Definition > +// where +// Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback >, Formed = Styles< 'callback > >, +// Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback >, Formed = Styles< 'callback > >, +// Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, +// Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback > >, +// { +// #[doc = r" Executes the transformation from the former's storage state to the preformed object as specified by the definition."] +// pub fn preform(self) -> ::Formed +// { +// former::StoragePreform::preform(self.storage) +// } +// } +// +// #[automatically_derived] +// impl< 'callback, Definition > StylesFormer< 'callback, Definition > +// where +// Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback >, Formed = Styles< 'callback > >, +// Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback >, Formed = Styles< 'callback > >, +// { +// #[doc = r""] +// #[doc = r" Finish setting options and call perform on formed entity."] +// #[doc = r""] +// #[doc = r" If `perform` defined then associated method is called and its result returned instead of entity."] +// #[doc = r" For example `perform()` of structure with : `#[ perform( fn after1() -> &str > )` returns `&str`."] +// #[doc = r""] +// #[inline(always)] +// pub fn perform(self) -> Definition::Formed +// { +// let result = self.form(); +// return result; +// } +// } +// +// impl< 'callback, Definition > former::FormerBegin< Definition > for StylesFormer< 'callback, Definition > +// where +// Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, +// { +// #[inline(always)] +// fn former_begin( +// storage: ::core::option::Option, +// context: ::core::option::Option, +// on_end: Definition::End, +// ) -> Self +// { +// debug_assert!(storage.is_none()); +// Self::begin(::core::option::Option::None, context, on_end) +// } +// } +// +// #[doc = r" Provides a specialized former for structure using predefined settings for superformer and end conditions."] +// #[doc = r""] +// #[doc = r" This type alias configures former of the structure with a specific definition to streamline its usage in broader contexts,"] +// #[doc = r" especially where structure needs to be integrated into larger structures with a clear termination condition."] +// pub type StylesAsSubformer< 'callback, __Superformer, __End > = StylesFormer< 'callback, StylesFormerDefinition< 'callback, __Superformer, __Superformer, __End > >; +// +// #[doc = "\nRepresents an end condition for former of [`$Styles`], tying the lifecycle of forming processes to a broader context.\n\nThis trait is intended for use with subformer alias, ensuring that end conditions are met according to the\nspecific needs of the broader forming context. It mandates the implementation of `former::FormingEnd`.\n "] +// pub trait StylesAsSubformerEnd< 'callback, SuperFormer > +// where +// Self: former::FormingEnd< StylesFormerDefinitionTypes< 'callback, SuperFormer, SuperFormer > >, +// {} +// impl< 'callback, SuperFormer, __T > StylesAsSubformerEnd< 'callback, SuperFormer > for __T +// where +// Self: former::FormingEnd< StylesFormerDefinitionTypes< 'callback, SuperFormer, SuperFormer > >, +// {} +// +// // === end of generated +// +// #[ test ] +// fn basic() +// { +// } \ No newline at end of file diff --git a/module/core/former/tests/inc/former_tests/subform_collection_custom.rs b/module/core/former/tests/inc/former_tests/subform_collection_custom.rs index 00851f857d..684cc4775a 100644 --- a/module/core/former/tests/inc/former_tests/subform_collection_custom.rs +++ b/module/core/former/tests/inc/former_tests/subform_collection_custom.rs @@ -36,7 +36,7 @@ where K : core::cmp::Eq + std::hash::Hash, { type Item = K; - type IntoIter = collection_tools::hset::IntoIter< K >; + type IntoIter = collection_tools::hash_set::IntoIter< K >; fn into_iter( self ) -> Self::IntoIter { @@ -49,7 +49,7 @@ where K : core::cmp::Eq + std::hash::Hash, { type Item = &'a K; - type IntoIter = collection_tools::hset::Iter< 'a, K >; + type IntoIter = collection_tools::hash_set::Iter< 'a, K >; fn into_iter( self ) -> Self::IntoIter { diff --git a/module/core/former/tests/inc/mod.rs b/module/core/former/tests/inc/mod.rs index d259269d35..3405bce07f 100644 --- a/module/core/former/tests/inc/mod.rs +++ b/module/core/former/tests/inc/mod.rs @@ -1,12 +1,11 @@ // #![ deny( missing_docs ) ] -#[ allow( unused_imports ) ] use super::*; +use test_tools::exposed::*; #[ cfg( feature = "derive_former" ) ] mod former_tests { - #[ allow( unused_imports ) ] use super::*; // = basic @@ -53,7 +52,7 @@ mod former_tests // = parametrization - mod parametrized_dyn; + mod parametrized_dyn; // xxx2 : qqq2 : fix the issue #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] mod parametrized_struct_manual; diff --git a/module/core/former/tests/smoke_test.rs b/module/core/former/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/former/tests/smoke_test.rs +++ b/module/core/former/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/former/tests/tests.rs b/module/core/former/tests/tests.rs index fe0db783b8..5796f74d30 100644 --- a/module/core/former/tests/tests.rs +++ b/module/core/former/tests/tests.rs @@ -1,9 +1,8 @@ +//! All tests. +#![ allow( unused_imports ) ] include!( "../../../../module/step/meta/src/module/terminal.rs" ); -#[ allow( unused_imports ) ] -use test_tools::exposed::*; -#[ allow( unused_imports ) ] use former as the_module; #[ cfg( feature = "enabled" ) ] diff --git a/module/core/former_meta/Cargo.toml b/module/core/former_meta/Cargo.toml index 38845bc3f1..80aab28703 100644 --- a/module/core/former_meta/Cargo.toml +++ b/module/core/former_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "former_meta" -version = "2.11.0" +version = "2.12.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/former_meta/tests/smoke_test.rs b/module/core/former_meta/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/former_meta/tests/smoke_test.rs +++ b/module/core/former_meta/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/former_types/Cargo.toml b/module/core/former_types/Cargo.toml index 1049a6c8bd..54c5034202 100644 --- a/module/core/former_types/Cargo.toml +++ b/module/core/former_types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "former_types" -version = "2.12.0" +version = "2.14.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/former_types/tests/smoke_test.rs b/module/core/former_types/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/former_types/tests/smoke_test.rs +++ b/module/core/former_types/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/fs_tools/tests/smoke_test.rs b/module/core/fs_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/fs_tools/tests/smoke_test.rs +++ b/module/core/fs_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/implements/Cargo.toml b/module/core/implements/Cargo.toml index 8c468c0b60..8d97aaedb4 100644 --- a/module/core/implements/Cargo.toml +++ b/module/core/implements/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "implements" -version = "0.10.0" +version = "0.11.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -24,8 +24,6 @@ workspace = true features = [ "full" ] all-features = false - - [features] default = [ "enabled" ] full = [ "enabled" ] @@ -36,4 +34,5 @@ enabled = [] [dependencies] [dev-dependencies] -test_tools = { workspace = true } +# this crate should not rely on test_tools to exclude cyclic dependencies +# test_tools = { workspace = true } diff --git a/module/core/implements/tests/inc/implements_test.rs b/module/core/implements/tests/inc/implements_test.rs index 24f39c32d7..e552165c41 100644 --- a/module/core/implements/tests/inc/implements_test.rs +++ b/module/core/implements/tests/inc/implements_test.rs @@ -3,221 +3,216 @@ use super::*; // -tests_impls! +#[ test ] +fn implements_basic() { - #[ test ] - fn implements_basic() - { + trait Trait1 {} + fn impl_trait1( _ : &impl Trait1 ) -> bool { true } - trait Trait1 {} - fn impl_trait1( _ : &impl Trait1 ) -> bool { true } + impl< T : Sized > Trait1 for &[ T ] {} + impl< T : Sized, const N : usize > Trait1 for [ T; N ] {} + impl< T : Sized, const N : usize > Trait1 for &[ T; N ] {} + let src : &[ i32 ] = &[ 1, 2, 3 ]; + assert_eq!( the_module::implements!( src => Trait1 ), true ); + assert_eq!( impl_trait1( &src ), true ); + assert_eq!( the_module::implements!( &[ 1, 2, 3 ] => Trait1 ), true ); + assert_eq!( impl_trait1( &[ 1, 2, 3 ] ), true ); + assert_eq!( the_module::implements!( [ 1, 2, 3 ] => Trait1 ), true ); - impl< T : Sized > Trait1 for &[ T ] {} - impl< T : Sized, const N : usize > Trait1 for [ T; N ] {} - impl< T : Sized, const N : usize > Trait1 for &[ T; N ] {} - let src : &[ i32 ] = &[ 1, 2, 3 ]; - a_id!( the_module::implements!( src => Trait1 ), true ); - a_id!( impl_trait1( &src ), true ); - a_id!( the_module::implements!( &[ 1, 2, 3 ] => Trait1 ), true ); - a_id!( impl_trait1( &[ 1, 2, 3 ] ), true ); - a_id!( the_module::implements!( [ 1, 2, 3 ] => Trait1 ), true ); + impl< T : Sized > Trait1 for Vec< T > {} + assert_eq!( the_module::implements!( vec!( 1, 2, 3 ) => Trait1 ), true ); - impl< T : Sized > Trait1 for Vec< T > {} - a_id!( the_module::implements!( vec!( 1, 2, 3 ) => Trait1 ), true ); + impl Trait1 for f32 {} + assert_eq!( the_module::implements!( 13_f32 => Trait1 ), true ); - impl Trait1 for f32 {} - a_id!( the_module::implements!( 13_f32 => Trait1 ), true ); + assert_eq!( the_module::implements!( true => Copy ), true ); + assert_eq!( the_module::implements!( true => Clone ), true ); - a_id!( the_module::implements!( true => Copy ), true ); - a_id!( the_module::implements!( true => Clone ), true ); + let src = true; + assert_eq!( the_module::implements!( src => Copy ), true ); + assert_eq!( the_module::implements!( src => Clone ), true ); - let src = true; - a_id!( the_module::implements!( src => Copy ), true ); - a_id!( the_module::implements!( src => Clone ), true ); + let src = Box::new( true ); + assert_eq!( the_module::implements!( src => Copy ), false ); + assert_eq!( the_module::implements!( src => Clone ), true ); - let src = Box::new( true ); - a_id!( the_module::implements!( src => Copy ), false ); - a_id!( the_module::implements!( src => Clone ), true ); + assert_eq!( the_module::implements!( Box::new( true ) => std::marker::Copy ), false ); + assert_eq!( the_module::implements!( Box::new( true ) => std::clone::Clone ), true ); - a_id!( the_module::implements!( Box::new( true ) => std::marker::Copy ), false ); - a_id!( the_module::implements!( Box::new( true ) => std::clone::Clone ), true ); +} - } +// - // +#[ test ] +fn instance_of_basic() +{ - #[ test ] - fn instance_of_basic() - { + let src = Box::new( true ); + assert_eq!( the_module::instance_of!( src => Copy ), false ); + assert_eq!( the_module::instance_of!( src => Clone ), true ); - let src = Box::new( true ); - a_id!( the_module::instance_of!( src => Copy ), false ); - a_id!( the_module::instance_of!( src => Clone ), true ); +} - } +// - // +#[ test ] +fn implements_functions() +{ - #[ test ] - fn implements_functions() + let _f = || { + println!( "hello" ); + }; - let _f = || - { - println!( "hello" ); - }; - - let fn_context = vec!( 1, 2, 3 ); - let _fn = || - { - println!( "hello {:?}", fn_context ); - }; - - let mut fn_mut_context = vec!( 1, 2, 3 ); - let _fn_mut = || - { - fn_mut_context[ 0 ] = 3; - println!( "{:?}", fn_mut_context ); - }; - - let mut fn_once_context = vec!( 1, 2, 3 ); - let _fn_once = || - { - fn_once_context[ 0 ] = 3; - let x = fn_once_context; - println!( "{:?}", x ); - }; - - /* */ - - a_id!( the_module::implements!( _fn => Copy ), true ); - a_id!( the_module::implements!( _fn => Clone ), true ); - a_id!( the_module::implements!( _fn => core::ops::Not ), false ); - let _ = _fn.clone(); - - /* */ - - // a_id!( the_module::implements!( function1 => fn() -> () ), true ); - // a_id!( the_module::implements!( &function1 => Fn() -> () ), true ); - // a_id!( the_module::implements!( &function1 => FnMut() -> () ), true ); - // a_id!( the_module::implements!( &function1 => FnOnce() -> () ), true ); - - // a_id!( the_module::implements!( _fn => fn() -> () ), true ); - a_id!( the_module::implements!( _fn => Fn() -> () ), true ); - a_id!( the_module::implements!( _fn => FnMut() -> () ), true ); - a_id!( the_module::implements!( _fn => FnOnce() -> () ), true ); - - // a_id!( the_module::implements!( _fn_mut => fn() -> () ), false ); - // a_id!( the_module::implements!( _fn_mut => Fn() -> () ), false ); - a_id!( the_module::implements!( _fn_mut => FnMut() -> () ), true ); - a_id!( the_module::implements!( _fn_mut => FnOnce() -> () ), true ); - - // a_id!( the_module::implements!( _fn_once => fn() -> () ), false ); - // a_id!( the_module::implements!( _fn_once => Fn() -> () ), false ); - // a_id!( the_module::implements!( _fn_once => FnMut() -> () ), false ); - a_id!( the_module::implements!( _fn_once => FnOnce() -> () ), true ); - - // fn is_f < R > ( _x : fn() -> R ) -> bool { true } - // fn is_fn < R, F : Fn() -> R > ( _x : &F ) -> bool { true } - // fn is_fn_mut < R, F : FnMut() -> R > ( _x : &F ) -> bool { true } - // fn is_fn_once < R, F : FnOnce() -> R > ( _x : &F ) -> bool { true } - // fn function1() -> bool { true } - - } - - // - - #[ test ] - fn pointer_experiment() + let fn_context = vec!( 1, 2, 3 ); + let _fn = || { + println!( "hello {:?}", fn_context ); + }; - let pointer_size = std::mem::size_of::< &u8 >(); - dbg!( &pointer_size ); - a_id!( 2 * pointer_size, std::mem::size_of::< &[ u8 ] >() ); - a_id!( 2 * pointer_size, std::mem::size_of::< *const [ u8 ] >() ); - a_id!( 2 * pointer_size, std::mem::size_of::< Box< [ u8 ] > >() ); - a_id!( 2 * pointer_size, std::mem::size_of::< std::rc::Rc< [ u8 ] > >() ); - a_id!( 1 * pointer_size, std::mem::size_of::< &[ u8 ; 20 ] >() ); + let mut fn_mut_context = vec!( 1, 2, 3 ); + let _fn_mut = || + { + fn_mut_context[ 0 ] = 3; + println!( "{:?}", fn_mut_context ); + }; - } + let mut fn_once_context = vec!( 1, 2, 3 ); + let _fn_once = || + { + fn_once_context[ 0 ] = 3; + let x = fn_once_context; + println!( "{:?}", x ); + }; + + /* */ + + assert_eq!( the_module::implements!( _fn => Copy ), true ); + assert_eq!( the_module::implements!( _fn => Clone ), true ); + assert_eq!( the_module::implements!( _fn => core::ops::Not ), false ); + let _ = _fn.clone(); + + /* */ + + // assert_eq!( the_module::implements!( function1 => fn() -> () ), true ); + // assert_eq!( the_module::implements!( &function1 => Fn() -> () ), true ); + // assert_eq!( the_module::implements!( &function1 => FnMut() -> () ), true ); + // assert_eq!( the_module::implements!( &function1 => FnOnce() -> () ), true ); + + // assert_eq!( the_module::implements!( _fn => fn() -> () ), true ); + assert_eq!( the_module::implements!( _fn => Fn() -> () ), true ); + assert_eq!( the_module::implements!( _fn => FnMut() -> () ), true ); + assert_eq!( the_module::implements!( _fn => FnOnce() -> () ), true ); + + // assert_eq!( the_module::implements!( _fn_mut => fn() -> () ), false ); + // assert_eq!( the_module::implements!( _fn_mut => Fn() -> () ), false ); + assert_eq!( the_module::implements!( _fn_mut => FnMut() -> () ), true ); + assert_eq!( the_module::implements!( _fn_mut => FnOnce() -> () ), true ); + + // assert_eq!( the_module::implements!( _fn_once => fn() -> () ), false ); + // assert_eq!( the_module::implements!( _fn_once => Fn() -> () ), false ); + // assert_eq!( the_module::implements!( _fn_once => FnMut() -> () ), false ); + assert_eq!( the_module::implements!( _fn_once => FnOnce() -> () ), true ); + + // fn is_f < R > ( _x : fn() -> R ) -> bool { true } + // fn is_fn < R, F : Fn() -> R > ( _x : &F ) -> bool { true } + // fn is_fn_mut < R, F : FnMut() -> R > ( _x : &F ) -> bool { true } + // fn is_fn_once < R, F : FnOnce() -> R > ( _x : &F ) -> bool { true } + // fn function1() -> bool { true } - // +} - #[ test ] - fn fn_experiment() - { +// - fn function1() -> bool { true } - - let _f = || - { - println!( "hello" ); - }; - - let fn_context = vec!( 1, 2, 3 ); - let _fn = || - { - println!( "hello {:?}", fn_context ); - }; - - let mut fn_mut_context = vec!( 1, 2, 3 ); - let _fn_mut = || - { - fn_mut_context[ 0 ] = 3; - println!( "{:?}", fn_mut_context ); - }; - - let mut fn_once_context = vec!( 1, 2, 3 ); - let _fn_once = || - { - fn_once_context[ 0 ] = 3; - let x = fn_once_context; - println!( "{:?}", x ); - }; - - a_id!( is_f( function1 ), true ); - a_id!( is_fn( &function1 ), true ); - a_id!( is_fn_mut( &function1 ), true ); - a_id!( is_fn_once( &function1 ), true ); - - a_id!( is_f( _f ), true ); - a_id!( is_fn( &_f ), true ); - a_id!( is_fn_mut( &_f ), true ); - a_id!( is_fn_once( &_f ), true ); - - // a_id!( is_f( _fn ), true ); - a_id!( is_fn( &_fn ), true ); - a_id!( is_fn_mut( &_fn ), true ); - a_id!( is_fn_once( &_fn ), true ); - - // a_id!( is_f( _fn_mut ), true ); - // a_id!( is_fn( &_fn_mut ), true ); - a_id!( is_fn_mut( &_fn_mut ), true ); - a_id!( is_fn_once( &_fn_mut ), true ); - - // a_id!( is_f( _fn_once ), true ); - // a_id!( is_fn( &_fn_once ), true ); - // a_id!( is_fn_mut( &_fn_once ), true ); - a_id!( is_fn_once( &_fn_once ), true ); - - // type Routine< R > = fn() -> R; - fn is_f < R > ( _x : fn() -> R ) -> bool { true } - // fn is_f < R > ( _x : Routine< R > ) -> bool { true } - fn is_fn < R, F : Fn() -> R > ( _x : &F ) -> bool { true } - fn is_fn_mut < R, F : FnMut() -> R > ( _x : &F ) -> bool { true } - fn is_fn_once < R, F : FnOnce() -> R > ( _x : &F ) -> bool { true } - } +#[ test ] +fn pointer_experiment() +{ + + let pointer_size = std::mem::size_of::< &u8 >(); + dbg!( &pointer_size ); + assert_eq!( 2 * pointer_size, std::mem::size_of::< &[ u8 ] >() ); + assert_eq!( 2 * pointer_size, std::mem::size_of::< *const [ u8 ] >() ); + assert_eq!( 2 * pointer_size, std::mem::size_of::< Box< [ u8 ] > >() ); + assert_eq!( 2 * pointer_size, std::mem::size_of::< std::rc::Rc< [ u8 ] > >() ); + assert_eq!( 1 * pointer_size, std::mem::size_of::< &[ u8 ; 20 ] >() ); } // -tests_index! +#[ test ] +fn fn_experiment() { - implements_basic, - instance_of_basic, - implements_functions, - pointer_experiment, - fn_experiment, + + fn function1() -> bool { true } + + let _f = || + { + println!( "hello" ); + }; + + let fn_context = vec!( 1, 2, 3 ); + let _fn = || + { + println!( "hello {:?}", fn_context ); + }; + + let mut fn_mut_context = vec!( 1, 2, 3 ); + let _fn_mut = || + { + fn_mut_context[ 0 ] = 3; + println!( "{:?}", fn_mut_context ); + }; + + let mut fn_once_context = vec!( 1, 2, 3 ); + let _fn_once = || + { + fn_once_context[ 0 ] = 3; + let x = fn_once_context; + println!( "{:?}", x ); + }; + + assert_eq!( is_f( function1 ), true ); + assert_eq!( is_fn( &function1 ), true ); + assert_eq!( is_fn_mut( &function1 ), true ); + assert_eq!( is_fn_once( &function1 ), true ); + + assert_eq!( is_f( _f ), true ); + assert_eq!( is_fn( &_f ), true ); + assert_eq!( is_fn_mut( &_f ), true ); + assert_eq!( is_fn_once( &_f ), true ); + + // assert_eq!( is_f( _fn ), true ); + assert_eq!( is_fn( &_fn ), true ); + assert_eq!( is_fn_mut( &_fn ), true ); + assert_eq!( is_fn_once( &_fn ), true ); + + // assert_eq!( is_f( _fn_mut ), true ); + // assert_eq!( is_fn( &_fn_mut ), true ); + assert_eq!( is_fn_mut( &_fn_mut ), true ); + assert_eq!( is_fn_once( &_fn_mut ), true ); + + // assert_eq!( is_f( _fn_once ), true ); + // assert_eq!( is_fn( &_fn_once ), true ); + // assert_eq!( is_fn_mut( &_fn_once ), true ); + assert_eq!( is_fn_once( &_fn_once ), true ); + + // type Routine< R > = fn() -> R; + fn is_f < R > ( _x : fn() -> R ) -> bool { true } + // fn is_f < R > ( _x : Routine< R > ) -> bool { true } + fn is_fn < R, F : Fn() -> R > ( _x : &F ) -> bool { true } + fn is_fn_mut < R, F : FnMut() -> R > ( _x : &F ) -> bool { true } + fn is_fn_once < R, F : FnOnce() -> R > ( _x : &F ) -> bool { true } } + +// + +// tests_index! +// { +// implements_basic, +// instance_of_basic, +// implements_functions, +// pointer_experiment, +// fn_experiment, +// } diff --git a/module/core/implements/tests/smoke_test.rs b/module/core/implements/tests/smoke_test.rs index 828e9b016b..ee06731048 100644 --- a/module/core/implements/tests/smoke_test.rs +++ b/module/core/implements/tests/smoke_test.rs @@ -1,14 +1,13 @@ - - -#[ test ] -fn local_smoke_test() -{ - ::test_tools::smoke_test_for_local_run(); -} - - -#[ test ] -fn published_smoke_test() -{ - ::test_tools::smoke_test_for_published_run(); -} +//! Smoke testing of the package. + +// #[ test ] +// fn local_smoke_test() +// { +// ::test_tools::smoke_test_for_local_run(); +// } +// +// #[ test ] +// fn published_smoke_test() +// { +// ::test_tools::smoke_test_for_published_run(); +// } diff --git a/module/core/implements/tests/implements_tests.rs b/module/core/implements/tests/tests.rs similarity index 50% rename from module/core/implements/tests/implements_tests.rs rename to module/core/implements/tests/tests.rs index d51c4b2b7d..9ee09a1d8c 100644 --- a/module/core/implements/tests/implements_tests.rs +++ b/module/core/implements/tests/tests.rs @@ -1,10 +1,11 @@ -// #![cfg_attr(docsrs, feature(doc_cfg))] +// #![ cfg_attr( docsrs, feature( doc_cfg ) ) ] // #![ cfg_attr( feature = "nightly", feature( type_name_of_val ) ) ] #![ cfg_attr( feature = "nightly", feature( trace_macros ) ) ] #![ cfg_attr( feature = "nightly", feature( meta_idents_concat ) ) ] +// qqq : this feature is generated by build.rs file, but chec does it work properly. should wanring be silented? +// explain how you verify that solution is correct -use test_tools::exposed::*; +// use test_tools::exposed::*; use implements as the_module; - mod inc; diff --git a/module/core/impls_index/src/impls_index/mod.rs b/module/core/impls_index/src/impls_index/mod.rs index 5b54558d8d..484e43dd3f 100644 --- a/module/core/impls_index/src/impls_index/mod.rs +++ b/module/core/impls_index/src/impls_index/mod.rs @@ -49,6 +49,7 @@ pub mod orphan pub mod exposed { use super::*; + pub use super::super::impls_index; #[ doc( inline ) ] pub use prelude::*; #[ doc( inline ) ] diff --git a/module/core/impls_index/tests/experiment.rs b/module/core/impls_index/tests/experiment.rs index 85e51cf468..bcb1aca749 100644 --- a/module/core/impls_index/tests/experiment.rs +++ b/module/core/impls_index/tests/experiment.rs @@ -1,10 +1,11 @@ +//! Experimenting. include!( "../../../../module/step/meta/src/module/terminal.rs" ); #[ allow( unused_imports ) ] use impls_index as the_module; #[ allow( unused_imports ) ] -use test_tools::exposed::*; +use test_tools::exposed::{ a_id }; #[ path = "inc/impls3_test.rs" ] mod inc; diff --git a/module/core/impls_index/tests/inc/func_test.rs b/module/core/impls_index/tests/inc/func_test.rs index 7b5d74bbcc..ebe6126f51 100644 --- a/module/core/impls_index/tests/inc/func_test.rs +++ b/module/core/impls_index/tests/inc/func_test.rs @@ -1,9 +1,10 @@ #![ deny( unused_imports ) ] use super::*; -#[ allow ( unused_imports ) ] -use the_module::exposed::*; +// #[ allow ( unused_imports ) ] +// use the_module::exposed::*; // use test_tools::exposed::*; +// use test_tools::a_id; // @@ -12,7 +13,7 @@ fn fn_name() { let f1 = 13; - let f2 = fn_name! + let f2 = the_module::exposed::fn_name! { fn f1() { @@ -29,7 +30,7 @@ fn fn_name() fn fn_rename() { - fn_rename! + the_module::exposed::fn_rename! { @Name { f2 } @Fn @@ -100,7 +101,7 @@ fn fns() }; } - fns! + the_module::exposed::fns! { @Callback { count } @Fns @@ -135,7 +136,7 @@ fn fns() }; } - fns! + the_module::exposed::fns! { @Callback { count } @Fns @@ -172,7 +173,7 @@ fn fns() }; } - fns! + the_module::exposed::fns! { @Callback { count } @Fns @@ -204,7 +205,7 @@ fn fns() }; } - fns! + the_module::exposed::fns! { @Callback { count } @Fns @@ -235,7 +236,7 @@ fn fns() }; } - fns! + the_module::exposed::fns! { @Callback { count } @Fns @@ -268,7 +269,7 @@ fn fns() }; } - fns! + the_module::exposed::fns! { @Callback { count } @Fns @@ -300,7 +301,7 @@ fn fns() // }; // } // -// fns! +// the_module::exposed::fns! // { // @Callback { count } // @Fns @@ -333,7 +334,7 @@ fn fns() } // trace_macros!( true ); - fns! + the_module::exposed::fns! { @Callback { count } @Fns diff --git a/module/core/impls_index/tests/inc/impls3_test.rs b/module/core/impls_index/tests/inc/impls3_test.rs index 1fe454dfc7..350a692a1f 100644 --- a/module/core/impls_index/tests/inc/impls3_test.rs +++ b/module/core/impls_index/tests/inc/impls3_test.rs @@ -1,6 +1,5 @@ use super::*; -use the_module::exposed::impls3; -use the_module::exposed::{ index }; +use the_module::exposed::{ impls3, index, impls_index }; // diff --git a/module/core/impls_index/tests/inc/impls_basic_test.rs b/module/core/impls_index/tests/inc/impls_basic_test.rs index 8a9ef8df85..64ca19ceac 100644 --- a/module/core/impls_index/tests/inc/impls_basic_test.rs +++ b/module/core/impls_index/tests/inc/impls_basic_test.rs @@ -1,8 +1,8 @@ use super::*; -use the_module::exposed::*; +// use the_module::exposed::*; // trace_macros!( true ); -tests_impls! +the_module::exposed::tests_impls! { fn pass1_test() @@ -40,7 +40,7 @@ tests_impls! // trace_macros!( false ); // trace_macros!( true ); -tests_index! +the_module::exposed::tests_index! { pass1_test, fail1_test, diff --git a/module/core/impls_index/tests/inc/mod.rs b/module/core/impls_index/tests/inc/mod.rs index 105f2928cd..624fc01ab8 100644 --- a/module/core/impls_index/tests/inc/mod.rs +++ b/module/core/impls_index/tests/inc/mod.rs @@ -1,9 +1,12 @@ +// To avoid conflicts with test_tools it's important to import only those names which are needed. +use test_tools::a_id; + use super:: { the_module, - only_for_terminal_module, - a_id, + // only_for_terminal_module, + // a_id, }; mod func_test; diff --git a/module/core/impls_index/tests/smoke_test.rs b/module/core/impls_index/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/impls_index/tests/smoke_test.rs +++ b/module/core/impls_index/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/impls_index/tests/tests.rs b/module/core/impls_index/tests/tests.rs index b96684ac4a..7cee7cbf9b 100644 --- a/module/core/impls_index/tests/tests.rs +++ b/module/core/impls_index/tests/tests.rs @@ -1,10 +1,9 @@ +//! All tests. + #![ allow( unused_imports ) ] include!( "../../../../module/step/meta/src/module/terminal.rs" ); #[ allow( unused_imports ) ] use impls_index as the_module; -#[ allow( unused_imports ) ] -use test_tools::exposed::*; - mod inc; diff --git a/module/core/impls_index_meta/Cargo.toml b/module/core/impls_index_meta/Cargo.toml index 036c5a03d0..00668cfd7b 100644 --- a/module/core/impls_index_meta/Cargo.toml +++ b/module/core/impls_index_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "impls_index_meta" -version = "0.9.0" +version = "0.10.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/impls_index_meta/src/impls.rs b/module/core/impls_index_meta/src/impls.rs index 1ae6c3ee9b..1a59eb4a2e 100644 --- a/module/core/impls_index_meta/src/impls.rs +++ b/module/core/impls_index_meta/src/impls.rs @@ -71,7 +71,7 @@ impl quote::ToTokens for Items2 { ( as $Name2 : ident ) => { - ::impls_index::fn_rename! + impls_index::fn_rename! { @Name { $Name2 } @Fn diff --git a/module/core/include_md/tests/smoke_test.rs b/module/core/include_md/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/include_md/tests/smoke_test.rs +++ b/module/core/include_md/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/inspect_type/Cargo.toml b/module/core/inspect_type/Cargo.toml index 260320b11b..cb35a5ecc8 100644 --- a/module/core/inspect_type/Cargo.toml +++ b/module/core/inspect_type/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "inspect_type" -version = "0.12.0" +version = "0.13.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -32,7 +32,8 @@ enabled = [] [dependencies] [dev-dependencies] -test_tools = { workspace = true } +# this crate should not rely on test_tools to exclude cyclic dependencies +# test_tools = { workspace = true } [build-dependencies] rustc_version = "0.4" diff --git a/module/core/inspect_type/build.rs b/module/core/inspect_type/build.rs index e1ddc05383..006a6376e7 100644 --- a/module/core/inspect_type/build.rs +++ b/module/core/inspect_type/build.rs @@ -1,35 +1,35 @@ //! To have information about channel of Rust compiler. -use rustc_version::{ version, version_meta, Channel }; +// use rustc_version::{ version, version_meta, Channel }; fn main() { // Assert we haven't travelled back in time - assert!( version().unwrap().major >= 1 ); + assert!( rustc_version::version().unwrap().major >= 1 ); - // Set cfg flags depending on release channel - match version_meta().unwrap().channel - { - Channel::Stable => - { - println!("cargo:rustc-cfg=RUSTC_IS_STABLE"); - println!("cargo:rustc-check-cfg=cfg(RUSTC_IS_STABLE)"); - } - Channel::Beta => - { - println!("cargo:rustc-cfg=RUSTC_IS_BETA"); - println!("cargo:rustc-check-cfg=cfg(RUSTC_IS_BETA)"); - } - Channel::Nightly => - { - println!("cargo:rustc-cfg=RUSTC_IS_NIGHTLY"); - println!("cargo:rustc-check-cfg=cfg(RUSTC_IS_NIGHTLY)"); - } - Channel::Dev => - { - println!("cargo:rustc-cfg=RUSTC_IS_DEV"); - println!("cargo:rustc-check-cfg=cfg(RUSTC_IS_DEV)"); - } - } + // // Set cfg flags depending on release channel + // match version_meta().unwrap().channel + // { + // Channel::Stable => + // { + // println!("cargo:rustc-cfg=RUSTC_IS_STABLE"); + // println!("cargo:rustc-check-cfg=cfg(RUSTC_IS_STABLE)"); + // } + // Channel::Beta => + // { + // println!("cargo:rustc-cfg=RUSTC_IS_BETA"); + // println!("cargo:rustc-check-cfg=cfg(RUSTC_IS_BETA)"); + // } + // Channel::Nightly => + // { + // println!("cargo:rustc-cfg=RUSTC_IS_NIGHTLY"); + // println!("cargo:rustc-check-cfg=cfg(RUSTC_IS_NIGHTLY)"); + // } + // Channel::Dev => + // { + // println!("cargo:rustc-cfg=RUSTC_IS_DEV"); + // println!("cargo:rustc-check-cfg=cfg(RUSTC_IS_DEV)"); + // } + // } } diff --git a/module/core/inspect_type/examples/inspect_type_trivial.rs b/module/core/inspect_type/examples/inspect_type_trivial.rs index 9f616a8204..260687cf71 100644 --- a/module/core/inspect_type/examples/inspect_type_trivial.rs +++ b/module/core/inspect_type/examples/inspect_type_trivial.rs @@ -1,5 +1,5 @@ //! qqq : write proper description -#![ cfg_attr( feature = "type_name_of_val", feature( type_name_of_val ) ) ] +// #![ cfg_attr( feature = "type_name_of_val", feature( type_name_of_val ) ) ] // // #![ cfg_attr( feature = "nightly", feature( type_name_of_val ) ) ] // #![ rustversion::attr( nightly, feature( type_name_of_val ) ) ] diff --git a/module/core/inspect_type/src/lib.rs b/module/core/inspect_type/src/lib.rs index 8f65d3fb63..06ede7e31c 100644 --- a/module/core/inspect_type/src/lib.rs +++ b/module/core/inspect_type/src/lib.rs @@ -4,9 +4,10 @@ #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] #![ allow( unexpected_cfgs ) ] +// xxx : qqq : no need in nightly anymore // #[ allow( unexpected_cfgs ) ] // #[ cfg( RUSTC_IS_NIGHTLY ) ] -#[ cfg( not( RUSTC_IS_STABLE ) ) ] +// #[ cfg( not( RUSTC_IS_STABLE ) ) ] mod nightly { @@ -96,7 +97,7 @@ pub mod prelude // #[ rustversion::nightly ] // #[ cfg( feature = "type_name_of_val" ) ] // #[ cfg( RUSTC_IS_NIGHTLY ) ] - #[ cfg( not( RUSTC_IS_STABLE ) ) ] + // #[ cfg( not( RUSTC_IS_STABLE ) ) ] #[ doc( inline ) ] pub use super::nightly::*; } diff --git a/module/core/inspect_type/tests/inc/inspect_type_test.rs b/module/core/inspect_type/tests/inc/inspect_type_test.rs index 01445f74c4..78bb0ecc2f 100644 --- a/module/core/inspect_type/tests/inc/inspect_type_test.rs +++ b/module/core/inspect_type/tests/inc/inspect_type_test.rs @@ -4,51 +4,32 @@ use super::*; // -// #[ test_tools::nightly ] -// #[ cfg( feature = "nightly" ) ] -// #[ cfg( RUSTC_IS_NIGHTLY ) ] -#[ cfg( not( RUSTC_IS_STABLE ) ) ] -tests_impls! +#[ test ] +fn inspect_to_str_type_of_test() { - fn inspect_to_str_type_of_test() - { + let exp = "sizeof( &[1, 2, 3][..] : &[i32] ) = 16".to_string(); + let got = the_module::inspect_to_str_type_of!( &[ 1, 2, 3 ][ .. ] ); + assert_eq!( got, exp ); - let exp = "sizeof( &[1, 2, 3][..] : &[i32] ) = 16".to_string(); - let got = the_module::inspect_to_str_type_of!( &[ 1, 2, 3 ][ .. ] ); - a_id!( got, exp ); - - let exp = "sizeof( &[1, 2, 3] : &[i32; 3] ) = 8".to_string(); - let got = the_module::inspect_to_str_type_of!( &[ 1, 2, 3 ] ); - a_id!( got, exp ); - - } - - // - - fn inspect_type_of_macro() - { - - let exp = "sizeof( &[1, 2, 3][..] : &[i32] ) = 16".to_string(); - let got = the_module::inspect_type_of!( &[ 1, 2, 3 ][ .. ] ); - a_id!( got, exp ); - - let exp = "sizeof( &[1, 2, 3] : &[i32; 3] ) = 8".to_string(); - let got = the_module::inspect_type_of!( &[ 1, 2, 3 ] ); - a_id!( got, exp ); - - } + let exp = "sizeof( &[1, 2, 3] : &[i32; 3] ) = 8".to_string(); + let got = the_module::inspect_to_str_type_of!( &[ 1, 2, 3 ] ); + assert_eq!( got, exp ); } // -// #[ test_tools::nightly ] -// #[ cfg( feature = "nightly" ) ] -// #[ cfg( RUSTC_IS_NIGHTLY ) ] -#[ cfg( not( RUSTC_IS_STABLE ) ) ] -tests_index! +#[ test ] +fn inspect_type_of_macro() { - inspect_to_str_type_of_test, - inspect_type_of_macro, + + let exp = "sizeof( &[1, 2, 3][..] : &[i32] ) = 16".to_string(); + let got = the_module::inspect_type_of!( &[ 1, 2, 3 ][ .. ] ); + assert_eq!( got, exp ); + + let exp = "sizeof( &[1, 2, 3] : &[i32; 3] ) = 8".to_string(); + let got = the_module::inspect_type_of!( &[ 1, 2, 3 ] ); + assert_eq!( got, exp ); + } diff --git a/module/core/inspect_type/tests/inc/mod.rs b/module/core/inspect_type/tests/inc/mod.rs index d8be619a97..9e35103f83 100644 --- a/module/core/inspect_type/tests/inc/mod.rs +++ b/module/core/inspect_type/tests/inc/mod.rs @@ -1,4 +1,4 @@ -#[ allow( unused_imports ) ] use super::*; +// use test_tools::exposed::*; mod inspect_type_test; diff --git a/module/core/inspect_type/tests/smoke_test.rs b/module/core/inspect_type/tests/smoke_test.rs index 828e9b016b..ee06731048 100644 --- a/module/core/inspect_type/tests/smoke_test.rs +++ b/module/core/inspect_type/tests/smoke_test.rs @@ -1,14 +1,13 @@ - - -#[ test ] -fn local_smoke_test() -{ - ::test_tools::smoke_test_for_local_run(); -} - - -#[ test ] -fn published_smoke_test() -{ - ::test_tools::smoke_test_for_published_run(); -} +//! Smoke testing of the package. + +// #[ test ] +// fn local_smoke_test() +// { +// ::test_tools::smoke_test_for_local_run(); +// } +// +// #[ test ] +// fn published_smoke_test() +// { +// ::test_tools::smoke_test_for_published_run(); +// } diff --git a/module/core/inspect_type/tests/tests.rs b/module/core/inspect_type/tests/tests.rs index 8e5818a1f9..4ac3f797ab 100644 --- a/module/core/inspect_type/tests/tests.rs +++ b/module/core/inspect_type/tests/tests.rs @@ -1,5 +1,7 @@ -// #![ allow( unexpected_cfgs ) ] +//! All Tests +#![ allow( unused_imports ) ] +// #![ allow( unexpected_cfgs ) ] // #![ no_std ] // #![ cfg_attr( feature = "no_std", no_std ) ] @@ -7,16 +9,12 @@ // #![ test_tools::nightly ] // #![ cfg_attr( feature = "type_name_of_val", feature( type_name_of_val ) ) ] // #![ cfg_attr( rustversion::nightly, feature( type_name_of_val ) ) ] -// #![cfg_attr(docsrs, feature(doc_cfg))] +// #![ cfg_attr( docsrs, feature( doc_cfg ) ) ] // // #![ cfg_attr( feature = "nightly", feature( type_name_of_val ) ) ] // #![ cfg_attr( feature = "nightly", feature( trace_macros ) ) ] // #![ cfg_attr( feature = "nightly", feature( meta_idents_concat ) ) ] // #![ cfg_attr( RUSTC_IS_NIGHTLY, feature( type_name_of_val ) ) ] -#[ allow( unused_imports ) ] use inspect_type as the_module; -#[ allow( unused_imports ) ] -use test_tools::exposed::*; - mod inc; diff --git a/module/core/interval_adapter/Cargo.toml b/module/core/interval_adapter/Cargo.toml index 787fac61c8..147d0f621f 100644 --- a/module/core/interval_adapter/Cargo.toml +++ b/module/core/interval_adapter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "interval_adapter" -version = "0.27.0" +version = "0.28.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/is_slice/Cargo.toml b/module/core/is_slice/Cargo.toml index 2854cf37cd..cde98e4390 100644 --- a/module/core/is_slice/Cargo.toml +++ b/module/core/is_slice/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "is_slice" -version = "0.11.0" +version = "0.12.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -32,4 +32,5 @@ enabled = [] [dependencies] [dev-dependencies] -test_tools = { workspace = true } +# this crate should not rely on test_tools to exclude cyclic dependencies +# test_tools = { workspace = true } diff --git a/module/core/is_slice/tests/inc/is_slice_test.rs b/module/core/is_slice/tests/inc/is_slice_test.rs index 19d026fde5..ae247a9cb3 100644 --- a/module/core/is_slice/tests/inc/is_slice_test.rs +++ b/module/core/is_slice/tests/inc/is_slice_test.rs @@ -2,33 +2,23 @@ use super::*; // -tests_impls! +#[ test ] +fn is_slice_basic() { - #[ test ] - fn is_slice_basic() - { - let src : &[ i32 ] = &[ 1, 2, 3 ]; - a_id!( the_module::is_slice!( src ), true ); - a_id!( the_module::is_slice!( &[ 1, 2, 3 ][ .. ] ), true ); - a_id!( the_module::is_slice!( &[ 1, 2, 3 ] ), false ); + let src : &[ i32 ] = &[ 1, 2, 3 ]; + assert_eq!( the_module::is_slice!( src ), true ); + assert_eq!( the_module::is_slice!( &[ 1, 2, 3 ][ .. ] ), true ); + assert_eq!( the_module::is_slice!( &[ 1, 2, 3 ] ), false ); - // the_module::inspect_type_of!( &[ 1, 2, 3 ][ .. ] ); - // the_module::inspect_type_of!( &[ 1, 2, 3 ] ); + // the_module::inspect_type_of!( &[ 1, 2, 3 ][ .. ] ); + // the_module::inspect_type_of!( &[ 1, 2, 3 ] ); - a_id!( the_module::is_slice!( vec!( 1, 2, 3 ) ), false ); - a_id!( the_module::is_slice!( 13_f32 ), false ); - a_id!( the_module::is_slice!( true ), false ); - let src = false; - a_id!( the_module::is_slice!( src ), false ); - a_id!( the_module::is_slice!( Box::new( true ) ), false ); - let src = Box::new( true ); - a_id!( the_module::is_slice!( src ), false ); - } -} - -// - -tests_index! -{ - is_slice_basic, + assert_eq!( the_module::is_slice!( vec!( 1, 2, 3 ) ), false ); + assert_eq!( the_module::is_slice!( 13_f32 ), false ); + assert_eq!( the_module::is_slice!( true ), false ); + let src = false; + assert_eq!( the_module::is_slice!( src ), false ); + assert_eq!( the_module::is_slice!( Box::new( true ) ), false ); + let src = Box::new( true ); + assert_eq!( the_module::is_slice!( src ), false ); } diff --git a/module/core/is_slice/tests/inc/mod.rs b/module/core/is_slice/tests/inc/mod.rs index d2e9305da9..3e91d401d9 100644 --- a/module/core/is_slice/tests/inc/mod.rs +++ b/module/core/is_slice/tests/inc/mod.rs @@ -1,6 +1,5 @@ -#![ no_std ] -#[ allow( unused_imports ) ] use super::*; +// use test_tools::exposed::*; mod is_slice_test; diff --git a/module/core/is_slice/tests/is_slice_tests.rs b/module/core/is_slice/tests/is_slice_tests.rs index 6aad89f853..b859cf6263 100644 --- a/module/core/is_slice/tests/is_slice_tests.rs +++ b/module/core/is_slice/tests/is_slice_tests.rs @@ -1,11 +1,11 @@ -// #![cfg_attr(docsrs, feature(doc_cfg))] +//! Smoke testing of the package. + +// #![ cfg_attr( docsrs, feature( doc_cfg ) ) ] // #![ cfg_attr( feature = "nightly", feature( type_name_of_val ) ) ] // #![ feature( type_name_of_val ) ] // #![ feature( trace_macros ) ] // #![ feature( meta_idents_concat ) ] +#![ allow( unused_imports ) ] -use test_tools::exposed::*; use is_slice as the_module; - -// #[ path = "./inc.rs" ] mod inc; diff --git a/module/core/is_slice/tests/smoke_test.rs b/module/core/is_slice/tests/smoke_test.rs index 828e9b016b..ee06731048 100644 --- a/module/core/is_slice/tests/smoke_test.rs +++ b/module/core/is_slice/tests/smoke_test.rs @@ -1,14 +1,13 @@ - - -#[ test ] -fn local_smoke_test() -{ - ::test_tools::smoke_test_for_local_run(); -} - - -#[ test ] -fn published_smoke_test() -{ - ::test_tools::smoke_test_for_published_run(); -} +//! Smoke testing of the package. + +// #[ test ] +// fn local_smoke_test() +// { +// ::test_tools::smoke_test_for_local_run(); +// } +// +// #[ test ] +// fn published_smoke_test() +// { +// ::test_tools::smoke_test_for_published_run(); +// } diff --git a/module/core/iter_tools/Cargo.toml b/module/core/iter_tools/Cargo.toml index 7e4dcad983..a909fca7c0 100644 --- a/module/core/iter_tools/Cargo.toml +++ b/module/core/iter_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iter_tools" -version = "0.24.0" +version = "0.26.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/iter_tools/tests/smoke_test.rs b/module/core/iter_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/iter_tools/tests/smoke_test.rs +++ b/module/core/iter_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/macro_tools/Cargo.toml b/module/core/macro_tools/Cargo.toml index 99877d2e6f..7d98c4f745 100644 --- a/module/core/macro_tools/Cargo.toml +++ b/module/core/macro_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "macro_tools" -version = "0.44.0" +version = "0.46.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/macro_tools/tests/smoke_test.rs b/module/core/macro_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/macro_tools/tests/smoke_test.rs +++ b/module/core/macro_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/mem_tools/tests/inc/mem_test.rs b/module/core/mem_tools/tests/inc/mem_test.rs index 1b2fa2954e..bc9a9ce519 100644 --- a/module/core/mem_tools/tests/inc/mem_test.rs +++ b/module/core/mem_tools/tests/inc/mem_test.rs @@ -8,21 +8,21 @@ tests_impls! fn same_data() { let buf = [ 0u8; 128 ]; - a_true!( the_module::same_data( &buf, &buf ) ); + a_true!( the_module::mem::same_data( &buf, &buf ) ); let x = [ 0u8; 1 ]; let y = 0u8; - a_true!( the_module::same_data( &x, &y ) ); + a_true!( the_module::mem::same_data( &x, &y ) ); - a_false!( the_module::same_data( &buf, &x ) ); - a_false!( the_module::same_data( &buf, &y ) ); + a_false!( the_module::mem::same_data( &buf, &x ) ); + a_false!( the_module::mem::same_data( &buf, &y ) ); struct H1( &'static str ); struct H2( &'static str ); - a_true!( the_module::same_data( &H1( "hello" ), &H2( "hello" ) ) ); - a_false!( the_module::same_data( &H1( "qwerty" ), &H2( "hello" ) ) ); + a_true!( the_module::mem::same_data( &H1( "hello" ), &H2( "hello" ) ) ); + a_false!( the_module::mem::same_data( &H1( "qwerty" ), &H2( "hello" ) ) ); } @@ -31,15 +31,15 @@ tests_impls! let src1 = "abc"; let src2 = "abc"; - a_true!( the_module::same_ptr( src1, src2 ) ); + a_true!( the_module::mem::same_ptr( src1, src2 ) ); let src1 = ( 1, ); let src2 = ( 1, ); - a_false!( the_module::same_ptr( &src1, &src2 ) ); + a_false!( the_module::mem::same_ptr( &src1, &src2 ) ); let src1 = ( 1 ); let src2 = "abcde"; - a_false!( the_module::same_ptr( &src1, src2 ) ); + a_false!( the_module::mem::same_ptr( &src1, src2 ) ); } @@ -50,15 +50,15 @@ tests_impls! let src1 = "abc"; let src2 = "cba"; - a_true!( the_module::same_size( src1, src2 ) ); + a_true!( the_module::mem::same_size( src1, src2 ) ); let src1 = ( 1, ); let src2 = ( 3, ); - a_true!( the_module::same_size( &src1, &src2 ) ); + a_true!( the_module::mem::same_size( &src1, &src2 ) ); let src1 = ( 1 ); let src2 = "abcde"; - a_false!( the_module::same_size( &src1, src2 ) ); + a_false!( the_module::mem::same_size( &src1, src2 ) ); } @@ -69,15 +69,15 @@ tests_impls! let src1 = "abc"; let src2 = "abc"; - a_true!( the_module::same_region( src1, src2 ) ); + a_true!( the_module::mem::same_region( src1, src2 ) ); let src1 = ( 1, ); let src2 = ( 1, ); - a_false!( the_module::same_region( &src1, &src2 ) ); + a_false!( the_module::mem::same_region( &src1, &src2 ) ); let src1 = ( 1 ); let src2 = "abcde"; - a_false!( the_module::same_region( &src1, src2 ) ); + a_false!( the_module::mem::same_region( &src1, src2 ) ); } @@ -85,24 +85,23 @@ tests_impls! fn samples() { - use the_module as mem; // Are two pointers are the same, not taking into accoint type. // Unlike `std::ptr::eq()` does not require arguments to have the same type. let src1 = ( 1, ); let src2 = ( 1, ); - assert!( !mem::same_ptr( &src1, &src2 ) ); + assert!( !the_module::mem::same_ptr( &src1, &src2 ) ); // Are two pointers points on data of the same size. let src1 = "abc"; let src2 = "cba"; - assert!( mem::same_size( src1, src2 ) ); + assert!( the_module::mem::same_size( src1, src2 ) ); // Are two pointers points on the same region, ie same size and same pointer. // Does not require arguments to have the same type. let src1 = "abc"; let src2 = "abc"; - assert!( mem::same_region( src1, src2 ) ); + assert!( the_module::mem::same_region( src1, src2 ) ); } diff --git a/module/core/mem_tools/tests/inc/mod.rs b/module/core/mem_tools/tests/inc/mod.rs index 9147b3ddcc..cc1110aad5 100644 --- a/module/core/mem_tools/tests/inc/mod.rs +++ b/module/core/mem_tools/tests/inc/mod.rs @@ -1,4 +1,7 @@ #[ allow( unused_imports ) ] use super::*; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + mod mem_test; diff --git a/module/core/mem_tools/tests/mem_tools_tests.rs b/module/core/mem_tools/tests/mem_tools_tests.rs index 5f9856b952..51260d5101 100644 --- a/module/core/mem_tools/tests/mem_tools_tests.rs +++ b/module/core/mem_tools/tests/mem_tools_tests.rs @@ -1,3 +1,5 @@ +//! All tests. + // #![ deny( rust_2018_idioms ) ] // #![ deny( missing_debug_implementations ) ] // #![ deny( missing_docs ) ] @@ -5,8 +7,5 @@ // #![ feature( trace_macros ) ] // #![ feature( type_name_of_val ) ] -#[ allow( unused_imports ) ] -use test_tools::exposed::*; use mem_tools as the_module; - mod inc; diff --git a/module/core/mem_tools/tests/smoke_test.rs b/module/core/mem_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/mem_tools/tests/smoke_test.rs +++ b/module/core/mem_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/meta_tools/tests/smoke_test.rs b/module/core/meta_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/meta_tools/tests/smoke_test.rs +++ b/module/core/meta_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/mod_interface/Cargo.toml b/module/core/mod_interface/Cargo.toml index 8f3e3f76f4..5853e418e2 100644 --- a/module/core/mod_interface/Cargo.toml +++ b/module/core/mod_interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mod_interface" -version = "0.30.0" +version = "0.31.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/mod_interface_meta/Cargo.toml b/module/core/mod_interface_meta/Cargo.toml index ab3e6c709c..69ba680466 100644 --- a/module/core/mod_interface_meta/Cargo.toml +++ b/module/core/mod_interface_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mod_interface_meta" -version = "0.29.0" +version = "0.30.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/mod_interface_meta/tests/smoke_test.rs b/module/core/mod_interface_meta/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/mod_interface_meta/tests/smoke_test.rs +++ b/module/core/mod_interface_meta/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/process_tools/Cargo.toml b/module/core/process_tools/Cargo.toml index e358031ef1..ffd2498fea 100644 --- a/module/core/process_tools/Cargo.toml +++ b/module/core/process_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "process_tools" -version = "0.12.0" +version = "0.13.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -19,12 +19,10 @@ keywords = [ "fundamental", "general-purpose" ] [lints] workspace = true - [package.metadata.docs.rs] features = [ "full" ] all-features = false - [features] default = [ "enabled", "process_environment_is_cicd" ] full = [ "default" ] diff --git a/module/core/process_tools/tests/smoke_test.rs b/module/core/process_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/process_tools/tests/smoke_test.rs +++ b/module/core/process_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/program_tools/tests/smoke_test.rs b/module/core/program_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/program_tools/tests/smoke_test.rs +++ b/module/core/program_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/pth/Cargo.toml b/module/core/pth/Cargo.toml index 79a2141441..0d06f333ef 100644 --- a/module/core/pth/Cargo.toml +++ b/module/core/pth/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pth" -version = "0.21.0" +version = "0.22.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/pth/tests/smoke_test.rs b/module/core/pth/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/pth/tests/smoke_test.rs +++ b/module/core/pth/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/reflect_tools/Cargo.toml b/module/core/reflect_tools/Cargo.toml index 80718672c4..6d4715039d 100644 --- a/module/core/reflect_tools/Cargo.toml +++ b/module/core/reflect_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reflect_tools" -version = "0.3.0" +version = "0.4.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/reflect_tools/tests/smoke_test.rs b/module/core/reflect_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/reflect_tools/tests/smoke_test.rs +++ b/module/core/reflect_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/reflect_tools_meta/Cargo.toml b/module/core/reflect_tools_meta/Cargo.toml index bd525a2655..3225c58663 100644 --- a/module/core/reflect_tools_meta/Cargo.toml +++ b/module/core/reflect_tools_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reflect_tools_meta" -version = "0.3.0" +version = "0.4.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/strs_tools/tests/smoke_test.rs b/module/core/strs_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/strs_tools/tests/smoke_test.rs +++ b/module/core/strs_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/test_tools/.cargo/config.toml b/module/core/test_tools/.cargo/config.toml new file mode 100644 index 0000000000..14735242a8 --- /dev/null +++ b/module/core/test_tools/.cargo/config.toml @@ -0,0 +1,5 @@ + +[build] +rustdocflags = [ + "--cfg", "feature=\"doctest\"", +] diff --git a/module/core/test_tools/Cargo.toml b/module/core/test_tools/Cargo.toml index 4f17161640..19d9c3e617 100644 --- a/module/core/test_tools/Cargo.toml +++ b/module/core/test_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_tools" -version = "0.11.0" +version = "0.12.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -21,74 +21,64 @@ keywords = [ "fundamental", "general-purpose", "testing" ] workspace = true [package.metadata.docs.rs] -features = [ "full" ] +features = [ "normal_build", "enabled" ] all-features = false +no-default-features = false +# features = [ "full" ] +# all-features = false # = features [features] default = [ "enabled", - # "standalone", - "normal", + "standalone_build", + # "normal_build", + "process_tools", + "process_environment_is_cicd", ] -full = [ "default" ] +full = [ + "default" +] +doctest = [] # for doctest shorcaomings resolution +# doctest does not work properly for aggregators no_std = [ - # "error_tools/no_std", - # "meta_tools/no_std", - # "mem_tools/no_std", - # "typing_tools/no_std", - # "data_type/no_std", - # "diagnostics_tools/no_std", - # "process_tools_published/no_std", - # "former_stable/use_alloc", ] use_alloc = [ "no_std", - # "error_tools/use_alloc", - # "meta_tools/use_alloc", - # "mem_tools/use_alloc", - # "typing_tools/use_alloc", - # "data_type/use_alloc", - # "diagnostics_tools/use_alloc", - # "process_tools_published/use_alloc", - # "former_stable/use_alloc", ] enabled = [ - # "error_tools/enabled", - # "meta_tools/enabled", - # "mem_tools/enabled", - # "typing_tools/enabled", - # "data_type/enabled", - # "diagnostics_tools/enabled", - # "process_tools/enabled", - # "collection_tools/enabled", ] # nightly = [ "typing_tools/nightly" ] -normal = [ - "dep:error_tools", - "dep:collection_tools", - "dep:impls_index", - "dep:mem_tools", - "dep:typing_tools", - "dep:diagnostics_tools", - "dep:process_tools", +normal_build = [ + # "dep:error_tools", + # "dep:collection_tools", + # "dep:impls_index", + # "dep:mem_tools", + # "dep:typing_tools", + # "dep:diagnostics_tools", + # # "dep:process_tools", ] -standalone = [ + +# standalone_build vesion of build is used to avoid cyclic dependency +# when crate depend on itself +standalone_build = [ "standalone_error_tools", "standalone_collection_tools", "standalone_impls_index", "standalone_mem_tools", - # "dep:mem_tools", - "dep:typing_tools", - "dep:diagnostics_tools", - "dep:process_tools", + "standalone_typing_tools", + "standalone_diagnostics_tools", + # "standalone_process_tools", + # "dep:process_tools", ] standalone_error_tools = [ "dep:anyhow", "dep:thiserror", "error_typed", "error_untyped" ] standalone_collection_tools = [ "dep:hashbrown", "collection_constructors", "collection_into_constructors" ] standalone_impls_index = [ "dep:impls_index_meta" ] standalone_mem_tools = [] +standalone_typing_tools = [ "typing_implements", "typing_is_slice", "typing_inspect_type" ] +standalone_diagnostics_tools = [ "diagnostics_runtime_assertions", "diagnostics_compiletime_assertions", "diagnostics_memory_layout" ] # error_tools error_typed = [] @@ -96,29 +86,39 @@ error_untyped = [] # collection_tools collection_constructors = [] collection_into_constructors = [] +# typing_tools +typing_inspect_type = [ "inspect_type/enabled" ] +typing_is_slice = [ "is_slice/enabled" ] +typing_implements = [ "implements/enabled" ] +# diagnostics_tools +diagnostics_runtime_assertions = [ "dep:pretty_assertions" ] # run-time assertions +diagnostics_compiletime_assertions = [] # compile-time assertions +diagnostics_memory_layout = [] # +# process_tools +process_tools = [] +process_environment_is_cicd = [] [dependencies] ## external -trybuild = { version = "1.0.85", features = [ "diff" ] } +# xxx : make sure we use workspace dependencies only +# trybuild = { version = "1.0.85", features = [ "diff" ] } +trybuild = { workspace = true, features = [ "diff" ] } rustversion = { workspace = true } num-traits = { workspace = true } rand = { workspace = true } # tempdir = { workspace = true } -## internal - -error_tools = { workspace = true, features = [ "full" ], optional = true } -collection_tools = { workspace = true, features = [ "full" ], optional = true } -impls_index = { workspace = true, features = [ "full" ], optional = true } -mem_tools = { workspace = true, features = [ "full" ], optional = true } - -typing_tools = { workspace = true, features = [ "full" ], optional = true } -diagnostics_tools = { workspace = true, features = [ "full" ], optional = true } -process_tools = { workspace = true, features = [ "full" ], optional = true } - -# former_stable = { workspace = true, features = [ "full" ] } +# ## internal +# +# error_tools = { workspace = true, features = [ "full" ], optional = true } +# collection_tools = { workspace = true, features = [ "full" ], optional = true } +# impls_index = { workspace = true, features = [ "full" ], optional = true } +# mem_tools = { workspace = true, features = [ "full" ], optional = true } +# typing_tools = { workspace = true, features = [ "full" ], optional = true } +# diagnostics_tools = { workspace = true, features = [ "full" ], optional = true } +# # process_tools = { workspace = true, features = [ "full" ], optional = true } ## transient @@ -129,6 +129,12 @@ thiserror = { workspace = true, optional = true } hashbrown = { workspace = true, optional = true } # impls_index impls_index_meta = { workspace = true, optional = true } +# typing_tools +inspect_type = { workspace = true, optional = true } +is_slice = { workspace = true, optional = true } +implements = { workspace = true, optional = true } +# diagnostics_tools +pretty_assertions = { workspace = true, optional = true } [build-dependencies] rustc_version = "0.4" diff --git a/module/core/test_tools/src/lib.rs b/module/core/test_tools/src/lib.rs index 4d1b25124e..31a90abcf7 100644 --- a/module/core/test_tools/src/lib.rs +++ b/module/core/test_tools/src/lib.rs @@ -4,10 +4,23 @@ #![ doc( html_root_url = "https://docs.rs/test_tools/latest/test_tools/" ) ] #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] +// xxx : remove +//! ```rust +//! println!("-- doc test: printing Cargo feature environment variables --"); +//! for (key, val) in std::env::vars() { +//! if key.starts_with("CARGO_FEATURE_") { +//! println!("{}={}", key, val); +//! } +//! } +//! ``` + +// xxx2 : try to repurpose top-level lib.rs fiel for only top level features + /// Namespace with dependencies. #[ allow( unused_imports ) ] #[ cfg( feature = "enabled" ) ] +#[ cfg( not( feature = "doctest" ) ) ] pub mod dependency { @@ -21,6 +34,11 @@ pub mod dependency #[ doc( inline ) ] pub use ::num_traits; + #[ cfg( all( feature = "standalone_build", not( feature = "normal_build" ) ) ) ] + #[ cfg( feature = "standalone_diagnostics_tools" ) ] + #[ doc( inline ) ] + pub use ::pretty_assertions; + #[ doc( inline ) ] pub use super:: { @@ -30,7 +48,7 @@ pub mod dependency mem_tools, typing_tools, diagnostics_tools, - process_tools, + // process_tools, }; } @@ -94,23 +112,31 @@ mod private {} // pub use test::{ compiletime, helper, smoke_test }; #[ cfg( feature = "enabled" ) ] +#[ cfg( not( feature = "doctest" ) ) ] pub mod test; -/// Error tools. +/// Aggegating submodules without using cargo, but including their entry files directly. +/// +/// We don't want to run doctest of included files, because all of the are relative to submodule. +/// So we disable doctests of such submodules with `#[ cfg( not( doctest ) ) ]`. #[ cfg( feature = "enabled" ) ] -#[ cfg( feature = "standalone" ) ] +#[ cfg( not( feature = "doctest" ) ) ] +// #[ cfg( all( feature = "no_std", feature = "use_alloc" ) ) ] +#[ cfg( all( feature = "standalone_build", not( feature = "normal_build" ) ) ) ] +// #[ cfg( any( not( doctest ), not( feature = "standalone_build" ) ) ) ] mod standalone { + // We don't want to run doctest of aggregate /// Error tools. #[ path = "../../../../core/error_tools/src/error/mod.rs" ] - pub mod error; - pub use error as error_tools; + pub mod error_tools; + pub use error_tools as error; /// Collection tools. #[ path = "../../../../core/collection_tools/src/collection/mod.rs" ] - pub mod collection; - pub use collection as collection_tools; + pub mod collection_tools; + pub use collection_tools as collection; /// impl and index macros. #[ path = "../../../../core/impls_index/src/impls_index/mod.rs" ] @@ -119,38 +145,55 @@ mod standalone /// Memory tools. #[ path = "../../../../core/mem_tools/src/mem.rs" ] pub mod mem_tools; + pub use mem_tools as mem; + + /// Typing tools. + #[ path = "../../../../core/typing_tools/src/typing.rs" ] + pub mod typing_tools; + pub use typing_tools as typing; + + /// Dagnostics tools. + #[ path = "../../../../core/diagnostics_tools/src/diag/mod.rs" ] + pub mod diagnostics_tools; + pub use diagnostics_tools as diag; } #[ cfg( feature = "enabled" ) ] -#[ cfg( feature = "standalone" ) ] +#[ cfg( not( feature = "doctest" ) ) ] +#[ cfg( all( feature = "standalone_build", not( feature = "normal_build" ) ) ) ] pub use standalone::*; #[ cfg( feature = "enabled" ) ] -#[ cfg( not( feature = "standalone" ) ) ] +#[ cfg( not( feature = "doctest" ) ) ] +#[ cfg( not( all( feature = "standalone_build", not( feature = "normal_build" ) ) ) ) ] pub use :: { error_tools, collection_tools, impls_index, mem_tools, + typing_tools, + diagnostics_tools, }; #[ cfg( feature = "enabled" ) ] +#[ cfg( not( feature = "doctest" ) ) ] +#[ allow( unused_imports ) ] pub use :: { - typing_tools, - diagnostics_tools, - process_tools, + // process_tools, }; #[ cfg( feature = "enabled" ) ] +#[ cfg( not( feature = "doctest" ) ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use own::*; /// Own namespace of the module. #[ cfg( feature = "enabled" ) ] +#[ cfg( not( feature = "doctest" ) ) ] #[ allow( unused_imports ) ] pub mod own { @@ -177,6 +220,7 @@ pub mod own /// Shared with parent namespace of the module #[ cfg( feature = "enabled" ) ] +#[ cfg( not( feature = "doctest" ) ) ] #[ allow( unused_imports ) ] pub mod orphan { @@ -192,6 +236,7 @@ pub mod orphan /// Exposed namespace of the module. #[ cfg( feature = "enabled" ) ] +#[ cfg( not( feature = "doctest" ) ) ] #[ allow( unused_imports ) ] pub mod exposed { @@ -218,6 +263,7 @@ pub mod exposed /// Prelude to use essentials: `use my_module::prelude::*`. #[ cfg( feature = "enabled" ) ] +#[ cfg( not( feature = "doctest" ) ) ] #[ allow( unused_imports ) ] pub mod prelude { diff --git a/module/core/test_tools/src/test/mod.rs b/module/core/test_tools/src/test/mod.rs index c13f70ef67..b8ee109966 100644 --- a/module/core/test_tools/src/test/mod.rs +++ b/module/core/test_tools/src/test/mod.rs @@ -20,6 +20,7 @@ pub mod compiletime; pub mod helper; pub mod smoke_test; pub mod version; +pub mod process; #[ cfg( feature = "enabled" ) ] #[ doc( inline ) ] @@ -44,6 +45,7 @@ pub mod own helper::orphan::*, smoke_test::orphan::*, version::orphan::*, + process::orphan::*, }; } @@ -78,6 +80,7 @@ pub mod exposed helper::exposed::*, smoke_test::exposed::*, version::exposed::*, + process::exposed::*, }; #[ doc( inline ) ] @@ -107,6 +110,7 @@ pub mod prelude helper::prelude::*, smoke_test::prelude::*, version::prelude::*, + process::prelude::*, }; } diff --git a/module/core/test_tools/src/test/process.rs b/module/core/test_tools/src/test/process.rs new file mode 100644 index 0000000000..bf59d4b314 --- /dev/null +++ b/module/core/test_tools/src/test/process.rs @@ -0,0 +1,63 @@ + +//! +//! Compact version of module::process_tools. What is needed from process tools +//! + +/// Define a private namespace for all its items. +mod private +{ +} + +pub mod environment; + +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use own::*; + +/// Own namespace of the module. +#[ allow( unused_imports ) ] +pub mod own +{ + use super::*; +} + +/// Shared with parent namespace of the module +#[ allow( unused_imports ) ] +pub mod orphan +{ + use super::*; + pub use super::super::process as process_tools; + + #[ doc( inline ) ] + pub use exposed::*; + +} + +/// Exposed namespace of the module. +#[ allow( unused_imports ) ] +pub mod exposed +{ + use super::*; + + #[ doc( inline ) ] + pub use prelude::*; + + #[ doc( inline ) ] + pub use private:: + { + }; + +} + +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ allow( unused_imports ) ] +pub mod prelude +{ + use super::*; + + #[ doc( inline ) ] + pub use + { + }; + +} diff --git a/module/core/test_tools/src/test/process/environment.rs b/module/core/test_tools/src/test/process/environment.rs new file mode 100644 index 0000000000..1f3a146a9b --- /dev/null +++ b/module/core/test_tools/src/test/process/environment.rs @@ -0,0 +1,114 @@ + +//! +//! Environment of a process. +//! + +/// Define a private namespace for all its items. +mod private +{ + + #[ allow( unused_imports ) ] + use crate::*; + + /// Checks if the current execution environment is a Continuous Integration (CI) or Continuous Deployment (CD) pipeline. + /// + /// This function looks for environment variables that are commonly set by CI/CD systems to determine if it's running + /// within such an environment. It supports detection for a variety of popular CI/CD platforms including GitHub Actions, + /// GitLab CI, Travis CI, `CircleCI`, and Jenkins. + /// + /// # Returns + /// - `true` if an environment variable indicating a CI/CD environment is found. + /// - `false` otherwise. + /// + /// # Examples + /// + /// When running in a typical development environment (locally): + /// ```no_run + /// use test_tools::process_tools::environment; + /// assert_eq!( environment::is_cicd(), false ); + /// ``` + /// + /// When running in a CI/CD environment, one of the specified environment variables would be set, and: + /// ```no_run + /// // This example cannot be run as a test since it depends on the environment + /// // the code is executed in. However, in a CI environment, this would return true. + /// use test_tools::process_tools::environment; + /// assert_eq!( environment::is_cicd(), true ); + /// ``` + #[ cfg( feature = "process_environment_is_cicd" ) ] + #[ must_use ] + pub fn is_cicd() -> bool + { + use std::env; + let ci_vars = + [ + "CI", // Common in many CI systems + "GITHUB_ACTIONS", // GitHub Actions + "GITLAB_CI", // GitLab CI + "TRAVIS", // Travis CI + "CIRCLECI", // CircleCI + "JENKINS_URL", // Jenkins + ]; + + ci_vars.iter().any( | &var | env::var( var ).is_ok() ) + } + +} + +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use own::*; + +/// Own namespace of the module. +#[ allow( unused_imports ) ] +pub mod own +{ + use super::*; + + #[ doc( inline ) ] + pub use + { + private::is_cicd, + }; + +} + +/// Shared with parent namespace of the module +#[ allow( unused_imports ) ] +pub mod orphan +{ + use super::*; + + #[ doc( inline ) ] + pub use exposed::*; + +} + +/// Exposed namespace of the module. +#[ allow( unused_imports ) ] +pub mod exposed +{ + use super::*; + + #[ doc( inline ) ] + pub use prelude::*; + + #[ doc( inline ) ] + pub use private:: + { + }; + +} + +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ allow( unused_imports ) ] +pub mod prelude +{ + use super::*; + + #[ doc( inline ) ] + pub use + { + }; + +} diff --git a/module/core/test_tools/src/test/smoke_test.rs b/module/core/test_tools/src/test/smoke_test.rs index a99b4ee1a0..f0d9d7ad00 100644 --- a/module/core/test_tools/src/test/smoke_test.rs +++ b/module/core/test_tools/src/test/smoke_test.rs @@ -250,7 +250,6 @@ mod private } /// Run smoke test for both published and local version of the module. - pub fn smoke_tests_run() { smoke_test_for_local_run(); @@ -344,9 +343,13 @@ pub mod own use super::*; #[ doc( inline ) ] - pub use + pub use private:: { - private::*, + SmokeModuleTest, + smoke_test_run, + smoke_tests_run, + smoke_test_for_local_run, + smoke_test_for_published_run, }; } diff --git a/module/core/test_tools/tests/inc/mod.rs b/module/core/test_tools/tests/inc/mod.rs index a6d6581d75..fa8f21affb 100644 --- a/module/core/test_tools/tests/inc/mod.rs +++ b/module/core/test_tools/tests/inc/mod.rs @@ -3,24 +3,27 @@ use super::*; mod impls_index_test; mod mem_test; mod try_build_test; -// mod wtest_utility; -// qqq : include tests of all internal dependencies +/// Error tools. +#[ path = "../../../../core/error_tools/tests/inc/mod.rs" ] +pub mod error_tests; -// /// Error tools. -// #[ path = "../../../../core/error_tools/tests/inc/mod.rs" ] -// pub mod error; -// pub use error as error_tools; -// -// /// Collection tools. -// #[ path = "../../../../core/collection_tools/tests/inc/mod.rs" ] -// pub mod collection; -// pub use collection as collection_tools; +/// Collection tools. +#[ path = "../../../../core/collection_tools/tests/inc/mod.rs" ] +pub mod collection_tests; -// /// impl and index macros. -// #[ path = "../../../../core/impls_index/tests/inc/mod.rs" ] -// pub mod impls_index; +/// impl and index macros. +#[ path = "../../../../core/impls_index/tests/inc/mod.rs" ] +pub mod impls_index_tests; -// /// Memory tools. -// #[ path = "../../../../core/mem_tools/tests/inc/mod.rs" ] -// pub mod mem_tools; +/// Memory tools. +#[ path = "../../../../core/mem_tools/tests/inc/mod.rs" ] +pub mod mem_tools_tests; + +/// Typing tools. +#[ path = "../../../../core/typing_tools/tests/inc/mod.rs" ] +pub mod typing_tools_tests; + +/// Diagnostics tools. +#[ path = "../../../../core/diagnostics_tools/tests/inc/mod.rs" ] +pub mod diagnostics_tools_tests; diff --git a/module/core/test_tools/tests/smoke_test.rs b/module/core/test_tools/tests/smoke_test.rs index d05a55b089..d31bbdb5e5 100644 --- a/module/core/test_tools/tests/smoke_test.rs +++ b/module/core/test_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the crate. #[ cfg( feature = "enabled" ) ] #[ cfg( not( feature = "no_std" ) ) ] diff --git a/module/core/test_tools/tests/tests.rs b/module/core/test_tools/tests/tests.rs index c9b1261fb2..68d3dc1ed4 100644 --- a/module/core/test_tools/tests/tests.rs +++ b/module/core/test_tools/tests/tests.rs @@ -1,9 +1,13 @@ +//! All test. + #![ allow( unused_imports ) ] // #![ deny( rust_2018_idioms ) ] // #![ deny( missing_debug_implementations ) ] // #![ deny( missing_docs ) ] +include!( "../../../../module/step/meta/src/module/aggregating.rs" ); + use test_tools as the_module; // #[ cfg( feature = "enabled" ) ] diff --git a/module/core/time_tools/tests/smoke_test.rs b/module/core/time_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/time_tools/tests/smoke_test.rs +++ b/module/core/time_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/typing_tools/Cargo.toml b/module/core/typing_tools/Cargo.toml index 2d75db2449..97878deab1 100644 --- a/module/core/typing_tools/Cargo.toml +++ b/module/core/typing_tools/Cargo.toml @@ -25,8 +25,6 @@ workspace = true features = [ "full" ] all-features = false - - [features] default = [ diff --git a/module/core/typing_tools/tests/inc/mod.rs b/module/core/typing_tools/tests/inc/mod.rs index f6849e47df..992c678289 100644 --- a/module/core/typing_tools/tests/inc/mod.rs +++ b/module/core/typing_tools/tests/inc/mod.rs @@ -1,8 +1,8 @@ -#[ allow( unused_imports ) ] use super::*; -#[ allow( unused_imports ) ] -use the_module::typing as the_module; +use test_tools::exposed::*; +// #[ allow( unused_imports ) ] +// use the_module::typing as the_module; #[ path = "../../../../core/implements/tests/inc/mod.rs" ] mod implements_test; diff --git a/module/core/typing_tools/tests/smoke_test.rs b/module/core/typing_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/typing_tools/tests/smoke_test.rs +++ b/module/core/typing_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/typing_tools/tests/tests.rs b/module/core/typing_tools/tests/tests.rs index 9f9c82cedc..090a22e25b 100644 --- a/module/core/typing_tools/tests/tests.rs +++ b/module/core/typing_tools/tests/tests.rs @@ -1,10 +1,9 @@ -// xxx -#![ cfg_attr( feature = "type_name_of_val", feature( type_name_of_val ) ) ] +//! All tests. + +// #![ cfg_attr( feature = "type_name_of_val", feature( type_name_of_val ) ) ] // // #![ cfg_attr( feature = "nightly", feature( type_name_of_val ) ) ] +#![ allow( unused_imports ) ] -#[ allow( unused_imports ) ] -use test_tools::exposed::*; -#[ allow( unused_imports ) ] use typing_tools as the_module; mod inc; diff --git a/module/core/variadic_from/Cargo.toml b/module/core/variadic_from/Cargo.toml index 073a4f994a..7cecdbc449 100644 --- a/module/core/variadic_from/Cargo.toml +++ b/module/core/variadic_from/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "variadic_from" -version = "0.27.0" +version = "0.28.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/variadic_from/tests/smoke_test.rs b/module/core/variadic_from/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/variadic_from/tests/smoke_test.rs +++ b/module/core/variadic_from/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/wtools/tests/smoke_test.rs b/module/core/wtools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/core/wtools/tests/smoke_test.rs +++ b/module/core/wtools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/move/assistant/src/agents.rs b/module/move/assistant/src/agents.rs deleted file mode 100644 index 0f04d8a61c..0000000000 --- a/module/move/assistant/src/agents.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! -//! Main module for agents framework. -//! - -mod private {} - -crate::mod_interface! -{ - - layer path; - layer context; - layer scenario_raw; - layer scenario_raw_processors; - layer scenario_processed; - -} \ No newline at end of file diff --git a/module/move/assistant/src/agents/context.rs b/module/move/assistant/src/agents/context.rs deleted file mode 100644 index a18a535780..0000000000 --- a/module/move/assistant/src/agents/context.rs +++ /dev/null @@ -1,150 +0,0 @@ -//! -//! Context representation. Can be used as compile-time context and as a runtime-context. -//! -//! Represents a simplistic "filesystem" with directories and terminal objects. -//! - -mod private -{ - use std::collections::HashMap; - - use crate::*; - use agents::path:: - { - Path, - PATH_SEPARATOR, - }; - - /// Represents a directory in a simplistic in-memory "filesystem" - /// with other directories and terminal objects. - /// - /// `T` is the type of terminal object. - #[ derive( Debug, PartialEq, Clone, Default ) ] - pub struct ContextDir< T > - { - /// Internal map of entry names and entries data (a directory or a terminal object). - map : HashMap< String, ContextEntry< T > >, - } - - impl< T > ContextDir< T > - { - /// Create an empty `ContextDir`. - pub fn new() -> Self - { - Self - { - map : HashMap::new() - } - } - - /// Add new entry to the directory. - /// - /// Returns `true` if entry was successfully added. - /// Returns `false` if there is already and entry with such name. - /// Old entry will not be overriden. - pub fn add( &mut self, name : impl Into< String >, entry : ContextEntry< T > ) -> bool - { - let name = name.into(); - - if self.map.contains_key( name.as_str() ) - { - false - } - else - { - self.map.insert( name, entry ); - true - } - } - - /// Get an entry by its name. Returns `None` is there is no such entry. - /// - /// `name` must be a valid path item. Refer to `path::PATH_ITEM_REGEX_STR` for syntax. - /// - /// This method is useful for quickly getting an entry only by its name. - /// For complex paths, where your object is located in several consecutives directories, - /// you can use `Path` type and use method `ContextDir::get_by_path`. - pub fn get( &self, name : impl AsRef< str > ) -> Option< &ContextEntry< T > > - { - self.map.get( name.as_ref() ) - } - - /// Get an entry by its path. Returns `None` is there is no such entry. - /// - /// This function accepts both relative and absolute paths and it will - /// treat itself as the root. - pub fn get_by_path( &self, path : &Path ) -> Option< &ContextEntry< T > > - { - let mut cur : Option< &ContextEntry< T > > = None; - - for component in path.components() - { - if component == PATH_SEPARATOR - { - continue; - } - - match cur - { - None => - { - cur = self.get( component ); - }, - - Some( entry ) => - { - match entry - { - ContextEntry::Terminal( _ ) => - { - return None; - }, - - ContextEntry::Dir( dir ) => - { - cur = dir.get( component ); - } - } - } - } - - if cur.is_none() - { - return None; - } - } - - cur - } - } - - /// Entry in a simplistic in-memory "filesystem": either a directory or a terminal object `T`. - /// - /// Notice, this struct does not store the name of the entry. - #[ derive( Debug, PartialEq, Clone ) ] - pub enum ContextEntry< T > - { - /// Directory in context. - Dir( ContextDir< T > ), - - /// Terminal object. - Terminal( T ), - } - - impl< T > Into< ContextEntry< T > > for ContextDir< T > - { - fn into( self ) -> ContextEntry< T > - { - ContextEntry::Dir( self ) - } - } -} - -crate::mod_interface! -{ - own use - { - ContextDir, - ContextEntry, - }; -} \ No newline at end of file diff --git a/module/move/assistant/src/agents/path.rs b/module/move/assistant/src/agents/path.rs deleted file mode 100644 index d0c29a15dd..0000000000 --- a/module/move/assistant/src/agents/path.rs +++ /dev/null @@ -1,241 +0,0 @@ -//! -//! Paths in agents graph. -//! - -mod private -{ - use std:: - { - io, - fmt, - ops::Deref, - sync::LazyLock, - }; - - use serde:: - { - Serialize, - Deserialize, - }; - - use regex::Regex; - - /// Path separator string. - pub const PATH_SEPARATOR : &str = "::"; - - /// Regular expression for `Path` items. Represented in `&str`. - /// It is not anchored to start and end of the string. - /// - /// If you want to match against this expression, use `PATH_ITEM_REGEX`. - pub const PATH_ITEM_REGEX_STR : &str = r"[a-zA-Z0-9_ -]+"; - - /// Regular expression for `Path`. You can match whole `&str` with this type. - pub static PATH_REGEX : LazyLock< Regex > = LazyLock::new( || - { - let regex = format! - ( - r"^({sep})?({item}({sep}{item})*({sep})?)?$", - sep = PATH_SEPARATOR, - item = PATH_ITEM_REGEX_STR, - ); - - Regex::new( ®ex ).unwrap() - }); - - /// New type for paths in agents graph. Use `TryFrom` implementation - /// to create `Path`s. - /// - /// Paths resemble filesystem path, path separator is `::`. - /// Absolute path starts with `::`. - #[ derive( Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize ) ] - pub struct Path( String ); - - impl Path - { - /// Returns the parent directory, if it exists. - /// - /// Returns `None` if the `Path` terminates in a root or if it's the empty string. - #[ inline ] - pub fn parent( &self ) -> Option< Path > - { - /// Find parent of a `Path`. - /// - /// This method uses `&str` as an argument instead of `Path` - /// in order to be more general and handle trailing `::` case. - fn find_parent( s : &str ) -> Option< &str > - { - s.rfind( PATH_SEPARATOR ) - .map( | sep_pos | - { - if sep_pos == 0 - { - // We found root. We should not return string before `::`, - // as it will be empty. - Some( PATH_SEPARATOR ) - } - else if sep_pos == s.len() - PATH_SEPARATOR.len() - { - // We found trailing `::`. We should continue looking for last separator. - find_parent( &s[ .. sep_pos ] ) - } - else - { - Some( &s[ .. sep_pos ] ) - } - }) - .flatten() - } - - find_parent( self.0.as_str() ) - .map( | s | Self( s.to_string() ) ) - } - - /// Returns whether the `Path` is relative (does not start with `::`). - pub fn is_relative( &self ) -> bool - { - !self.is_absolute() - } - - /// Returns whether the `Path` is absolute (starts with `::`). - pub fn is_absolute( &self ) -> bool - { - self.0.starts_with( PATH_SEPARATOR ) - } - - /// Creates an owned `Path` by joining a given path to `self`. - /// - /// If path is joined with an absolute path, then this absolute - /// path will be returned. - #[ inline ] - pub fn join( &self, path : &Path ) -> Self - { - if path.is_absolute() - { - path.clone() - } - else - { - if self.0.ends_with( PATH_SEPARATOR ) - { - Self( format!( "{}{}", self.0, path.0 ) ) - } - else - { - Self( format!( "{}::{}", self.0, path.0 ) ) - } - } - } - - /// Checks if the `Path` starts with a given base path. - #[ inline ] - pub fn starts_with( &self, base : &Path ) -> bool - { - self.0.starts_with( base.0.as_str() ) - } - - /// Returns the inner `String`. - #[ inline( always ) ] - pub fn inner( self ) -> String - { - self.0 - } - - /// Iterate over components of a `Path`. If the `Path` is absolute, then the first - /// element will be `::`. - pub fn components( &self ) -> impl Iterator< Item = &str > - { - self.0.split( PATH_SEPARATOR ).map( | c | - { - if c.is_empty() - { - PATH_SEPARATOR - } - else - { - c - } - }) - } - } - - impl fmt::Display for Path - { - #[ inline ] - fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result - { - write!( f, "{}", self.0 ) - } - } - - impl TryFrom< String > for Path - { - type Error = io::Error; - - fn try_from( src : String ) -> Result< Self, Self::Error > - { - if PATH_REGEX.is_match( src.as_str() ) - { - Ok( Self ( src ) ) - } - else - { - Err( io::Error::from( io::ErrorKind::InvalidData ) ) - } - } - } - - impl TryFrom< &str > for Path - { - type Error = io::Error; - - fn try_from( src : &str ) -> Result< Self, Self::Error > - { - if PATH_REGEX.is_match( src ) - { - Ok( Self ( src.to_string() ) ) - } - else - { - Err( io::Error::from( io::ErrorKind::InvalidData ) ) - } - } - } - - impl AsRef< str > for Path - { - #[ inline ] - fn as_ref( &self ) -> &str - { - self.0.as_ref() - } - } - - impl Into< String > for Path - { - #[ inline ] - fn into( self ) -> String - { - self.0 - } - } - - impl Deref for Path - { - type Target = str; - - #[ inline ] - fn deref( &self ) -> &Self::Target - { - &self.0 - } - } -} - -crate::mod_interface! -{ - own use - { - Path, - PATH_SEPARATOR, - }; -} \ No newline at end of file diff --git a/module/move/assistant/src/agents/scenario_processed.rs b/module/move/assistant/src/agents/scenario_processed.rs deleted file mode 100644 index ada486efba..0000000000 --- a/module/move/assistant/src/agents/scenario_processed.rs +++ /dev/null @@ -1,99 +0,0 @@ -//! -//! Scenario representation. Stores parsed representation of templates and paths. -//! This is the type used for running scenarios. -//! -//! For a more simplistic representation use `ScenarioRaw`. -//! - -mod private -{ - use std::collections::HashMap; - - use crate::*; - use agents:: - { - path::Path, - scenario_raw:: - { - ScenarioRaw, - NodeRaw, - }, - }; - - /// New type for templates in scenarios. - #[ derive( Debug, PartialEq ) ] - pub struct TemplateBody( pub String ); - - /// Struct that represents user written scenarios. - /// - /// This is a processed form of a scenario, paths are distinguished here with types. - /// For more simplistic representation of scenarios, use `ScenarioRaw` type. - #[ derive( Debug, PartialEq ) ] - pub struct ScenarioProcessed - { - /// Nodes in the scenario. - pub nodes: Vec< Node >, - } - - impl TryFrom< ScenarioRaw > for ScenarioProcessed - { - type Error = std::io::Error; - - fn try_from( scenario_raw : ScenarioRaw ) -> Result< Self, Self::Error > - { - let nodes : Result< Vec< Node >, Self::Error > = - scenario_raw.nodes.into_iter().map( | rn | Node::try_from( rn ) ).collect(); - - Ok( Self { nodes : nodes? } ) - } - } - - /// Node representation in a scenario file. - /// - /// This is a processed form of a node, paths are distinguished here with types. - /// For more simplistic representation of scenarios, use `NodeRaw` type. - #[ derive( Debug, PartialEq ) ] - pub struct Node - { - /// ID of the node. Must be unique, will also identify node output. - pub id : String, - - /// Type of the node. - pub typ : Path, - - /// Parameters of the node. - pub params : HashMap< String, String >, - - /// ID of the next node to execute. - pub next : Path, - } - - impl TryFrom< NodeRaw > for Node - { - type Error = std::io::Error; - - fn try_from( node_raw : NodeRaw ) -> Result< Self, Self::Error > - { - Ok - ( - Self - { - id : node_raw.id, - typ : Path::try_from( node_raw.typ )?, - params : node_raw.params, - next : Path::try_from( node_raw.next )?, - } - ) - } - } -} - -crate::mod_interface! -{ - own use - { - TemplateBody, - ScenarioProcessed, - Node, - }; -} \ No newline at end of file diff --git a/module/move/assistant/src/agents/scenario_raw.rs b/module/move/assistant/src/agents/scenario_raw.rs deleted file mode 100644 index 9c588d1fbb..0000000000 --- a/module/move/assistant/src/agents/scenario_raw.rs +++ /dev/null @@ -1,71 +0,0 @@ -//! -//! Raw scenario representation. Captures only the basic syntax of scenario file. -//! -//! For more detailed representation, use `ScenarioProcessed`. -//! - -mod private -{ - use std:: - { - io, - collections::HashMap, - }; - - use former::Former; - use serde:: - { - Serialize, - Deserialize, - }; - - /// Struct that represents user written scenarios. - /// - /// This is a raw form of a scenario, only the general structure is captured there. - /// For more detailed representation of scenarios, use `ScenarioProcessed` type. - #[ derive( Debug, Serialize, Deserialize, Former, PartialEq ) ] - pub struct ScenarioRaw - { - /// Nodes in the scenario. - pub nodes: Vec< NodeRaw >, - } - - impl ScenarioRaw - { - /// Read scenario file in YAML format. - pub fn read( reader : impl io::Read ) -> Result< Self, serde_yaml::Error > - { - serde_yaml::from_reader( reader ) - } - } - - /// Node representation in a scenario file. - /// - /// This is a raw form of a node, only the general structure is captured there. - /// For more detailed representation of scenarios, use `Node` type. - #[ derive( Debug, Serialize, Deserialize, Former, PartialEq ) ] - pub struct NodeRaw - { - /// ID of the node. Must be unique, will also identify node output. - pub id : String, - - /// Type of the node. Represented as a path. - pub typ : String, - - /// Rest of the key-value pairs in the node that are specific to node types. - #[ serde( flatten ) ] - pub params : HashMap< String, String >, - - /// ID of the next node to execute. Represented as a path. - pub next : String, - } -} - -crate::mod_interface! -{ - own use - { - ScenarioRaw, - NodeRaw, - }; -} \ No newline at end of file diff --git a/module/move/assistant/src/agents/scenario_raw_processors.rs b/module/move/assistant/src/agents/scenario_raw_processors.rs deleted file mode 100644 index 4e9ebb7798..0000000000 --- a/module/move/assistant/src/agents/scenario_raw_processors.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! -//! `ScenarioRaw` processors: functions that work with `ScenarioRaw`. -//! -//! Currently only formatters are implemented. -//! - -mod private {} - -crate::mod_interface! -{ - layer yaml_formatter; - layer plantuml_formatter; -} \ No newline at end of file diff --git a/module/move/assistant/src/agents/scenario_raw_processors/plantuml_formatter.rs b/module/move/assistant/src/agents/scenario_raw_processors/plantuml_formatter.rs deleted file mode 100644 index 2bfed18c17..0000000000 --- a/module/move/assistant/src/agents/scenario_raw_processors/plantuml_formatter.rs +++ /dev/null @@ -1,76 +0,0 @@ -//! -//! Format scenario in PlantUML diagram. -//! - -mod private -{ - use std::io; - - use crate::*; - use agents::scenario_raw::ScenarioRaw; - - /// Format scenario in PlantUML diagram. - pub fn plantuml_formatter - ( - scenario : &ScenarioRaw, - writer : &mut impl io::Write, - ) -> Result< (), io::Error > - { - writer.write( b"@startuml\n" )?; - - for node in &scenario.nodes - { - writer.write( b"json " )?; - writer.write( node.id.as_bytes() )?; - writer.write( b" {\n" )?; - - writer.write( b" \"type\": \"" )?; - writer.write( node.typ.as_bytes() )?; - writer.write( b"\"" )?; - - if node.params.len() > 0 - { - writer.write( b"," )?; - } - - writer.write( b"\n" )?; - - for ( i, ( key, value ) ) in node.params.iter().enumerate() - { - writer.write( b" \"" )?; - writer.write( key.as_bytes() )?; - writer.write( b"\": \"" )?; - writer.write( value.as_bytes() )?; - writer.write( b"\"" )?; - - if i != node.params.len() - 1 - { - writer.write( b"," )?; - } - - writer.write( b"\n" )?; - } - - writer.write( b"}\n" )?; - } - - writer.write( b"json ::scenario::termination {\n" )?; - writer.write( b"}\n" )?; - - for node in &scenario.nodes - { - writer.write( node.id.as_bytes() )?; - writer.write( b" --> " )?; - writer.write( node.next.as_bytes() )?; - writer.write( b" : next\n" )?; - } - - writer.write( b"@enduml" )?; - Ok( () ) - } -} - -crate::mod_interface! -{ - own use plantuml_formatter; -} \ No newline at end of file diff --git a/module/move/assistant/src/agents/scenario_raw_processors/yaml_formatter.rs b/module/move/assistant/src/agents/scenario_raw_processors/yaml_formatter.rs deleted file mode 100644 index 05d1bb5668..0000000000 --- a/module/move/assistant/src/agents/scenario_raw_processors/yaml_formatter.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! -//! Format scenario in YAML format (pretty-printing). -//! - -mod private -{ - use std::io; - - use crate::*; - use agents::scenario_raw::ScenarioRaw; - - /// Pretty-print `ScenarioRaw` in YAML format. - pub fn yaml_formatter - ( - scenario : &ScenarioRaw, - writer : &mut impl io::Write, - ) -> Result< (), serde_yaml::Error > - { - serde_yaml::to_writer( writer, scenario ) - } -} - -crate::mod_interface! -{ - own use yaml_formatter; -} \ No newline at end of file diff --git a/module/move/assistant/src/lib.rs b/module/move/assistant/src/lib.rs index 4d21799cc5..5a33e41692 100644 --- a/module/move/assistant/src/lib.rs +++ b/module/move/assistant/src/lib.rs @@ -33,7 +33,6 @@ crate::mod_interface! layer actions; layer secret; layer util; - layer agents; exposed use ::reflect_tools:: { diff --git a/module/move/assistant/src/main.rs b/module/move/assistant/src/main.rs deleted file mode 100644 index ad03e3549a..0000000000 --- a/module/move/assistant/src/main.rs +++ /dev/null @@ -1,28 +0,0 @@ -#![ cfg_attr( feature = "no_std", no_std ) ] -#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] -#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] -#![ doc( html_root_url = "https://docs.rs/assistant/latest/assistant/" ) ] -#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] - -use std:: -{ - env, - error::Error, -}; - -use dotenv::dotenv; - -use assistant:: -{ - client, -}; - -#[ tokio::main ] -async fn main() -> Result< (), Box< dyn Error > > -{ - dotenv().ok(); - let client = client()?; - let assistants = client.list_assistant( None, None, None, None )?; - println!( "Assistants: {:?}", assistants.data ); - Ok( () ) -} diff --git a/module/move/assistant/tests/inc/agents_tests/context_test.rs b/module/move/assistant/tests/inc/agents_tests/context_test.rs deleted file mode 100644 index e28fc8c264..0000000000 --- a/module/move/assistant/tests/inc/agents_tests/context_test.rs +++ /dev/null @@ -1,128 +0,0 @@ -use super::*; - -use the_module::agents:: -{ - path::Path, - context:: - { - ContextDir, - ContextEntry, - }, -}; - -#[ test ] -fn context_dir_add_terminal() -{ - let mut ctx : ContextDir< () > = ContextDir::new(); - let entry = ContextEntry::Terminal( () ); - let name = "test"; - - let res = ctx.add( name, entry.clone() ); - - assert!( res ); - assert_eq!( ctx.get( name ), Some( &entry ) ); -} - -#[ test ] -fn context_dir_add_dir() -{ - let mut ctx : ContextDir< () > = ContextDir::new(); - let entry : ContextEntry< () > = ContextDir::new().into(); - let name = "test"; - - let res = ctx.add( name, entry.clone() ); - - assert!( res ); - assert_eq!( ctx.get( name ), Some( &entry ) ); -} - -#[ test ] -fn context_dir_add_duplicate() -{ - let name = "test"; - let orig_entry = ContextEntry::Terminal( 1 ); - - let mut ctx : ContextDir< usize > = ContextDir::new(); - ctx.add( name, orig_entry.clone() ); - - let res = ctx.add( name, ContextEntry::Terminal( 2 ) ); - - assert!( !res ); - assert_eq!( ctx.get( name ), Some( &orig_entry ) ); -} - -#[ test ] -fn context_dir_get() -{ - let mut ctx : ContextDir< usize > = ContextDir::new(); - ctx.add( "test_1", ContextEntry::Terminal( 1 ) ); - ctx.add( "test_2", ContextEntry::Terminal( 2 ) ); - ctx.add( "test_3", ContextEntry::Terminal( 3 ) ); - - assert_eq!( ctx.get( "test_1" ), Some( &ContextEntry::Terminal( 1 ) ) ); - assert_eq!( ctx.get( "test_2" ), Some( &ContextEntry::Terminal( 2 ) ) ); - assert_eq!( ctx.get( "test_3" ), Some( &ContextEntry::Terminal( 3 ) ) ); -} - -#[ test ] -fn context_dir_get_non_existing() -{ - let ctx : ContextDir< () > = ContextDir::new(); - - let res = ctx.get( "test" ); - - assert!( res.is_none() ); -} - -#[ test ] -fn context_dir_get_by_path_relative() -{ - let value_1 = ContextEntry::Terminal( 1 ); - let value_2 = ContextEntry::Terminal( 2 ); - let value_3 = ContextEntry::Terminal( 3 ); - - let mut dir_1 : ContextDir< usize > = ContextDir::new(); - dir_1.add( "value_1", value_1.clone() ); - dir_1.add( "value_2", value_2.clone() ); - - let mut dir_3 : ContextDir< usize > = ContextDir::new(); - dir_3.add( "value_3", value_3.clone() ); - - let mut dir_2 : ContextDir< usize > = ContextDir::new(); - dir_2.add( "dir_3", dir_3.into() ); - - let mut ctx : ContextDir< usize > = ContextDir::new(); - ctx.add( "dir_1", dir_1.into() ); - ctx.add( "dir_2", dir_2.into() ); - - let got_value_1 = ctx.get_by_path( &Path::try_from( "dir_1::value_1" ).unwrap() ); - let got_value_2 = ctx.get_by_path( &Path::try_from( "dir_1::value_2" ).unwrap() ); - let got_value_3 = ctx.get_by_path( &Path::try_from( "dir_2::dir_3::value_3" ).unwrap() ); - - assert_eq!( got_value_1, Some( &value_1 ) ); - assert_eq!( got_value_2, Some( &value_2 ) ); - assert_eq!( got_value_3, Some( &value_3 ) ); -} - -#[ test ] -fn context_dir_get_by_path_absolute() -{ - let entry = ContextEntry::Terminal( () ); - let mut ctx : ContextDir< () > = ContextDir::new(); - ctx.add( "test", entry.clone() ); - - let res = ctx.get_by_path( &&Path::try_from( "::test" ).unwrap() ); - - assert!( res.is_some() ); - assert_eq!( res.unwrap(), &entry ); -} - -#[ test ] -fn context_dir_get_by_path_non_existing() -{ - let ctx : ContextDir< () > = ContextDir::new(); - - let res = ctx.get_by_path( &Path::try_from( "test" ).unwrap() ); - - assert!( res.is_none() ); -} \ No newline at end of file diff --git a/module/move/assistant/tests/inc/agents_tests/mod.rs b/module/move/assistant/tests/inc/agents_tests/mod.rs deleted file mode 100644 index f4260d9ed5..0000000000 --- a/module/move/assistant/tests/inc/agents_tests/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -use super::*; - -mod test_scenarios; - -mod path_test; -mod context_test; -mod scenario_raw_test; -mod scenario_raw_processors; -mod scenario_processed_test; \ No newline at end of file diff --git a/module/move/assistant/tests/inc/agents_tests/path_test.rs b/module/move/assistant/tests/inc/agents_tests/path_test.rs deleted file mode 100644 index 277f4965ff..0000000000 --- a/module/move/assistant/tests/inc/agents_tests/path_test.rs +++ /dev/null @@ -1,259 +0,0 @@ -use super::*; - -use the_module::agents::path::Path; - -#[ test ] -fn path_create_right() -{ - let path_str = "agent::completion"; - - let path = Path::try_from( path_str ); - - assert!( path.is_ok() ); - assert_eq! ( path.unwrap().inner(), path_str ); -} - -#[ test ] -fn path_create_wrong() -{ - let path = Path::try_from( "agent:completion" ); - assert!( path.is_err() ); -} - -#[ test ] -fn path_create_absolute() -{ - let path_str = "::agent::completion"; - - let path = Path::try_from( path_str ); - - assert!( path.is_ok() ); - assert_eq! ( path.unwrap().inner(), path_str ); -} - -#[ test ] -fn path_create_trailing() -{ - let path_str = "agent::completion::"; - - let path = Path::try_from( path_str ); - - assert!( path.is_ok() ); - assert_eq! ( path.unwrap().inner(), path_str ); -} - -#[ test ] -fn path_some_parent_relative() -{ - let path_str = "agent::completion"; - let path = Path::try_from( path_str ).unwrap(); - - let path_parent = path.parent(); - - assert!( path_parent.is_some() ); - assert_eq!( path_parent.unwrap().inner(), "agent" ); -} - -#[ test ] -fn path_some_parent_relative_trailing() -{ - let path_str = "agent::completion::"; - let path = Path::try_from( path_str ).unwrap(); - - let path_parent = path.parent(); - - assert!( path_parent.is_some() ); - assert_eq!( path_parent.unwrap().inner(), "agent" ); -} - -#[ test ] -fn path_some_parent_absolute() -{ - let path_str = "::agent"; - let path = Path::try_from( path_str ).unwrap(); - - let path_parent = path.parent(); - - assert!( path_parent.is_some() ); - assert_eq!( path_parent.unwrap().inner(), "::" ); -} - -#[ test ] -fn path_some_parent_absolute_trailing() -{ - let path_str = "::agent::"; - let path = Path::try_from( path_str ).unwrap(); - - let path_parent = path.parent(); - - assert!( path_parent.is_some() ); - assert_eq!( path_parent.unwrap().inner(), "::" ); -} - -#[ test ] -fn path_none_parent() -{ - let path_str = "agent"; - let path = Path::try_from( path_str ).unwrap(); - - let path_parent = path.parent(); - - assert!( path_parent.is_none() ); -} - -#[ test ] -fn path_is_relative() -{ - let path_str = "agent"; - let path = Path::try_from( path_str ).unwrap(); - - let is_relative = path.is_relative(); - let is_absolute = path.is_absolute(); - - assert!( is_relative ); - assert!( !is_absolute ); -} - -#[ test ] -fn path_is_absolute() -{ - let path_str = "::agent"; - let path = Path::try_from( path_str ).unwrap(); - - let is_relative = path.is_relative(); - let is_absolute = path.is_absolute(); - - assert!( !is_relative ); - assert!( is_absolute ); -} - -#[ test ] -fn path_join_relative() -{ - let orig_path = Path::try_from( "agent" ).unwrap(); - let append = Path::try_from( "completion" ).unwrap(); - - let combined = orig_path.join( &append ); - - assert_eq!( combined.inner(), "agent::completion" ); -} - -#[ test ] -fn path_join_absolute() -{ - let orig_path = Path::try_from( "agent" ).unwrap(); - let append = Path::try_from( "::completion" ).unwrap(); - - let combined = orig_path.join( &append ); - - assert_eq!( combined.inner(), "::completion" ); -} - -#[ test ] -fn path_join_root() -{ - let orig_path = Path::try_from( "::" ).unwrap(); - let append = Path::try_from( "agent" ).unwrap(); - - let combined = orig_path.join( &append ); - - assert_eq!( combined.inner(), "::agent" ); -} - -#[ test ] -fn path_join_trailing() -{ - let orig_path = Path::try_from( "agents::" ).unwrap(); - let append = Path::try_from( "completion" ).unwrap(); - - let combined = orig_path.join( &append ); - - assert_eq!( combined.inner(), "agents::completion" ); -} - -#[ test ] -fn path_starts_with_abs_abs() -{ - let a = Path::try_from( "::agent::completion" ).unwrap(); - let b = Path::try_from( "::agent" ).unwrap(); - - let starts_with = a.starts_with( &b ); - - assert!( starts_with ); -} - -#[ test ] -fn path_starts_with_abs_rel() -{ - let a = Path::try_from( "::agent::completion" ).unwrap(); - let b = Path::try_from( "agent" ).unwrap(); - - let starts_with = a.starts_with( &b ); - - assert!( !starts_with ); -} - -#[ test ] -fn path_starts_with_rel_abs() -{ - let a = Path::try_from( "agent" ).unwrap(); - let b = Path::try_from( "::agent::completion" ).unwrap(); - - let starts_with = a.starts_with( &b ); - - assert!( !starts_with ); -} - -#[ test ] -fn path_starts_with_rel_rel() -{ - let a = Path::try_from( "agent::completion" ).unwrap(); - let b = Path::try_from( "agent" ).unwrap(); - - let starts_with = a.starts_with( &b ); - - assert!( starts_with ); -} - -#[ test ] -fn path_not_starts_with_abs_abs() -{ - let a = Path::try_from( "::agent::completion" ).unwrap(); - let b = Path::try_from( "::output" ).unwrap(); - - let starts_with = a.starts_with( &b ); - - assert!( !starts_with ); -} - -#[ test ] -fn path_not_starts_with_rel_rel() -{ - let a = Path::try_from( "agent::completion" ).unwrap(); - let b = Path::try_from( "output" ).unwrap(); - - let starts_with = a.starts_with( &b ); - - assert!( !starts_with ); -} - -#[ test ] -fn path_inner() -{ - let path_str = "::agent::completion"; - let path = Path::try_from( path_str ).unwrap(); - - let inner = path.inner(); - - assert_eq!( inner, path_str ); -} - -#[ test ] -fn path_components() -{ - let path = Path::try_from( "::agents::completion" ).unwrap(); - - let components : Vec< &str > = path.components().collect(); - - assert_eq!( components, vec![ "::", "agents", "completion" ] ); -} \ No newline at end of file diff --git a/module/move/assistant/tests/inc/agents_tests/scenario_processed_test.rs b/module/move/assistant/tests/inc/agents_tests/scenario_processed_test.rs deleted file mode 100644 index 5fc734ae41..0000000000 --- a/module/move/assistant/tests/inc/agents_tests/scenario_processed_test.rs +++ /dev/null @@ -1,25 +0,0 @@ -use super::*; - -use the_module::agents::scenario_processed::ScenarioProcessed; - -use test_scenarios:: -{ - gen_test_scenario_raw, - gen_test_scenario_raw_wrong, -}; - -#[ test ] -fn scenario_processed_right() -{ - let scenario_processed = ScenarioProcessed::try_from( gen_test_scenario_raw() ); - - assert!( scenario_processed.is_ok() ); -} - -#[ test ] -fn scenario_processed_wrong() -{ - let scenario_processed = ScenarioProcessed::try_from( gen_test_scenario_raw_wrong() ); - - assert!( scenario_processed.is_err() ); -} \ No newline at end of file diff --git a/module/move/assistant/tests/inc/agents_tests/scenario_raw_processors/mod.rs b/module/move/assistant/tests/inc/agents_tests/scenario_raw_processors/mod.rs deleted file mode 100644 index bbaccfe254..0000000000 --- a/module/move/assistant/tests/inc/agents_tests/scenario_raw_processors/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -use super::*; - -mod plantuml_formatter_test; -mod yaml_formatter_test; \ No newline at end of file diff --git a/module/move/assistant/tests/inc/agents_tests/scenario_raw_processors/plantuml_formatter_test.rs b/module/move/assistant/tests/inc/agents_tests/scenario_raw_processors/plantuml_formatter_test.rs deleted file mode 100644 index 44d5cf86b7..0000000000 --- a/module/move/assistant/tests/inc/agents_tests/scenario_raw_processors/plantuml_formatter_test.rs +++ /dev/null @@ -1,33 +0,0 @@ -use super::*; - -use the_module::agents::scenario_raw_processors::plantuml_formatter::plantuml_formatter; - -use test_scenarios::gen_test_scenario_raw; - - -#[ test ] -fn plantuml_formatter_test() -{ - let expected_plantuml = r#"@startuml -json node_1 { - "type": "agents::completion", - "model": "gpt-4o-mini" -} -json node_2 { - "type": "agents::classify", - "model": "gpt-4o" -} -json ::scenario::termination { -} -node_1 --> node_2 : next -node_2 --> ::scenario::termination : next -@enduml"#; - - let scenario_raw = gen_test_scenario_raw(); - - let mut buffer = Vec::new(); - let result = plantuml_formatter( &scenario_raw, &mut buffer ); - - assert!( result.is_ok() ); - assert_eq!( String::from_utf8( buffer ).unwrap(), expected_plantuml ); -} diff --git a/module/move/assistant/tests/inc/agents_tests/scenario_raw_processors/yaml_formatter_test.rs b/module/move/assistant/tests/inc/agents_tests/scenario_raw_processors/yaml_formatter_test.rs deleted file mode 100644 index fd64cbacec..0000000000 --- a/module/move/assistant/tests/inc/agents_tests/scenario_raw_processors/yaml_formatter_test.rs +++ /dev/null @@ -1,33 +0,0 @@ -use super::*; - -use the_module::agents::scenario_raw_processors::yaml_formatter::yaml_formatter; - -use test_scenarios::gen_test_scenario_raw; - -#[ test ] -fn yaml_formatter_test() -{ - let expected_yaml = r#"nodes: -- id: node_1 - type: agents::completion - model: gpt-4o-mini - next: node_2 -- id: node_2 - type: agents::classify - model: gpt-4o - next: ::scenario::termination"#; - - let scenario_raw = gen_test_scenario_raw(); - - let mut buffer = Vec::new(); - let result = yaml_formatter( &scenario_raw, &mut buffer ); - assert!( result.is_ok() ); - - let result = String::from_utf8( buffer ); - assert!( result.is_ok() ); - - let result = result.unwrap(); - println!( "{}", result ); - - assert_eq!( result.trim(), expected_yaml.trim() ); -} diff --git a/module/move/assistant/tests/inc/agents_tests/scenario_raw_test.rs b/module/move/assistant/tests/inc/agents_tests/scenario_raw_test.rs deleted file mode 100644 index 2f8acc60fe..0000000000 --- a/module/move/assistant/tests/inc/agents_tests/scenario_raw_test.rs +++ /dev/null @@ -1,49 +0,0 @@ -use super::*; - -use the_module::agents::scenario_raw::ScenarioRaw; - -use test_scenarios::gen_test_scenario_raw; - -#[ test ] -fn scenario_read() -{ - let scenario_text = r#" - nodes: - - id: node_1 - type: agents::completion - model: gpt-4o-mini - next: node_2 - - - id: node_2 - type: agents::classify - model: gpt-4o - next: ::scenario::termination - "#; - - let expected_scenario_raw = gen_test_scenario_raw(); - - let scenario_raw = ScenarioRaw::read( scenario_text.as_bytes() ); - - assert!( scenario_raw.is_ok() ); - - let scenario_raw = scenario_raw.unwrap(); - assert_eq!( scenario_raw, expected_scenario_raw ); -} - -#[ test ] -fn scenario_wrong() -{ - let scenario_text = r#" - nodes: - - completion: - model: - company: openai - name: gpt-4o - depends_on: - node_2 - "#; - - let scenario_raw = ScenarioRaw::read( scenario_text.as_bytes() ); - - assert!( scenario_raw.is_err() ); -} \ No newline at end of file diff --git a/module/move/assistant/tests/inc/agents_tests/test_scenarios.rs b/module/move/assistant/tests/inc/agents_tests/test_scenarios.rs deleted file mode 100644 index 3da3ce3e34..0000000000 --- a/module/move/assistant/tests/inc/agents_tests/test_scenarios.rs +++ /dev/null @@ -1,64 +0,0 @@ -use super::*; - -use the_module::agents::scenario_raw:: -{ - ScenarioRaw, - NodeRaw, -}; - -/// Generates an example `ScenarioRaw`. -pub fn gen_test_scenario_raw() -> ScenarioRaw -{ - ScenarioRaw::former() - .nodes( vec! - [ - NodeRaw::former() - .id( "node_1".to_string() ) - .typ( "agents::completion".to_string() ) - .params( - { - let mut map : HashMap< String, String > = HashMap::new(); - map.insert( "model".into(), "gpt-4o-mini".into() ); - map - } - ) - .next( "node_2".to_string() ) - .form(), - - NodeRaw::former() - .id( "node_2".to_string() ) - .typ( "agents::classify".to_string() ) - .params( - { - let mut map : HashMap< String, String > = HashMap::new(); - map.insert( "model".into(), "gpt-4o".into() ); - map - } - ) - .next( "::scenario::termination".to_string() ) - .form(), - ] ) - .form() -} - -/// Generates a `ScenarioRaw` with wrong syntax for `Path`. -pub fn gen_test_scenario_raw_wrong() -> ScenarioRaw -{ - ScenarioRaw::former() - .nodes( vec! - [ - NodeRaw::former() - .id( "node_1".to_string() ) - .typ( ":agents:".to_string() ) // This part is incorrect. Path written in wrong syntax. - .params( - { - let mut map : HashMap< String, String > = HashMap::new(); - map.insert( "model".into(), "gpt-4o-mini".into() ); - map - } - ) - .next( "node_2".to_string() ) - .form(), - ] ) - .form() -} \ No newline at end of file diff --git a/module/move/assistant/tests/inc/mod.rs b/module/move/assistant/tests/inc/mod.rs index abf35e2f97..fd3344b089 100644 --- a/module/move/assistant/tests/inc/mod.rs +++ b/module/move/assistant/tests/inc/mod.rs @@ -1,7 +1,5 @@ #[ allow( unused_imports ) ] use super::*; -mod agents_tests; - mod basic_test; mod experiment; diff --git a/module/move/assistant/tests/smoke_test.rs b/module/move/assistant/tests/smoke_test.rs index 663dd6fb9f..2f3e22aa74 100644 --- a/module/move/assistant/tests/smoke_test.rs +++ b/module/move/assistant/tests/smoke_test.rs @@ -1,3 +1,4 @@ +//! Smoke testing of the crate. #[ test ] fn local_smoke_test() diff --git a/module/move/assistant/tests/tests.rs b/module/move/assistant/tests/tests.rs index c94c4d074f..9c966dc926 100644 --- a/module/move/assistant/tests/tests.rs +++ b/module/move/assistant/tests/tests.rs @@ -1,3 +1,4 @@ +//! All test. include!( "../../../../module/step/meta/src/module/terminal.rs" ); diff --git a/module/move/crates_tools/Cargo.toml b/module/move/crates_tools/Cargo.toml index 3f14f8e209..62244920ae 100644 --- a/module/move/crates_tools/Cargo.toml +++ b/module/move/crates_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crates_tools" -version = "0.14.0" +version = "0.15.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/move/graphs_tools/tests/smoke_test.rs b/module/move/graphs_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/move/graphs_tools/tests/smoke_test.rs +++ b/module/move/graphs_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/move/graphs_tools_deprecated/tests/smoke_test.rs b/module/move/graphs_tools_deprecated/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/move/graphs_tools_deprecated/tests/smoke_test.rs +++ b/module/move/graphs_tools_deprecated/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/move/llm_tools/.key/readme.md b/module/move/llm_tools/.key/readme.md new file mode 100644 index 0000000000..4209c24678 --- /dev/null +++ b/module/move/llm_tools/.key/readme.md @@ -0,0 +1,20 @@ +# Keys + +This document provides a concise example of an environment configuration script, used to set up environment variables for a project. These variables configure application behavior without altering the code. + +## Example of `.key/-env.sh` + +```bash +# OpenAI API key. +OPENAI_API_KEY=sk-proj-ABCDEFG +``` + +## How to Use in Shell + +To apply these variables to your current shell session, use: + +```bash +. ./key/-env.sh +``` + +This command sources the script, making the variables available in your current session. Ensure `-env.sh` is in the `key` directory relative to your current location. \ No newline at end of file diff --git a/module/move/llm_tools/Cargo.toml b/module/move/llm_tools/Cargo.toml new file mode 100644 index 0000000000..325482a155 --- /dev/null +++ b/module/move/llm_tools/Cargo.toml @@ -0,0 +1,62 @@ +[package] +name = "llm_tools" +version = "0.2.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/llm_tools" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/llm_tools" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/llm_tools" +description = """ +Unified API for AI. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] +default-run = "main" + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +enabled = [ + "former/enabled", + "format_tools/enabled", + "reflect_tools/enabled", +] + +[[bin]] +name = "main" +path = "src/bin/main.rs" + +[dependencies] +# xxx : qqq : optimze features +mod_interface = { workspace = true, features = [ "full" ] } +former = { workspace = true, features = [ "full" ] } +format_tools = { workspace = true, features = [ "full" ] } +reflect_tools = { workspace = true, features = [ "full" ] } +openai-api-rs = { version = "=5.0.14" } +tokio = { version = "1", features = ["full"] } +dotenv = "0.15" +# clap = { version = "4.5.20", features = ["derive"] } +# pth = "0.21.0" +pth = { workspace = true, features = [ "full" ] } +serde = { version = "1.0.213", features = ["derive"] } +serde_with = "3.11.0" +# error_tools = "0.17.0" +error_tools = { workspace = true, features = [ "full" ] } +derive_tools = { workspace = true, features = ["full"] } +# derive_tools = { version = "0.32.0", features = ["full"] } +regex = { version = "1.10.3" } +serde_yaml = "0.9" + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/move/llm_tools/License b/module/move/llm_tools/License new file mode 100644 index 0000000000..0804aed8e3 --- /dev/null +++ b/module/move/llm_tools/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn Mysnyk and Out of the Box Systems (c) 2021-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/move/llm_tools/Readme.md b/module/move/llm_tools/Readme.md new file mode 100644 index 0000000000..3982fe50dc --- /dev/null +++ b/module/move/llm_tools/Readme.md @@ -0,0 +1,8 @@ + + +# Module :: llm_tools +[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleassistantPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleassistantPush.yml) [![docs.rs](https://img.shields.io/docsrs/llm_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/llm_tools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +**NOT ready for production** + +Unified API for AI. diff --git a/module/move/llm_tools/api/list.http b/module/move/llm_tools/api/list.http new file mode 100644 index 0000000000..89424758ff --- /dev/null +++ b/module/move/llm_tools/api/list.http @@ -0,0 +1,11 @@ +# use REST Client VSCode plugin +# ctrl+l + +get https://api.openai.com/v1/models +Authorization: Bearer {{openai_token}} +# Content-Type: application/json + +get https://api.openai.com/v1/assistants +Authorization: Bearer {{openai_token}} +OpenAI-Beta: assistants=v2 +Content-Type: application/json diff --git a/module/move/llm_tools/src/bin/main.rs b/module/move/llm_tools/src/bin/main.rs new file mode 100644 index 0000000000..3b4ab6bd22 --- /dev/null +++ b/module/move/llm_tools/src/bin/main.rs @@ -0,0 +1,55 @@ +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc( html_root_url = "https://docs.rs/assistant/latest/assistant/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +use std:: +{ + env, + error::Error, +}; + +use format_tools:: +{ + AsTable, + TableFormatter, + output_format, +}; +use dotenv::dotenv; + +use llm_tools:: +{ + client::client, + Secret +}; + +#[ tokio::main ] +async fn main() -> Result< (), Box< dyn Error > > +{ + dotenv().ok(); + + let secret = Secret::load()?; + + let client = client( &secret )?; + + let response = client.file_list().await?; + // println!( "Files: {:?}", response.data ); + let files : Vec< _ > = response.data.into_iter().map( | e | llm_tools::FileDataWrap( e ) ).collect(); + println! + ( + "Files:\n{}", + AsTable::new( &files ).table_to_string_with_format( &output_format::Table::default() ), + ); + + let response = client.list_assistant( None, None, None, None ).await?; + + // println!( "Assistants: {:?}", assistants.data ); + let assistants : Vec< _ > = response.data.into_iter().map( | e | llm_tools::AssistantObjectWrap( e ) ).collect(); + println! + ( + "Assistants:\n{}", + AsTable::new( &assistants ).table_to_string_with_format( &output_format::Records::default() ), + ); + + Ok( () ) +} \ No newline at end of file diff --git a/module/move/llm_tools/src/client.rs b/module/move/llm_tools/src/client.rs new file mode 100644 index 0000000000..1c9fd0bbee --- /dev/null +++ b/module/move/llm_tools/src/client.rs @@ -0,0 +1,39 @@ +//! +//! Client of API. +//! + +/// Define a private namespace for all its items. +mod private +{ + + pub use openai_api_rs::v1:: + { + api::OpenAIClient as Client, + assistant::AssistantObject, + }; + + use std:: + { + error::Error, + }; + + use crate::*; + use secret::Secret; + + /// Creates a new OpenAI API client using the secrets. + pub fn client( secrets : &Secret ) -> Result< Client, Box< dyn Error > > + { + Ok( Client::new( secrets.OPENAI_API_KEY.clone() ) ) + } + +} + +crate::mod_interface! +{ + exposed use + { + Client, + AssistantObject, + client + }; +} diff --git a/module/move/llm_tools/src/debug.rs b/module/move/llm_tools/src/debug.rs new file mode 100644 index 0000000000..294333abf0 --- /dev/null +++ b/module/move/llm_tools/src/debug.rs @@ -0,0 +1,30 @@ +//! +//! Client of API. +//! + +/// Define a private namespace for all its items. +mod private +{ + +} + +use format_tools:: +{ + Fields, + TableWithFields, +}; +use std::borrow::Cow; + +mod assistant_object; +mod file_data; +mod run_object; + +crate::mod_interface! +{ + exposed use + { + assistant_object::AssistantObjectWrap, + file_data::FileDataWrap, + run_object::RunObjectWrap, + }; +} diff --git a/module/move/llm_tools/src/debug/assistant_object.rs b/module/move/llm_tools/src/debug/assistant_object.rs new file mode 100644 index 0000000000..9ebcead56e --- /dev/null +++ b/module/move/llm_tools/src/debug/assistant_object.rs @@ -0,0 +1,84 @@ +use super::*; +use openai_api_rs::v1::assistant; + +/// A wrapper for `AssistantObject` to make pretty print. +#[ derive( Debug ) ] +pub struct AssistantObjectWrap( pub assistant::AssistantObject ); + +/// Manually implemented `Clone`, as `FileData` does not implement it. +impl Clone for AssistantObjectWrap +{ + fn clone( &self ) -> Self + { + // Manually clone each field of the wrapped AssistantObject + AssistantObjectWrap( assistant::AssistantObject + { + id : self.0.id.clone(), + object : self.0.object.clone(), + created_at : self.0.created_at, + name : self.0.name.clone(), + description : self.0.description.clone(), + model : self.0.model.clone(), + instructions : self.0.instructions.clone(), + tools : self.0.tools.clone(), + tool_resources : self.0.tool_resources.clone(), + metadata : self.0.metadata.clone(), + headers : self.0.headers.clone(), + } ) + } +} + +impl TableWithFields for AssistantObjectWrap {} +impl Fields< &'_ str, Option< Cow< '_, str > > > +for AssistantObjectWrap +{ + type Key< 'k > = &'k str; + type Val< 'v > = Option< Cow< 'v, str > >; + + fn fields( &self ) -> impl format_tools::IteratorTrait< Item = ( &'_ str, Option< Cow< '_, str > > ) > + { + use format_tools::ref_or_display_or_debug_multiline::field; + let mut dst = Vec::new(); + + // Use the field! macro for direct field references + dst.push( field!( &self.0.id ) ); + dst.push( field!( &self.0.object ) ); + dst.push( field!( &self.0.model ) ); + + // Manually handle fields that require function calls + dst.push( ( "created_at", Some( Cow::Owned( self.0.created_at.to_string() ) ) ) ); + dst.push( ( "name", self.0.name.as_deref().map( Cow::Borrowed ) ) ); + dst.push( ( "description", self.0.description.as_deref().map( Cow::Borrowed ) ) ); + dst.push( ( "instructions", self.0.instructions.as_deref().map( Cow::Borrowed ) ) ); + + // Handle complex fields like `tools`, `tool_resources`, `metadata`, and `headers` + if !self.0.tools.is_empty() + { + dst.push( ( "tools", Some( Cow::Borrowed( "tools present" ) ) ) ); + } + else + { + dst.push( ( "tools", Option::None ) ); + } + + if let Some( _metadata ) = &self.0.metadata + { + dst.push( ( "metadata", Some( Cow::Borrowed( "metadata present" ) ) ) ); + } + else + { + dst.push( ( "metadata", Option::None ) ); + } + + if let Some( _headers ) = &self.0.headers + { + dst.push( ( "headers", Some( Cow::Borrowed( "headers present" ) ) ) ); + } + else + { + dst.push( ( "headers", Option::None ) ); + } + + dst.into_iter() + } +} diff --git a/module/move/llm_tools/src/debug/file_data.rs b/module/move/llm_tools/src/debug/file_data.rs new file mode 100644 index 0000000000..b8029949c7 --- /dev/null +++ b/module/move/llm_tools/src/debug/file_data.rs @@ -0,0 +1,50 @@ + +use super::*; +use openai_api_rs::v1::file::FileData; + +// Assuming the `format_tools` module and `field!` macro are defined elsewhere + +/// A wrapper for `FileData` to make pretty print. +#[ derive( Debug ) ] +pub struct FileDataWrap( pub FileData ); + +/// Manually implemented `Clone`, as `FileData` does not implement it. +impl Clone for FileDataWrap +{ + fn clone( &self ) -> Self + { + FileDataWrap( FileData + { + id : self.0.id.clone(), + object : self.0.object.clone(), + bytes : self.0.bytes, + created_at : self.0.created_at, + filename : self.0.filename.clone(), + purpose : self.0.purpose.clone(), + } ) + } +} + +impl TableWithFields for FileDataWrap {} +impl Fields< &'_ str, Option< Cow< '_, str > > > +for FileDataWrap +{ + type Key<'k> = &'k str; + type Val< 'v > = Option< Cow< 'v, str > >; + + fn fields( &self ) -> impl format_tools::IteratorTrait< Item = ( &'_ str, Option< Cow< '_, str > > ) > + { + use format_tools::ref_or_display_or_debug_multiline::field; + let mut dst = Vec::new(); + + // Use the field! macro for direct field references + dst.push( field!( &self.0.id ) ); + dst.push( field!( &self.0.object ) ); + dst.push( ( "bytes", Some( Cow::Owned( self.0.bytes.to_string() ) ) ) ); + dst.push( ( "created_at", Some( Cow::Owned( self.0.created_at.to_string() ) ) ) ); + dst.push( field!( &self.0.filename ) ); + dst.push( field!( &self.0.purpose ) ); + + dst.into_iter() + } +} diff --git a/module/move/llm_tools/src/debug/run_object.rs b/module/move/llm_tools/src/debug/run_object.rs new file mode 100644 index 0000000000..cc2fda5357 --- /dev/null +++ b/module/move/llm_tools/src/debug/run_object.rs @@ -0,0 +1,79 @@ + +use super::*; +use openai_api_rs::v1::run::RunObject; + +// Assuming the `format_tools` module and `field!` macro are defined elsewhere + +/// A wrapper for `RunObject` to make pretty print. +#[ derive( Debug ) ] +pub struct RunObjectWrap( pub RunObject ); + +/// Manually implemented `Clone`, as `RunObject` does not implement it. +impl Clone for RunObjectWrap +{ + fn clone(&self) -> Self + { + RunObjectWrap + ( + RunObject + { + id : self.0.id.clone(), + object : self.0.object.clone(), + created_at : self.0.created_at, + thread_id : self.0.thread_id.clone(), + assistant_id : self.0.assistant_id.clone(), + status : self.0.status.clone(), + required_action : self.0.required_action.clone(), + last_error : self.0.last_error.clone(), + expires_at : self.0.expires_at, + started_at : self.0.started_at, + cancelled_at : self.0.cancelled_at, + failed_at : self.0.failed_at, + completed_at : self.0.completed_at, + model : self.0.model.clone(), + instructions : self.0.instructions.clone(), + tools : self.0.tools.clone(), + metadata : self.0.metadata.clone(), + headers : self.0.headers.clone(), + } + ) + } +} + +impl TableWithFields for RunObjectWrap {} +impl Fields< &'_ str, Option< Cow< '_, str > > > +for RunObjectWrap +{ + type Key< 'k > = &'k str; + type Val< 'v > = Option< Cow< 'v, str > >; + + fn fields( &self ) -> impl format_tools::IteratorTrait< Item = ( &'_ str, Option< Cow< '_, str > > ) > + { + use format_tools::ref_or_display_or_debug_multiline::field; + let mut dst = Vec::new(); + + dst.push( field!( &self.0.id ) ); + dst.push( field!( &self.0.object ) ); + dst.push( ( "created_at", Some( Cow::Owned( self.0.created_at.to_string() ) ) ) ); + dst.push( field!( &self.0.thread_id ) ); + dst.push( field!( &self.0.assistant_id ) ); + dst.push( field!( &self.0.status ) ); + + dst.push( ( "required_action", self.0.required_action.as_ref().map( |ra| Cow::Owned( format!( "{:?}", ra ) ) ) ) ); + dst.push( ( "last_error", self.0.last_error.as_ref().map( |le| Cow::Owned( format!( "{:?}", le ) ) ) ) ); + dst.push( ( "expires_at", self.0.expires_at.map( |ea| Cow::Owned( ea.to_string() ) ) ) ); + dst.push( ( "started_at", self.0.started_at.map( |sa| Cow::Owned( sa.to_string() ) ) ) ); + dst.push( ( "cancelled_at", self.0.cancelled_at.map( |ca| Cow::Owned( ca.to_string() ) ) ) ); + dst.push( ( "failed_at", self.0.failed_at.map( |fa| Cow::Owned( fa.to_string() ) ) ) ); + dst.push( ( "completed_at", self.0.completed_at.map( |ca| Cow::Owned( ca.to_string() ) ) ) ); + + dst.push( field!( &self.0.model ) ); + dst.push( ( "instructions", self.0.instructions.as_ref().map( |i| Cow::Owned( i.clone() ) ) ) ); + + dst.push( ( "tools", Some( Cow::Owned( format!( "{:?}", self.0.tools ) ) ) ) ); + dst.push( ( "metadata", Some( Cow::Owned( format!( "{:?}", self.0.metadata ) ) ) ) ); + dst.push( ( "headers", self.0.headers.as_ref().map( |h| Cow::Owned( format!( "{:?}", h ) ) ) ) ); + + dst.into_iter() + } +} diff --git a/module/move/llm_tools/src/lib.rs b/module/move/llm_tools/src/lib.rs new file mode 100644 index 0000000000..7299b5df2f --- /dev/null +++ b/module/move/llm_tools/src/lib.rs @@ -0,0 +1,42 @@ +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc( html_root_url = "https://docs.rs/assistant/latest/assistant/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +use mod_interface::mod_interface; +use error_tools::thiserror; + +/// Define a private namespace for all its items. +mod private +{ +} + +/// Serde-related exports. +pub mod ser +{ + pub use serde:: + { + Serialize, + Deserialize, + }; + pub use serde_with::*; +} + +// pub mod client; + +crate::mod_interface! +{ + + layer client; + layer debug; + layer secret; + layer util; + + exposed use ::reflect_tools:: + { + Fields, + _IteratorTrait, + IteratorTrait, + }; + +} diff --git a/module/move/llm_tools/src/secret.rs b/module/move/llm_tools/src/secret.rs new file mode 100644 index 0000000000..aa90da77bc --- /dev/null +++ b/module/move/llm_tools/src/secret.rs @@ -0,0 +1,219 @@ +//! +//! Tool's secrets. +//! + +/// Internal namespace. +mod private +{ + use crate::*; + use std:: + { + env, + sync::OnceLock, + }; + + use error_tools::typed::Error; + use ser::DisplayFromStr; + + /// Typed secret error. + #[ ser::serde_as ] + #[ derive( Debug, Error, ser::Serialize ) ] + #[ serde( tag = "type", content = "data" ) ] + pub enum Error + { + + /// Secret file is illformed. + #[ error( "Secret file is illformed\n{0}" ) ] + SecretFileIllformed + ( + #[ from ] + #[ serde_as( as = "DisplayFromStr" ) ] + dotenv::Error + ), + + /// Some variable in the secrets is missing. + #[ error( "Secret misssing the variable {0}" ) ] + VariableMissing( &'static str ), + + /// Some variable in the secrets is illformed. + #[ error( "Secret error processing the variable {0}\n{1}" ) ] + VariableIllformed( &'static str, String ), + + } + + /// Result type for `Secret` methods. + pub type Result< R > = core::result::Result< R, Error >; + + /// Represents the application secrets loaded from environment variables. + #[ derive( Debug ) ] + #[ allow( non_snake_case ) ] + pub struct Secret + { + /// OpenAI API key. + pub OPENAI_API_KEY : String, + } + + impl Secret + { + + /// Loads secrets from environment variables. + /// + /// # Returns + /// + /// * `Result< Self >` - On success, returns a `Secret` instance with values from environment variables. + /// * On failure, returns an error indicating which environment variable is missing or invalid. + #[ allow( non_snake_case ) ] + pub fn load() -> Result< Self > + { + let path = "./.key/-env.sh"; + + // Attempt to load environment variables from the specified file + let r = dotenv::from_filename( path ); + if let Err( ref err ) = r + { + // Only return an error if it's not an Io error, and include the file path in the error message + if !matches!( err, dotenv::Error::Io( _ ) ) + { + return Err( r.expect_err( &format!( "Failed to load {path}" ) ).into() ); + } + } + + let config = Self + { + OPENAI_API_KEY : var( "OPENAI_API_KEY", None )?, + }; + Ok( config ) + } + + /// Reads the secrets, panicking with an explanation if loading fails. + /// + /// # Returns + /// + /// * `Secret` - The loaded secrets. + /// + /// # Panics + /// + /// * Panics with a detailed explanation if the secrets cannot be loaded. + + pub fn read() -> Secret + { + Self::load().unwrap_or_else( | err | + { + let example = include_str!( "../.key/readme.md" ); + let explanation = format! + ( +r#" = Lack of secrets + +Failed to load secret or some its parameters. +{err} + + = Fix + +Either define missing environment variable or make sure `./.key/-env.toml` file has it defined. + + = More information + +{example} +"# + ); + panic!( "{}", explanation ); + }) + } + + /// Retrieves a static reference to the secrets, initializing it if necessary. + /// + /// # Returns + /// + /// * `&'static Secret` - A static reference to the secrets. + /// + /// # Warning + /// + /// * Do not use this function unless absolutely necessary. + /// * Avoid using it in `lib.rs`. + pub fn get() -> &'static Secret + { + static INSTANCE : OnceLock< Secret > = OnceLock::new(); + INSTANCE.get_or_init( || Self::read() ) + } + + } + + /// Retrieves the value of an environment variable as a `String`. + /// + /// This function attempts to fetch the value of the specified environment variable. + /// If the variable is not set, it returns a provided default value if available, or an error if not. + /// + /// # Arguments + /// + /// * `name` - The name of the environment variable to retrieve. + /// * `default` - An optional default value to return if the environment variable is not set. + /// + /// # Returns + /// + /// * `Result` - On success, returns the value of the environment variable or the default value. + /// * On failure, returns an error indicating the missing environment variable. + fn var + ( + name : &'static str, + default : Option< &'static str >, + ) -> Result< String > + { + match env::var( name ) + { + Ok( value ) => Ok( value ), + Err( _ ) => + { + if let Some( default_value ) = default + { + Ok( default_value.to_string() ) + } + else + { + Err( Error::VariableMissing( name ) ) + } + } + } + } + + /// Retrieves the value of an environment variable as an `AbsolutePath`. + /// + /// This function attempts to fetch the value of the specified environment variable and convert it into an `AbsolutePath`. + /// If the variable is not set, it returns a provided default value if available, or an error if not. + /// + /// # Arguments + /// + /// * `name` - The name of the environment variable to retrieve. + /// * `default` - An optional default value to return if the environment variable is not set. + /// + /// # Returns + /// + /// * `Result` - On success, returns the parsed `AbsolutePath`. + /// * On failure, returns an error indicating the missing or ill-formed environment variable. + fn _var_path + ( + name : &'static str, + default : Option< &'static str >, + ) -> Result< pth::AbsolutePath > + { + let p = var( name, default )?; + pth::AbsolutePath::from_paths( ( pth::CurrentPath, p ) ) + .map_err( |e| Error::VariableIllformed( name, e.to_string() ) ) + } + +} + +crate::mod_interface! +{ + + own use + { + Error, + Result, + }; + + orphan use + { + Secret, + }; + +} \ No newline at end of file diff --git a/module/move/llm_tools/src/util.rs b/module/move/llm_tools/src/util.rs new file mode 100644 index 0000000000..7e34c0fd16 --- /dev/null +++ b/module/move/llm_tools/src/util.rs @@ -0,0 +1,10 @@ +//! +//! Collection of utility functions for this crate. +//! + +mod private {} + +crate::mod_interface! +{ + layer display_table; +} \ No newline at end of file diff --git a/module/move/llm_tools/src/util/display_table.rs b/module/move/llm_tools/src/util/display_table.rs new file mode 100644 index 0000000000..ffb99bf052 --- /dev/null +++ b/module/move/llm_tools/src/util/display_table.rs @@ -0,0 +1,154 @@ +//! +//! Function for displaying tabular data according to `TableConfig`. +//! + +mod private +{ + + use std::fmt; + + use format_tools:: + { + TableFormatter, + output_format, + print, + TableOutputFormat, + }; + + // use crate::*; + // use commands::{ TableConfig }; + + /// Common collection of arguments for formatting tabular data. + #[ derive( Debug ) ] + pub struct TableConfig + { + /// Limit table widht. + // #[ arg( long, default_value_t = DEFAULT_MAX_TABLE_WIDTH ) ] + pub max_table_width : usize, + + /// Show tabular data as an ordinary table. + // #[ arg( long ) ] + pub as_table : bool, + + /// Show each record of a tabular data as a separate table. + // #[ arg( long ) ] + pub as_records : bool, + + /// Show only keys (columns) of tabular data. + // #[ arg( long ) ] + pub columns : bool, + + /// Filter columns of tabular data. + // #[ arg( long, value_delimiter( ',' ) ) ] + pub filter_columns : Vec< String >, + } + + /// Function for displaying tabular data according to `TableConfig`. + pub fn display_tabular_data<'a> + ( + data : &'a impl TableFormatter< 'a >, + f : &mut fmt::Formatter< '_ >, + table_config : &'a TableConfig, + ) -> fmt::Result + { + if table_config.as_table + { + display_table( data, f, table_config ) + } + else if table_config.as_records + { + display_records( data, f, table_config ) + } + else if table_config.columns + { + display_columns( data, f, table_config ) + } + else + { + display_table( data, f, table_config ) + } + } + + fn display_table<'a> + ( + data : &'a impl TableFormatter< 'a >, + f : &mut fmt::Formatter< '_ >, + table_config : &'a TableConfig, + ) -> fmt::Result + { + let mut format = output_format::Table::default(); + format.max_width = table_config.max_table_width; + + display_data + ( + data, + f, + format, + &table_config.filter_columns, + ) + } + + fn display_records<'a> + ( + data : &'a impl TableFormatter< 'a >, + f : &mut fmt::Formatter< '_ >, + table_config : &'a TableConfig, + ) -> fmt::Result + { + let mut format = output_format::Records::default(); + format.max_width = table_config.max_table_width; + + display_data + ( + data, + f, + format, + &table_config.filter_columns, + ) + } + + fn display_columns<'a> + ( + data : &'a impl TableFormatter< 'a >, + f : &mut fmt::Formatter< '_ >, + table_config : &'a TableConfig, + ) -> fmt::Result + { + let mut format = output_format::Records::default(); + format.max_width = table_config.max_table_width; + + display_data + ( + data, + f, + format, + &table_config.filter_columns, + ) + } + + fn display_data<'a> + ( + data : &'a impl TableFormatter< 'a >, + f : &mut fmt::Formatter< '_ >, + format : impl TableOutputFormat, + filter_columns : &'a Vec< String >, + ) -> fmt::Result + { + let mut printer = print::Printer::with_format( &format ); + let binding = | title : &str | + { + filter_columns.is_empty() || filter_columns.iter().any( |c| c.as_str() == title ) + }; + printer.filter_col = &binding; + + let mut context = print::Context::new( f, printer ); + TableFormatter::fmt( data, &mut context ) + } + +} + +crate::mod_interface! +{ + own use display_tabular_data; + own use TableConfig; +} \ No newline at end of file diff --git a/module/move/llm_tools/tests/inc/basic_test.rs b/module/move/llm_tools/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/move/llm_tools/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/move/llm_tools/tests/inc/experiment.rs b/module/move/llm_tools/tests/inc/experiment.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/module/move/llm_tools/tests/inc/mod.rs b/module/move/llm_tools/tests/inc/mod.rs new file mode 100644 index 0000000000..fd3344b089 --- /dev/null +++ b/module/move/llm_tools/tests/inc/mod.rs @@ -0,0 +1,5 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; +mod experiment; diff --git a/module/move/llm_tools/tests/smoke_test.rs b/module/move/llm_tools/tests/smoke_test.rs new file mode 100644 index 0000000000..2f3e22aa74 --- /dev/null +++ b/module/move/llm_tools/tests/smoke_test.rs @@ -0,0 +1,13 @@ +//! Smoke testing of the crate. + +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/move/llm_tools/tests/tests.rs b/module/move/llm_tools/tests/tests.rs new file mode 100644 index 0000000000..b390683e4c --- /dev/null +++ b/module/move/llm_tools/tests/tests.rs @@ -0,0 +1,9 @@ +//! All test. + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/move/plot_interface/tests/smoke_test.rs b/module/move/plot_interface/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/move/plot_interface/tests/smoke_test.rs +++ b/module/move/plot_interface/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/move/sqlx_query/tests/smoke_test.rs b/module/move/sqlx_query/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/move/sqlx_query/tests/smoke_test.rs +++ b/module/move/sqlx_query/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/move/wca/Cargo.toml b/module/move/wca/Cargo.toml index 06791cf645..662ecd9c71 100644 --- a/module/move/wca/Cargo.toml +++ b/module/move/wca/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wca" -version = "0.23.0" +version = "0.24.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/move/wca/tests/inc/mod.rs b/module/move/wca/tests/inc/mod.rs index b51887947e..c805473908 100644 --- a/module/move/wca/tests/inc/mod.rs +++ b/module/move/wca/tests/inc/mod.rs @@ -1,15 +1,7 @@ -#[ allow( unused_imports ) ] use super::*; +use test_tools::exposed::*; - -#[ cfg( not( feature = "no_std" ) ) ] mod parser; -#[ cfg( not( feature = "no_std" ) ) ] mod grammar; -#[ cfg( not( feature = "no_std" ) ) ] mod executor; -#[ cfg( not( feature = "no_std" ) ) ] mod commands_aggregator; - -// aaa : for Bohdan : why commented out? resolve -// aaa : no longer relevant, so removed diff --git a/module/move/wca/tests/smoke_test.rs b/module/move/wca/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/move/wca/tests/smoke_test.rs +++ b/module/move/wca/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/move/wca/tests/wca_tests.rs b/module/move/wca/tests/tests.rs similarity index 50% rename from module/move/wca/tests/wca_tests.rs rename to module/move/wca/tests/tests.rs index ac2fbf9612..cd66cd65aa 100644 --- a/module/move/wca/tests/wca_tests.rs +++ b/module/move/wca/tests/tests.rs @@ -1,12 +1,11 @@ +//! All tests. + // #![ deny( rust_2018_idioms ) ] // #![ deny( missing_debug_implementations ) ] // #![ deny( missing_docs ) ] +#![ allow( unused_imports ) ] -#[ allow( unused_imports ) ] +/// System under test. use wca as the_module; -#[ allow( unused_imports ) ] -use test_tools::exposed::*; -// #[ allow( unused_imports ) ] -// use wca::wtools::*; mod inc; diff --git a/module/move/willbe/Cargo.toml b/module/move/willbe/Cargo.toml index e647b11d88..358de1a184 100644 --- a/module/move/willbe/Cargo.toml +++ b/module/move/willbe/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "willbe" -version = "0.20.0" +version = "0.21.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/move/willbe/src/tool/graph.rs b/module/move/willbe/src/tool/graph.rs index 9f632778bf..e0ba9bc109 100644 --- a/module/move/willbe/src/tool/graph.rs +++ b/module/move/willbe/src/tool/graph.rs @@ -283,8 +283,9 @@ mod private for root in roots { let root = graph.node_indices().find( | &i | graph[ i ] == *root ).unwrap(); + // qqq : no unwraps. simulate crash here and check output. it should be verbal let mut dfs = DfsPostOrder::new( &graph, root ); - 'main : while let Some( n ) = dfs.next(&graph) + 'main : while let Some( n ) = dfs.next( &graph ) { for neighbor in graph.neighbors_directed( n, Outgoing ) { diff --git a/module/move/willbe/tests/inc/mod.rs b/module/move/willbe/tests/inc/mod.rs index 0b456a9b87..be920a6b41 100644 --- a/module/move/willbe/tests/inc/mod.rs +++ b/module/move/willbe/tests/inc/mod.rs @@ -1,4 +1,5 @@ use super::*; +use test_tools::exposed::*; /// Entities of which spaces consists of. mod entity; diff --git a/module/move/willbe/tests/smoke_test.rs b/module/move/willbe/tests/smoke_test.rs index dd681c20c1..c9b1b4daae 100644 --- a/module/move/willbe/tests/smoke_test.rs +++ b/module/move/willbe/tests/smoke_test.rs @@ -1,14 +1,13 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() { - ::test_tools::smoke_test_for_local_run(); + ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { - ::test_tools::smoke_test_for_published_run(); + ::test_tools::smoke_test_for_published_run(); } diff --git a/module/move/willbe/tests/tests.rs b/module/move/willbe/tests/tests.rs index 3e8c5b7621..cefd199e28 100644 --- a/module/move/willbe/tests/tests.rs +++ b/module/move/willbe/tests/tests.rs @@ -1,9 +1,10 @@ +//! All tests. +#![ allow( unused_imports ) ] + include!( "../../../../module/step/meta/src/module/terminal.rs" ); -#[ allow( unused_imports ) ] +/// System under test. use willbe as the_module; -#[ allow( unused_imports ) ] -use test_tools::exposed::*; /// asset path pub const ASSET_PATH : &str = "tests/asset"; diff --git a/module/move/wplot/tests/smoke_test.rs b/module/move/wplot/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/move/wplot/tests/smoke_test.rs +++ b/module/move/wplot/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/postponed/_video_experiment/tests/smoke_test.rs b/module/postponed/_video_experiment/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/postponed/_video_experiment/tests/smoke_test.rs +++ b/module/postponed/_video_experiment/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/postponed/automata_tools/tests/smoke_test.rs b/module/postponed/automata_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/postponed/automata_tools/tests/smoke_test.rs +++ b/module/postponed/automata_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/postponed/non_std/tests/smoke_test.rs b/module/postponed/non_std/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/postponed/non_std/tests/smoke_test.rs +++ b/module/postponed/non_std/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/postponed/std_tools/tests/smoke_test.rs b/module/postponed/std_tools/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/postponed/std_tools/tests/smoke_test.rs +++ b/module/postponed/std_tools/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/postponed/std_x/tests/smoke_test.rs b/module/postponed/std_x/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/postponed/std_x/tests/smoke_test.rs +++ b/module/postponed/std_x/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/postponed/type_constructor/tests/smoke_test.rs b/module/postponed/type_constructor/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/postponed/type_constructor/tests/smoke_test.rs +++ b/module/postponed/type_constructor/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/postponed/wautomata/tests/smoke_test.rs b/module/postponed/wautomata/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/postponed/wautomata/tests/smoke_test.rs +++ b/module/postponed/wautomata/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/postponed/wpublisher/tests/smoke_test.rs b/module/postponed/wpublisher/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/postponed/wpublisher/tests/smoke_test.rs +++ b/module/postponed/wpublisher/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/step/meta/tests/smoke_test.rs b/module/step/meta/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/step/meta/tests/smoke_test.rs +++ b/module/step/meta/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/template/template_alias/tests/smoke_test.rs b/module/template/template_alias/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/template/template_alias/tests/smoke_test.rs +++ b/module/template/template_alias/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/template/template_procedural_macro/tests/smoke_test.rs b/module/template/template_procedural_macro/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/template/template_procedural_macro/tests/smoke_test.rs +++ b/module/template/template_procedural_macro/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/template/template_procedural_macro_meta/tests/smoke_test.rs b/module/template/template_procedural_macro_meta/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/template/template_procedural_macro_meta/tests/smoke_test.rs +++ b/module/template/template_procedural_macro_meta/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/template/template_procedural_macro_runtime/tests/smoke_test.rs b/module/template/template_procedural_macro_runtime/tests/smoke_test.rs index 828e9b016b..c9b1b4daae 100644 --- a/module/template/template_procedural_macro_runtime/tests/smoke_test.rs +++ b/module/template/template_procedural_macro_runtime/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke testing of the package. #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() {