summaryrefslogtreecommitdiff
path: root/modules/gdscript/tests/gdscript_test_runner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/tests/gdscript_test_runner.cpp')
-rw-r--r--modules/gdscript/tests/gdscript_test_runner.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp
index d2c8b5c317..5b8af0ff34 100644
--- a/modules/gdscript/tests/gdscript_test_runner.cpp
+++ b/modules/gdscript/tests/gdscript_test_runner.cpp
@@ -132,9 +132,10 @@ void finish_language() {
StringName GDScriptTestRunner::test_function_name;
-GDScriptTestRunner::GDScriptTestRunner(const String &p_source_dir, bool p_init_language) {
+GDScriptTestRunner::GDScriptTestRunner(const String &p_source_dir, bool p_init_language, bool p_print_filenames) {
test_function_name = StaticCString::create("test");
do_init_languages = p_init_language;
+ print_filenames = p_print_filenames;
source_dir = p_source_dir;
if (!source_dir.ends_with("/")) {
@@ -194,6 +195,9 @@ int GDScriptTestRunner::run_tests() {
int failed = 0;
for (int i = 0; i < tests.size(); i++) {
GDScriptTest test = tests[i];
+ if (print_filenames) {
+ print_line(test.get_source_relative_filepath());
+ }
GDScriptTest::TestResult result = test.run_test();
String expected = FileAccess::get_file_as_string(test.get_output_file());
@@ -225,8 +229,13 @@ bool GDScriptTestRunner::generate_outputs() {
}
for (int i = 0; i < tests.size(); i++) {
- OS::get_singleton()->print(".");
GDScriptTest test = tests[i];
+ if (print_filenames) {
+ print_line(test.get_source_relative_filepath());
+ } else {
+ OS::get_singleton()->print(".");
+ }
+
bool result = test.generate_output();
if (!result) {
@@ -337,15 +346,10 @@ GDScriptTest::GDScriptTest(const String &p_source_path, const String &p_output_p
void GDScriptTestRunner::handle_cmdline() {
List<String> cmdline_args = OS::get_singleton()->get_cmdline_args();
- // TODO: this could likely be ported to use test commands:
- // https://github.com/godotengine/godot/pull/41355
- // Currently requires to startup the whole engine, which is slow.
- String test_cmd = "--gdscript-test";
- String gen_cmd = "--gdscript-generate-tests";
for (List<String>::Element *E = cmdline_args.front(); E; E = E->next()) {
String &cmd = E->get();
- if (cmd == test_cmd || cmd == gen_cmd) {
+ if (cmd == "--gdscript-generate-tests") {
if (E->next() == nullptr) {
ERR_PRINT("Needed a path for the test files.");
exit(-1);
@@ -353,14 +357,10 @@ void GDScriptTestRunner::handle_cmdline() {
const String &path = E->next()->get();
- GDScriptTestRunner runner(path, false);
- int failed = 0;
- if (cmd == test_cmd) {
- failed = runner.run_tests();
- } else {
- bool completed = runner.generate_outputs();
- failed = completed ? 0 : -1;
- }
+ GDScriptTestRunner runner(path, false, cmdline_args.find("--print-filenames") != nullptr);
+
+ bool completed = runner.generate_outputs();
+ int failed = completed ? 0 : -1;
exit(failed);
}
}