summaryrefslogtreecommitdiff
path: root/modules/gdscript/tests
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-02-01 10:54:22 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-02-01 10:54:22 +0100
commitafe3b94ab28a28d562fd96f3daf41a22cb26757a (patch)
tree1b2e0cfc8e529ae652f79c286495527883581fa6 /modules/gdscript/tests
parentf7397a5ac6bffc0df24cae61b8aabfa4a3b65347 (diff)
Revert "GDScript: Add warnings that are set to error by default"
This reverts commit a166833bfa23a21a7bff196a85a20b014e7c1396. This caused multiple regressions. Needs to be redone with more testing before merge. Fixes #72501.
Diffstat (limited to 'modules/gdscript/tests')
-rw-r--r--modules/gdscript/tests/gdscript_test_runner.cpp6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.gd15
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.out14
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.gd6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.out6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.gd6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.out6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.gd5
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out6
11 files changed, 5 insertions, 71 deletions
diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp
index 57405aa1ce..5b8af0ff34 100644
--- a/modules/gdscript/tests/gdscript_test_runner.cpp
+++ b/modules/gdscript/tests/gdscript_test_runner.cpp
@@ -146,11 +146,11 @@ GDScriptTestRunner::GDScriptTestRunner(const String &p_source_dir, bool p_init_l
init_language(p_source_dir);
}
#ifdef DEBUG_ENABLED
- // Set all warning levels to "Warn" in order to test them properly, even the ones that default to error.
+ // Enable all warnings for GDScript, so we can test them.
ProjectSettings::get_singleton()->set_setting("debug/gdscript/warnings/enable", true);
for (int i = 0; i < (int)GDScriptWarning::WARNING_MAX; i++) {
- String warning_setting = GDScriptWarning::get_settings_path_from_code((GDScriptWarning::Code)i);
- ProjectSettings::get_singleton()->set_setting(warning_setting, (int)GDScriptWarning::WARN);
+ String warning = GDScriptWarning::get_name_from_code((GDScriptWarning::Code)i).to_lower();
+ ProjectSettings::get_singleton()->set_setting("debug/gdscript/warnings/" + warning, true);
}
#endif
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.out b/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.out
index 508e46742f..c70a1df10d 100644
--- a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.out
+++ b/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.out
@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
-The function signature doesn't match the parent. Parent signature is "my_function(int = <default>) -> int".
+The function signature doesn't match the parent. Parent signature is "my_function(int = default) -> int".
diff --git a/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd b/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd
index b447180ea8..48a804ff54 100644
--- a/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd
+++ b/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd
@@ -2,18 +2,16 @@ func variant() -> Variant: return null
var member_weak = variant()
var member_typed: Variant = variant()
-@warning_ignore("inference_on_variant")
var member_inferred := variant()
func param_weak(param = variant()) -> void: print(param)
func param_typed(param: Variant = variant()) -> void: print(param)
-@warning_ignore("inference_on_variant")
func param_inferred(param := variant()) -> void: print(param)
func return_untyped(): return variant()
func return_typed() -> Variant: return variant()
-@warning_ignore("unused_variable", "inference_on_variant")
+@warning_ignore("unused_variable")
func test() -> void:
var weak = variant()
var typed: Variant = variant()
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.gd b/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.gd
deleted file mode 100644
index bf5ea241ec..0000000000
--- a/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.gd
+++ /dev/null
@@ -1,15 +0,0 @@
-extends Node
-
-var add_node = do_add_node() # Hack to have one node on init and not fail at runtime.
-
-var shorthand = $Node
-var with_self = self.get_node("Node")
-var without_self = get_node("Node")
-
-func test():
- print("warn")
-
-func do_add_node():
- var node = Node.new()
- node.name = "Node"
- add_child(node)
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.out b/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.out
deleted file mode 100644
index 11cd9c678b..0000000000
--- a/modules/gdscript/tests/scripts/analyzer/warnings/get_node_without_onready.out
+++ /dev/null
@@ -1,14 +0,0 @@
-GDTEST_OK
->> WARNING
->> Line: 5
->> GET_NODE_DEFAULT_WITHOUT_ONREADY
->> The default value is using "$" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
->> WARNING
->> Line: 6
->> GET_NODE_DEFAULT_WITHOUT_ONREADY
->> The default value is using "get_node()" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
->> WARNING
->> Line: 7
->> GET_NODE_DEFAULT_WITHOUT_ONREADY
->> The default value is using "get_node()" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this.
-warn
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.gd b/modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.gd
deleted file mode 100644
index 024e91b7c6..0000000000
--- a/modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.gd
+++ /dev/null
@@ -1,6 +0,0 @@
-func test():
- var inferred_with_variant := return_variant()
- print(inferred_with_variant)
-
-func return_variant() -> Variant:
- return "warn"
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.out b/modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.out
deleted file mode 100644
index 1d4078d2f7..0000000000
--- a/modules/gdscript/tests/scripts/analyzer/warnings/inference_with_variant.out
+++ /dev/null
@@ -1,6 +0,0 @@
-GDTEST_OK
->> WARNING
->> Line: 2
->> INFERENCE_ON_VARIANT
->> The variable type is being inferred from a Variant value, so it will be typed as Variant.
-warn
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.gd b/modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.gd
deleted file mode 100644
index 0b358ca5f2..0000000000
--- a/modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.gd
+++ /dev/null
@@ -1,6 +0,0 @@
-extends Node
-
-@onready @export var conflict = ""
-
-func test():
- print("warn")
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.out b/modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.out
deleted file mode 100644
index ff184f9f04..0000000000
--- a/modules/gdscript/tests/scripts/analyzer/warnings/onready_with_export.out
+++ /dev/null
@@ -1,6 +0,0 @@
-GDTEST_OK
->> WARNING
->> Line: 3
->> ONREADY_WITH_EXPORT
->> The "@onready" annotation will make the default value to be set after the "@export" takes effect and will override it.
-warn
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.gd b/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.gd
deleted file mode 100644
index 19d40f8ec8..0000000000
--- a/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.gd
+++ /dev/null
@@ -1,5 +0,0 @@
-func test():
- print("warn")
-
-func get(_property: StringName) -> Variant:
- return null
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out b/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out
deleted file mode 100644
index 793faa05d4..0000000000
--- a/modules/gdscript/tests/scripts/analyzer/warnings/overriding_native_method.out
+++ /dev/null
@@ -1,6 +0,0 @@
-GDTEST_OK
->> WARNING
->> Line: 4
->> NATIVE_METHOD_OVERRIDE
->> The method "get" overrides a method from native class "Object". This won't be called by the engine and may not work as expected.
-warn