From 64d059e49677fb06f538d884712570d693339a9a Mon Sep 17 00:00:00 2001 From: Jan Haller Date: Sun, 27 Aug 2023 18:34:14 +0200 Subject: [PATCH] Reorganize file structure of itest cases Changes: * Group tests by shared semantics, rather than having all on top level. * Remove 2 tests in `builtin.rs` (Vector2, VariantArray), already covered through unit-tests and other itests. --- itest/rust/src/builtin_test.rs | 61 ------------ .../src/{ => builtin_tests}/color_test.rs | 0 .../containers}/array_test.rs | 0 .../containers}/callable_test.rs | 26 ++++- .../containers}/dictionary_test.rs | 0 .../containers}/packed_array_test.rs | 0 .../containers}/rid_test.rs | 0 .../containers}/signal_test.rs | 0 .../containers}/variant_test.rs | 28 ++---- .../geometry}/basis_test.rs | 0 .../geometry}/plane_test.rs | 0 .../geometry}/projection_test.rs | 0 .../geometry}/quaternion_test.rs | 0 .../geometry}/rect2_test.rs | 0 .../geometry}/rect2i_test.rs | 0 .../geometry}/transform2d_test.rs | 0 .../geometry}/transform3d_test.rs | 0 itest/rust/src/builtin_tests/mod.rs | 33 +++++++ .../string/godot_string_test.rs | 0 .../string/node_path_test.rs | 0 .../string/string_name_test.rs | 0 itest/rust/src/common.rs | 22 +++++ .../src/{ => engine_tests}/codegen_test.rs | 7 ++ .../src/{registration => engine_tests}/mod.rs | 4 +- .../native_structures_test.rs | 0 .../rust/src/{ => engine_tests}/node_test.rs | 0 .../src/{ => engine_tests}/utilities_test.rs | 0 itest/rust/src/framework/runner.rs | 2 +- itest/rust/src/lib.rs | 42 ++------ .../rust/src/{ => object_tests}/base_test.rs | 0 .../rust/src/{ => object_tests}/enum_test.rs | 0 .../rust/src/{string => object_tests}/mod.rs | 8 +- .../src/{ => object_tests}/object_test.rs | 0 .../src/{ => object_tests}/property_test.rs | 0 .../src/{ => object_tests}/singleton_test.rs | 0 .../virtual_methods_test.rs | 0 .../constant_test.rs | 0 .../derive_variant/enums_skip.rs | 0 .../derive_variant/mod.rs | 5 +- .../derive_variant/structs_skip.rs | 0 .../src/{ => register_tests}/func_test.rs | 96 +++++++++---------- .../{ => register_tests}/gdscript_ffi_test.rs | 2 +- itest/rust/src/register_tests/mod.rs | 12 +++ .../{ => register_tests}/option_ffi_test.rs | 0 .../var_test.rs} | 8 -- 45 files changed, 174 insertions(+), 182 deletions(-) delete mode 100644 itest/rust/src/builtin_test.rs rename itest/rust/src/{ => builtin_tests}/color_test.rs (100%) rename itest/rust/src/{ => builtin_tests/containers}/array_test.rs (100%) rename itest/rust/src/{ => builtin_tests/containers}/callable_test.rs (80%) rename itest/rust/src/{ => builtin_tests/containers}/dictionary_test.rs (100%) rename itest/rust/src/{ => builtin_tests/containers}/packed_array_test.rs (100%) rename itest/rust/src/{ => builtin_tests/containers}/rid_test.rs (100%) rename itest/rust/src/{ => builtin_tests/containers}/signal_test.rs (100%) rename itest/rust/src/{ => builtin_tests/containers}/variant_test.rs (96%) rename itest/rust/src/{ => builtin_tests/geometry}/basis_test.rs (100%) rename itest/rust/src/{ => builtin_tests/geometry}/plane_test.rs (100%) rename itest/rust/src/{ => builtin_tests/geometry}/projection_test.rs (100%) rename itest/rust/src/{ => builtin_tests/geometry}/quaternion_test.rs (100%) rename itest/rust/src/{ => builtin_tests/geometry}/rect2_test.rs (100%) rename itest/rust/src/{ => builtin_tests/geometry}/rect2i_test.rs (100%) rename itest/rust/src/{ => builtin_tests/geometry}/transform2d_test.rs (100%) rename itest/rust/src/{ => builtin_tests/geometry}/transform3d_test.rs (100%) create mode 100644 itest/rust/src/builtin_tests/mod.rs rename itest/rust/src/{ => builtin_tests}/string/godot_string_test.rs (100%) rename itest/rust/src/{ => builtin_tests}/string/node_path_test.rs (100%) rename itest/rust/src/{ => builtin_tests}/string/string_name_test.rs (100%) create mode 100644 itest/rust/src/common.rs rename itest/rust/src/{ => engine_tests}/codegen_test.rs (91%) rename itest/rust/src/{registration => engine_tests}/mod.rs (77%) rename itest/rust/src/{ => engine_tests}/native_structures_test.rs (100%) rename itest/rust/src/{ => engine_tests}/node_test.rs (100%) rename itest/rust/src/{ => engine_tests}/utilities_test.rs (100%) rename itest/rust/src/{ => object_tests}/base_test.rs (100%) rename itest/rust/src/{ => object_tests}/enum_test.rs (100%) rename itest/rust/src/{string => object_tests}/mod.rs (68%) rename itest/rust/src/{ => object_tests}/object_test.rs (100%) rename itest/rust/src/{ => object_tests}/property_test.rs (100%) rename itest/rust/src/{ => object_tests}/singleton_test.rs (100%) rename itest/rust/src/{ => object_tests}/virtual_methods_test.rs (100%) rename itest/rust/src/{registration => register_tests}/constant_test.rs (100%) rename itest/rust/src/{ => register_tests}/derive_variant/enums_skip.rs (100%) rename itest/rust/src/{ => register_tests}/derive_variant/mod.rs (98%) rename itest/rust/src/{ => register_tests}/derive_variant/structs_skip.rs (100%) rename itest/rust/src/{ => register_tests}/func_test.rs (95%) rename itest/rust/src/{ => register_tests}/gdscript_ffi_test.rs (89%) create mode 100644 itest/rust/src/register_tests/mod.rs rename itest/rust/src/{ => register_tests}/option_ffi_test.rs (100%) rename itest/rust/src/{init_test.rs => register_tests/var_test.rs} (68%) diff --git a/itest/rust/src/builtin_test.rs b/itest/rust/src/builtin_test.rs deleted file mode 100644 index 72d168816..000000000 --- a/itest/rust/src/builtin_test.rs +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -use crate::framework::itest; -use godot::builtin::inner::*; -use godot::prelude::*; - -#[itest] -fn test_builtins_vector2() { - let vec = Vector2::new(3.0, -4.0); - let inner: InnerVector2 = vec.as_inner(); - - let len_sq = inner.length_squared(); - assert_eq!(len_sq, 25.0); - - let abs = inner.abs(); - assert_eq!(abs, Vector2::new(3.0, 4.0)); - - let normalized = inner.is_normalized(); - assert!(!normalized); -} - -#[itest] -fn test_builtins_array() { - let array = VariantArray::default(); - let mut inner: InnerArray = array.as_inner(); - - let a = 7.to_variant(); - let b = GodotString::from("Seven").to_variant(); - - inner.append(a.clone()); - inner.append(b.clone()); - - assert_eq!(inner.size(), 2); - assert_eq!(inner.pop_front(), a); - assert_eq!(inner.pop_front(), b); - assert_eq!(inner.pop_front(), Variant::nil()); -} - -#[itest] -fn test_builtins_callable() { - let obj = Node2D::new_alloc(); - let cb = Callable::from_object_method(obj.share(), "set_position"); - let inner: InnerCallable = cb.as_inner(); - - assert!(!inner.is_null()); - assert_eq!(inner.get_object_id(), obj.instance_id().to_i64()); - assert_eq!(inner.get_method(), StringName::from("set_position")); - - // TODO once varargs is available - // let pos = Vector2::new(5.0, 7.0); - // inner.call(&[pos.to_variant()]); - // assert_eq!(obj.get_position(), pos); - // - // inner.bindv(array); - - obj.free(); -} diff --git a/itest/rust/src/color_test.rs b/itest/rust/src/builtin_tests/color_test.rs similarity index 100% rename from itest/rust/src/color_test.rs rename to itest/rust/src/builtin_tests/color_test.rs diff --git a/itest/rust/src/array_test.rs b/itest/rust/src/builtin_tests/containers/array_test.rs similarity index 100% rename from itest/rust/src/array_test.rs rename to itest/rust/src/builtin_tests/containers/array_test.rs diff --git a/itest/rust/src/callable_test.rs b/itest/rust/src/builtin_tests/containers/callable_test.rs similarity index 80% rename from itest/rust/src/callable_test.rs rename to itest/rust/src/builtin_tests/containers/callable_test.rs index f5b000abb..fbfa13fac 100644 --- a/itest/rust/src/callable_test.rs +++ b/itest/rust/src/builtin_tests/containers/callable_test.rs @@ -5,10 +5,10 @@ */ use godot::bind::{godot_api, GodotClass}; -use godot::builtin::{varray, Callable, ToVariant, Variant}; -use godot::engine::Object; +use godot::builtin::inner::InnerCallable; +use godot::builtin::{varray, Callable, GodotString, StringName, ToVariant, Variant}; +use godot::engine::{Node2D, Object}; use godot::obj::{Gd, Share}; -use godot::prelude::GodotString; use crate::framework::itest; @@ -105,3 +105,23 @@ fn callable_call_return() { // errors in godot but does not crash assert_eq!(callable.callv(varray!["string"]), Variant::nil()); } + +#[itest] +fn callable_call_engine() { + let obj = Node2D::new_alloc(); + let cb = Callable::from_object_method(obj.share(), "set_position"); + let inner: InnerCallable = cb.as_inner(); + + assert!(!inner.is_null()); + assert_eq!(inner.get_object_id(), obj.instance_id().to_i64()); + assert_eq!(inner.get_method(), StringName::from("set_position")); + + // TODO once varargs is available + // let pos = Vector2::new(5.0, 7.0); + // inner.call(&[pos.to_variant()]); + // assert_eq!(obj.get_position(), pos); + // + // inner.bindv(array); + + obj.free(); +} diff --git a/itest/rust/src/dictionary_test.rs b/itest/rust/src/builtin_tests/containers/dictionary_test.rs similarity index 100% rename from itest/rust/src/dictionary_test.rs rename to itest/rust/src/builtin_tests/containers/dictionary_test.rs diff --git a/itest/rust/src/packed_array_test.rs b/itest/rust/src/builtin_tests/containers/packed_array_test.rs similarity index 100% rename from itest/rust/src/packed_array_test.rs rename to itest/rust/src/builtin_tests/containers/packed_array_test.rs diff --git a/itest/rust/src/rid_test.rs b/itest/rust/src/builtin_tests/containers/rid_test.rs similarity index 100% rename from itest/rust/src/rid_test.rs rename to itest/rust/src/builtin_tests/containers/rid_test.rs diff --git a/itest/rust/src/signal_test.rs b/itest/rust/src/builtin_tests/containers/signal_test.rs similarity index 100% rename from itest/rust/src/signal_test.rs rename to itest/rust/src/builtin_tests/containers/signal_test.rs diff --git a/itest/rust/src/variant_test.rs b/itest/rust/src/builtin_tests/containers/variant_test.rs similarity index 96% rename from itest/rust/src/variant_test.rs rename to itest/rust/src/builtin_tests/containers/variant_test.rs index b95519495..57918c2a9 100644 --- a/itest/rust/src/variant_test.rs +++ b/itest/rust/src/builtin_tests/containers/variant_test.rs @@ -4,17 +4,22 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::framework::{expect_panic, itest}; +use std::cmp::Ordering; +use std::fmt::Display; + use godot::builtin::{ dict, varray, FromVariant, GodotString, NodePath, StringName, ToVariant, Variant, Vector2, Vector3, }; +use godot::builtin::{ + Basis, Dictionary, VariantArray, VariantConversionError, VariantOperator, VariantType, +}; use godot::engine::Node2D; use godot::obj::InstanceId; -use godot::prelude::{Basis, Dictionary, VariantArray, VariantConversionError}; -use godot::sys::{GodotFfi, VariantOperator, VariantType}; -use std::cmp::Ordering; -use std::fmt::{Debug, Display}; +use godot::sys::GodotFfi; + +use crate::common::roundtrip; +use crate::framework::{expect_panic, itest}; const TEST_BASIS: Basis = Basis::from_rows( Vector3::new(1.0, 2.0, 3.0), @@ -408,19 +413,6 @@ fn variant_hash_correct() { // ---------------------------------------------------------------------------------------------------------------------------------------------- -pub(crate) fn roundtrip(value: T) -where - T: FromVariant + ToVariant + PartialEq + Debug, -{ - // TODO test other roundtrip (first FromVariant, then ToVariant) - // Some values can be represented in Variant, but not in T (e.g. Variant(0i64) -> Option -> Variant is lossy) - - let variant = value.to_variant(); - let back = T::try_from_variant(&variant).unwrap(); - - assert_eq!(value, back); -} - fn truncate_bad(original_value: i64) where T: FromVariant + Display, diff --git a/itest/rust/src/basis_test.rs b/itest/rust/src/builtin_tests/geometry/basis_test.rs similarity index 100% rename from itest/rust/src/basis_test.rs rename to itest/rust/src/builtin_tests/geometry/basis_test.rs diff --git a/itest/rust/src/plane_test.rs b/itest/rust/src/builtin_tests/geometry/plane_test.rs similarity index 100% rename from itest/rust/src/plane_test.rs rename to itest/rust/src/builtin_tests/geometry/plane_test.rs diff --git a/itest/rust/src/projection_test.rs b/itest/rust/src/builtin_tests/geometry/projection_test.rs similarity index 100% rename from itest/rust/src/projection_test.rs rename to itest/rust/src/builtin_tests/geometry/projection_test.rs diff --git a/itest/rust/src/quaternion_test.rs b/itest/rust/src/builtin_tests/geometry/quaternion_test.rs similarity index 100% rename from itest/rust/src/quaternion_test.rs rename to itest/rust/src/builtin_tests/geometry/quaternion_test.rs diff --git a/itest/rust/src/rect2_test.rs b/itest/rust/src/builtin_tests/geometry/rect2_test.rs similarity index 100% rename from itest/rust/src/rect2_test.rs rename to itest/rust/src/builtin_tests/geometry/rect2_test.rs diff --git a/itest/rust/src/rect2i_test.rs b/itest/rust/src/builtin_tests/geometry/rect2i_test.rs similarity index 100% rename from itest/rust/src/rect2i_test.rs rename to itest/rust/src/builtin_tests/geometry/rect2i_test.rs diff --git a/itest/rust/src/transform2d_test.rs b/itest/rust/src/builtin_tests/geometry/transform2d_test.rs similarity index 100% rename from itest/rust/src/transform2d_test.rs rename to itest/rust/src/builtin_tests/geometry/transform2d_test.rs diff --git a/itest/rust/src/transform3d_test.rs b/itest/rust/src/builtin_tests/geometry/transform3d_test.rs similarity index 100% rename from itest/rust/src/transform3d_test.rs rename to itest/rust/src/builtin_tests/geometry/transform3d_test.rs diff --git a/itest/rust/src/builtin_tests/mod.rs b/itest/rust/src/builtin_tests/mod.rs new file mode 100644 index 000000000..f8eddf018 --- /dev/null +++ b/itest/rust/src/builtin_tests/mod.rs @@ -0,0 +1,33 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +mod geometry { + mod basis_test; + mod plane_test; + mod projection_test; + mod quaternion_test; + mod rect2_test; + mod rect2i_test; + mod transform2d_test; + mod transform3d_test; +} + +mod containers { + mod array_test; + mod callable_test; + mod dictionary_test; + mod rid_test; + mod signal_test; + mod variant_test; +} + +mod string { + mod godot_string_test; + mod node_path_test; + mod string_name_test; +} + +mod color_test; diff --git a/itest/rust/src/string/godot_string_test.rs b/itest/rust/src/builtin_tests/string/godot_string_test.rs similarity index 100% rename from itest/rust/src/string/godot_string_test.rs rename to itest/rust/src/builtin_tests/string/godot_string_test.rs diff --git a/itest/rust/src/string/node_path_test.rs b/itest/rust/src/builtin_tests/string/node_path_test.rs similarity index 100% rename from itest/rust/src/string/node_path_test.rs rename to itest/rust/src/builtin_tests/string/node_path_test.rs diff --git a/itest/rust/src/string/string_name_test.rs b/itest/rust/src/builtin_tests/string/string_name_test.rs similarity index 100% rename from itest/rust/src/string/string_name_test.rs rename to itest/rust/src/builtin_tests/string/string_name_test.rs diff --git a/itest/rust/src/common.rs b/itest/rust/src/common.rs new file mode 100644 index 000000000..ff9364244 --- /dev/null +++ b/itest/rust/src/common.rs @@ -0,0 +1,22 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +use std::fmt::Debug; + +use godot::builtin::{FromVariant, ToVariant}; + +pub fn roundtrip(value: T) +where + T: FromVariant + ToVariant + PartialEq + Debug, +{ + // TODO test other roundtrip (first FromVariant, then ToVariant) + // Some values can be represented in Variant, but not in T (e.g. Variant(0i64) -> Option -> Variant is lossy) + + let variant = value.to_variant(); + let back = T::try_from_variant(&variant).unwrap(); + + assert_eq!(value, back); +} diff --git a/itest/rust/src/codegen_test.rs b/itest/rust/src/engine_tests/codegen_test.rs similarity index 91% rename from itest/rust/src/codegen_test.rs rename to itest/rust/src/engine_tests/codegen_test.rs index f4a076ae9..47ab0aabf 100644 --- a/itest/rust/src/codegen_test.rs +++ b/itest/rust/src/engine_tests/codegen_test.rs @@ -56,6 +56,13 @@ fn codegen_constants() { // assert_eq!(Material::RENDER_PRIORITY_MIN, -128); } +#[itest] +fn cfg_test() { + // Makes sure that since_api and before_api are mutually exclusive + assert_ne!(cfg!(since_api = "4.1"), cfg!(before_api = "4.1")); + assert_ne!(cfg!(since_api = "4.2"), cfg!(before_api = "4.2")); +} + // ---------------------------------------------------------------------------------------------------------------------------------------------- #[derive(GodotClass)] diff --git a/itest/rust/src/registration/mod.rs b/itest/rust/src/engine_tests/mod.rs similarity index 77% rename from itest/rust/src/registration/mod.rs rename to itest/rust/src/engine_tests/mod.rs index 37a164ed2..64b498bf7 100644 --- a/itest/rust/src/registration/mod.rs +++ b/itest/rust/src/engine_tests/mod.rs @@ -4,4 +4,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -mod constant_test; +mod native_structures_test; +mod node_test; +mod utilities_test; diff --git a/itest/rust/src/native_structures_test.rs b/itest/rust/src/engine_tests/native_structures_test.rs similarity index 100% rename from itest/rust/src/native_structures_test.rs rename to itest/rust/src/engine_tests/native_structures_test.rs diff --git a/itest/rust/src/node_test.rs b/itest/rust/src/engine_tests/node_test.rs similarity index 100% rename from itest/rust/src/node_test.rs rename to itest/rust/src/engine_tests/node_test.rs diff --git a/itest/rust/src/utilities_test.rs b/itest/rust/src/engine_tests/utilities_test.rs similarity index 100% rename from itest/rust/src/utilities_test.rs rename to itest/rust/src/engine_tests/utilities_test.rs diff --git a/itest/rust/src/framework/runner.rs b/itest/rust/src/framework/runner.rs index 7240257b1..8843489d6 100644 --- a/itest/rust/src/framework/runner.rs +++ b/itest/rust/src/framework/runner.rs @@ -16,7 +16,7 @@ use crate::framework::{passes_filter, RustTestCase, TestContext}; #[derive(GodotClass, Debug)] #[class(init)] -pub(crate) struct IntegrationTests { +pub struct IntegrationTests { total: i64, passed: i64, skipped: i64, diff --git a/itest/rust/src/lib.rs b/itest/rust/src/lib.rs index c89d546e6..e1b8c24bf 100644 --- a/itest/rust/src/lib.rs +++ b/itest/rust/src/lib.rs @@ -6,45 +6,15 @@ use godot::init::{gdextension, ExtensionLibrary}; +mod builtin_tests; +mod common; +mod engine_tests; mod framework; - -mod array_test; -mod base_test; -mod basis_test; -mod builtin_test; -mod callable_test; -mod codegen_test; -mod color_test; -mod derive_variant; -mod dictionary_test; -mod enum_test; -mod func_test; -mod gdscript_ffi_test; -mod init_test; -mod native_structures_test; -mod node_test; -mod object_test; -mod option_ffi_test; -mod packed_array_test; -mod plane_test; -mod projection_test; -mod property_test; -mod quaternion_test; -mod rect2_test; -mod rect2i_test; -mod registration; -mod rid_test; -mod signal_test; -mod singleton_test; -mod string; -mod transform2d_test; -mod transform3d_test; -mod utilities_test; -mod variant_test; -mod virtual_methods_test; +mod object_tests; +mod register_tests; // ---------------------------------------------------------------------------------------------------------------------------------------------- -// API for test cases +// Entry point #[gdextension(entry_point=itest_init)] unsafe impl ExtensionLibrary for framework::IntegrationTests {} diff --git a/itest/rust/src/base_test.rs b/itest/rust/src/object_tests/base_test.rs similarity index 100% rename from itest/rust/src/base_test.rs rename to itest/rust/src/object_tests/base_test.rs diff --git a/itest/rust/src/enum_test.rs b/itest/rust/src/object_tests/enum_test.rs similarity index 100% rename from itest/rust/src/enum_test.rs rename to itest/rust/src/object_tests/enum_test.rs diff --git a/itest/rust/src/string/mod.rs b/itest/rust/src/object_tests/mod.rs similarity index 68% rename from itest/rust/src/string/mod.rs rename to itest/rust/src/object_tests/mod.rs index e5a006e21..2a52061f6 100644 --- a/itest/rust/src/string/mod.rs +++ b/itest/rust/src/object_tests/mod.rs @@ -4,6 +4,8 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -mod godot_string_test; -mod node_path_test; -mod string_name_test; +mod base_test; +mod object_test; +mod property_test; +mod singleton_test; +mod virtual_methods_test; diff --git a/itest/rust/src/object_test.rs b/itest/rust/src/object_tests/object_test.rs similarity index 100% rename from itest/rust/src/object_test.rs rename to itest/rust/src/object_tests/object_test.rs diff --git a/itest/rust/src/property_test.rs b/itest/rust/src/object_tests/property_test.rs similarity index 100% rename from itest/rust/src/property_test.rs rename to itest/rust/src/object_tests/property_test.rs diff --git a/itest/rust/src/singleton_test.rs b/itest/rust/src/object_tests/singleton_test.rs similarity index 100% rename from itest/rust/src/singleton_test.rs rename to itest/rust/src/object_tests/singleton_test.rs diff --git a/itest/rust/src/virtual_methods_test.rs b/itest/rust/src/object_tests/virtual_methods_test.rs similarity index 100% rename from itest/rust/src/virtual_methods_test.rs rename to itest/rust/src/object_tests/virtual_methods_test.rs diff --git a/itest/rust/src/registration/constant_test.rs b/itest/rust/src/register_tests/constant_test.rs similarity index 100% rename from itest/rust/src/registration/constant_test.rs rename to itest/rust/src/register_tests/constant_test.rs diff --git a/itest/rust/src/derive_variant/enums_skip.rs b/itest/rust/src/register_tests/derive_variant/enums_skip.rs similarity index 100% rename from itest/rust/src/derive_variant/enums_skip.rs rename to itest/rust/src/register_tests/derive_variant/enums_skip.rs diff --git a/itest/rust/src/derive_variant/mod.rs b/itest/rust/src/register_tests/derive_variant/mod.rs similarity index 98% rename from itest/rust/src/derive_variant/mod.rs rename to itest/rust/src/register_tests/derive_variant/mod.rs index c2fbdd992..45d7004fc 100644 --- a/itest/rust/src/derive_variant/mod.rs +++ b/itest/rust/src/register_tests/derive_variant/mod.rs @@ -6,12 +6,13 @@ use std::fmt::Debug; -use crate::framework::itest; -use crate::variant_test::roundtrip; use godot::bind::FromVariant; use godot::bind::ToVariant; use godot::builtin::{dict, varray, FromVariant, ToVariant, Variant}; +use crate::common::roundtrip; +use crate::framework::itest; + #[macro_export] macro_rules! roundtrip_with_skip { ($name_to:ident, $name_from:ident, $value:expr, $to_var:expr, $from_var:expr) => { diff --git a/itest/rust/src/derive_variant/structs_skip.rs b/itest/rust/src/register_tests/derive_variant/structs_skip.rs similarity index 100% rename from itest/rust/src/derive_variant/structs_skip.rs rename to itest/rust/src/register_tests/derive_variant/structs_skip.rs diff --git a/itest/rust/src/func_test.rs b/itest/rust/src/register_tests/func_test.rs similarity index 95% rename from itest/rust/src/func_test.rs rename to itest/rust/src/register_tests/func_test.rs index b29019cf5..586158b57 100644 --- a/itest/rust/src/func_test.rs +++ b/itest/rust/src/register_tests/func_test.rs @@ -1,48 +1,48 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -use godot::prelude::*; - -#[derive(GodotClass)] -#[class(base=RefCounted)] -struct FuncRename; - -#[godot_api] -impl FuncRename { - #[func(rename=is_true)] - fn long_function_name_for_is_true(&self) -> bool { - true - } - - #[func(rename=give_one)] - fn give_one_inner(&self) -> i32 { - self.give_one() - } - - #[func(rename=spell_static)] - fn renamed_static() -> GodotString { - GodotString::from("static") - } -} - -impl FuncRename { - /// Unused but present to demonstrate how `rename = ...` can be used to avoid name clashes. - #[allow(dead_code)] - fn is_true(&self) -> bool { - false - } - - fn give_one(&self) -> i32 { - 1 - } -} - -#[godot_api] -impl RefCountedVirtual for FuncRename { - fn init(_base: Base) -> Self { - Self - } -} +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +use godot::prelude::*; + +#[derive(GodotClass)] +#[class(base=RefCounted)] +struct FuncRename; + +#[godot_api] +impl FuncRename { + #[func(rename=is_true)] + fn long_function_name_for_is_true(&self) -> bool { + true + } + + #[func(rename=give_one)] + fn give_one_inner(&self) -> i32 { + self.give_one() + } + + #[func(rename=spell_static)] + fn renamed_static() -> GodotString { + GodotString::from("static") + } +} + +impl FuncRename { + /// Unused but present to demonstrate how `rename = ...` can be used to avoid name clashes. + #[allow(dead_code)] + fn is_true(&self) -> bool { + false + } + + fn give_one(&self) -> i32 { + 1 + } +} + +#[godot_api] +impl RefCountedVirtual for FuncRename { + fn init(_base: Base) -> Self { + Self + } +} diff --git a/itest/rust/src/gdscript_ffi_test.rs b/itest/rust/src/register_tests/gdscript_ffi_test.rs similarity index 89% rename from itest/rust/src/gdscript_ffi_test.rs rename to itest/rust/src/register_tests/gdscript_ffi_test.rs index c75f7efae..93954c4ce 100644 --- a/itest/rust/src/gdscript_ffi_test.rs +++ b/itest/rust/src/register_tests/gdscript_ffi_test.rs @@ -7,5 +7,5 @@ #![allow(dead_code)] #[rustfmt::skip] -#[path = "gen/gen_ffi.rs"] +#[path = "../gen/gen_ffi.rs"] mod gen_ffi; diff --git a/itest/rust/src/register_tests/mod.rs b/itest/rust/src/register_tests/mod.rs new file mode 100644 index 000000000..ea489be21 --- /dev/null +++ b/itest/rust/src/register_tests/mod.rs @@ -0,0 +1,12 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +mod constant_test; +mod derive_variant; +mod func_test; +mod gdscript_ffi_test; +mod option_ffi_test; +mod var_test; diff --git a/itest/rust/src/option_ffi_test.rs b/itest/rust/src/register_tests/option_ffi_test.rs similarity index 100% rename from itest/rust/src/option_ffi_test.rs rename to itest/rust/src/register_tests/option_ffi_test.rs diff --git a/itest/rust/src/init_test.rs b/itest/rust/src/register_tests/var_test.rs similarity index 68% rename from itest/rust/src/init_test.rs rename to itest/rust/src/register_tests/var_test.rs index 4dd326f76..ef4406d93 100644 --- a/itest/rust/src/init_test.rs +++ b/itest/rust/src/register_tests/var_test.rs @@ -4,7 +4,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::framework::itest; use godot::prelude::*; #[derive(GodotClass)] @@ -25,10 +24,3 @@ struct WithInitDefaults { // TODO Remove once https://github.com/godot-rust/gdext/issues/187 is fixed #[godot_api] impl WithInitDefaults {} - -#[itest] -fn cfg_test() { - // Makes sure that since_api and before_api are mutually exclusive - assert_ne!(cfg!(since_api = "4.1"), cfg!(before_api = "4.1")); - assert_ne!(cfg!(since_api = "4.2"), cfg!(before_api = "4.2")); -}