Browse Source

Merge pull request #93745 from AThousandShips/test_template_fix

[Tests] Fix unit tests in template builds
Rémi Verschelde 1 year ago
parent
commit
2f7973f04b

+ 3 - 1
tests/core/math/test_vector2.h

@@ -353,7 +353,6 @@ TEST_CASE("[Vector2] Plane methods") {
 	const Vector2 vector = Vector2(1.2, 3.4);
 	const Vector2 vector_y = Vector2(0, 1);
 	const Vector2 vector_normal = Vector2(0.95879811270838721622267, 0.2840883296913739899919);
-	const Vector2 vector_non_normal = Vector2(5.4, 1.6);
 	const real_t p_d = 99.1;
 	CHECK_MESSAGE(
 			vector.bounce(vector_y) == Vector2(1.2, -3.4),
@@ -383,6 +382,8 @@ TEST_CASE("[Vector2] Plane methods") {
 			vector.slide(vector_normal).is_equal_approx(Vector2(-0.8292559899117276166456, 2.798738965952080706179)),
 			"Vector2 slide with normal should return expected value.");
 	// There's probably a better way to test these ones?
+#ifdef MATH_CHECKS
+	const Vector2 vector_non_normal = Vector2(5.4, 1.6);
 	ERR_PRINT_OFF;
 	CHECK_MESSAGE(
 			vector.bounce(vector_non_normal).is_equal_approx(Vector2()),
@@ -394,6 +395,7 @@ TEST_CASE("[Vector2] Plane methods") {
 			vector.slide(vector_non_normal).is_equal_approx(Vector2()),
 			"Vector2 slide should return empty Vector2 with non-normalized input.");
 	ERR_PRINT_ON;
+#endif // MATH_CHECKS
 }
 
 TEST_CASE("[Vector2] Rounding methods") {

+ 3 - 1
tests/core/math/test_vector3.h

@@ -368,7 +368,6 @@ TEST_CASE("[Vector3] Plane methods") {
 	const Vector3 vector = Vector3(1.2, 3.4, 5.6);
 	const Vector3 vector_y = Vector3(0, 1, 0);
 	const Vector3 vector_normal = Vector3(0.88763458893247992491, 0.26300284116517923701, 0.37806658417494515320);
-	const Vector3 vector_non_normal = Vector3(5.4, 1.6, 2.3);
 	CHECK_MESSAGE(
 			vector.bounce(vector_y) == Vector3(1.2, -3.4, 5.6),
 			"Vector3 bounce on a plane with normal of the Y axis should.");
@@ -394,6 +393,8 @@ TEST_CASE("[Vector3] Plane methods") {
 			vector.slide(vector_normal).is_equal_approx(Vector3(-2.41848149148878681437, 2.32785733585517427722237, 4.0587949202918130235)),
 			"Vector3 slide with normal should return expected value.");
 	// There's probably a better way to test these ones?
+#ifdef MATH_CHECKS
+	const Vector3 vector_non_normal = Vector3(5.4, 1.6, 2.3);
 	ERR_PRINT_OFF;
 	CHECK_MESSAGE(
 			vector.bounce(vector_non_normal).is_equal_approx(Vector3()),
@@ -405,6 +406,7 @@ TEST_CASE("[Vector3] Plane methods") {
 			vector.slide(vector_non_normal).is_equal_approx(Vector3()),
 			"Vector3 slide should return empty Vector3 with non-normalized input.");
 	ERR_PRINT_ON;
+#endif // MATH_CHECKS
 }
 
 TEST_CASE("[Vector3] Rounding methods") {

+ 2 - 0
tests/core/object/test_class_db.h

@@ -375,8 +375,10 @@ void validate_property(const Context &p_context, const ExposedClass &p_class, co
 }
 
 void validate_argument(const Context &p_context, const ExposedClass &p_class, const String &p_owner_name, const String &p_owner_type, const ArgumentData &p_arg) {
+#ifdef DEBUG_METHODS_ENABLED
 	TEST_COND((p_arg.name.is_empty() || p_arg.name.begins_with("_unnamed_arg")),
 			vformat("Unnamed argument in position %d of %s '%s.%s'.", p_arg.position, p_owner_type, p_class.name, p_owner_name));
+#endif // DEBUG_METHODS_ENABLED
 
 	const ExposedClass *arg_class = p_context.find_exposed_class(p_arg.type);
 	if (arg_class) {

+ 2 - 0
tests/core/os/test_os.h

@@ -163,12 +163,14 @@ TEST_CASE("[OS] Processor count and memory information") {
 	CHECK_MESSAGE(
 			OS::get_singleton()->get_processor_count() >= 1,
 			"The returned processor count should be greater than zero.");
+#ifdef DEBUG_ENABLED
 	CHECK_MESSAGE(
 			OS::get_singleton()->get_static_memory_usage() >= 1,
 			"The returned static memory usage should be greater than zero.");
 	CHECK_MESSAGE(
 			OS::get_singleton()->get_static_memory_peak_usage() >= 1,
 			"The returned static memory peak usage should be greater than zero.");
+#endif // DEBUG_ENABLED
 }
 
 TEST_CASE("[OS] Execute") {

+ 2 - 0
tests/scene/test_instance_placeholder.h

@@ -333,6 +333,7 @@ TEST_CASE("[SceneTree][InstancePlaceholder] Instantiate from placeholder with ov
 	}
 }
 
+#ifdef TOOLS_ENABLED
 TEST_CASE("[SceneTree][InstancePlaceholder] Instance a PackedScene containing an InstancePlaceholder with no overrides") {
 	GDREGISTER_CLASS(_TestInstancePlaceholderNode);
 
@@ -526,6 +527,7 @@ TEST_CASE("[SceneTree][InstancePlaceholder] Instance a PackedScene containing an
 	DirAccess::remove_file_or_error(internal_path);
 	DirAccess::remove_file_or_error(main_path);
 }
+#endif // TOOLS_ENABLED
 
 } //namespace TestInstancePlaceholder
 

+ 2 - 0
tests/scene/test_node.h

@@ -529,6 +529,7 @@ TEST_CASE("[SceneTree][Node]Exported node checks") {
 		memdelete(dup);
 	}
 
+#ifdef TOOLS_ENABLED
 	SUBCASE("Saving instance with exported nodes should not store the unchanged property") {
 		Ref<PackedScene> ps;
 		ps.instantiate();
@@ -602,6 +603,7 @@ TEST_CASE("[SceneTree][Node]Exported node checks") {
 		}
 		CHECK_EQ(stored_properties, 2);
 	}
+#endif // TOOLS_ENABLED
 
 	memdelete(node);
 }