Skip to content

Commit

Permalink
Disable certain tests, which rely on Godot checks in Release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Dec 17, 2023
1 parent 5df258a commit 5fd22af
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
6 changes: 6 additions & 0 deletions itest/godot/ManualFfiTests.gd
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,19 @@ func test_custom_property():
assert_eq(d.b, 33)

func test_custom_property_wrong_values_1():
if runs_release():
return

var has_property: HasCustomProperty = HasCustomProperty.new()
disable_error_messages()
has_property.some_c_style_enum = 10 # Should fail.
enable_error_messages()
assert_fail("HasCustomProperty.some_c_style_enum should only accept integers in the range `(0 ..= 2)`")

func test_custom_property_wrong_values_2():
if runs_release():
return

var has_property: HasCustomProperty = HasCustomProperty.new()
disable_error_messages()
has_property.not_exportable = {"a": "hello", "b": Callable()} # Should fail.
Expand Down
5 changes: 5 additions & 0 deletions itest/godot/TestSuite.gd
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@ func assert_fail(message: String = "") -> bool:
print_error("Test execution should have failed")

return false

## Some tests are disabled, as they rely on Godot checks which are only available in Debug builds.
## See https://github.com/godotengine/godot/issues/86264.
static func runs_release() -> bool:
return !OS.is_debug_build()
24 changes: 13 additions & 11 deletions itest/rust/src/builtin_tests/containers/variant_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use godot::obj::InstanceId;
use godot::sys::GodotFfi;

use crate::common::roundtrip;
use crate::framework::{expect_panic, itest};
use crate::framework::{expect_panic, itest, runs_release};

const TEST_BASIS: Basis = Basis::from_rows(
Vector3::new(1.0, 2.0, 3.0),
Expand Down Expand Up @@ -146,16 +146,18 @@ fn variant_call() {
let result = vector.to_variant().call("dot", &[vector_rhs.to_variant()]);
assert_eq!(result, 2.0.to_variant());

// Error cases
expect_panic("Variant::call on non-existent method", || {
variant.call("gut_position", &[]);
});
expect_panic("Variant::call with bad signature", || {
variant.call("set_position", &[]);
});
expect_panic("Variant::call with non-object variant (int)", || {
Variant::from(77).call("to_string", &[]);
});
// Dynamic checks are only available in Debug builds.
if !runs_release() {
expect_panic("Variant::call on non-existent method", || {
variant.call("gut_position", &[]);
});
expect_panic("Variant::call with bad signature", || {
variant.call("set_position", &[]);
});
expect_panic("Variant::call with non-object variant (int)", || {
Variant::from(77).call("to_string", &[]);
});
}

node2d.free();
}
Expand Down
8 changes: 7 additions & 1 deletion itest/rust/src/framework/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

use godot::engine::{Engine, Node};
use godot::engine::{Engine, Node, Os};
use godot::obj::Gd;
use godot::sys;
use std::collections::HashSet;
Expand Down Expand Up @@ -128,3 +128,9 @@ pub fn suppress_godot_print(mut f: impl FnMut()) {
f();
Engine::singleton().set_print_error_messages(true);
}

/// Some tests are disabled, as they rely on Godot checks which are only available in Debug builds.
/// See https://github.com/godotengine/godot/issues/86264.
pub fn runs_release() -> bool {
!Os::singleton().is_debug_build()
}

0 comments on commit 5fd22af

Please sign in to comment.