summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorRevoluPowered <gordon@gordonite.tech>2020-07-20 17:35:34 +0100
committerGordon MacPherson <gordon@gordonite.tech>2020-07-24 13:05:33 +0100
commit579342810f5c453e91063c54ca6544300ea09090 (patch)
treeb01e1478605b835e1fe903384d753b114106d51e /platform
parent93b50a62e333cd05702fb749ebcdc18127abe01b (diff)
t Add unit testing to Godot using DocTest and added to GitHub Actions CI
Implements exit codes into the engine so tests can return their statuses. Ideally we don't do this, and we use FIXUP logic to 'begin' and 'end' the engine execution for tests specifically. Since realistically we're initialising the engine here we don't want to do that, since String should not require an engine startup to test a single header. This lowers the complexity of running the unit tests and even for physics should be possible to implement such a fix.
Diffstat (limited to 'platform')
-rw-r--r--platform/iphone/godot_iphone.cpp3
-rw-r--r--platform/javascript/javascript_main.cpp4
-rw-r--r--platform/linuxbsd/godot_linuxbsd.cpp3
-rw-r--r--platform/osx/godot_main_osx.mm5
-rw-r--r--platform/server/godot_server.cpp3
-rw-r--r--platform/windows/godot_windows.cpp8
6 files changed, 23 insertions, 3 deletions
diff --git a/platform/iphone/godot_iphone.cpp b/platform/iphone/godot_iphone.cpp
index b9d217c9d2..aa5dbd5130 100644
--- a/platform/iphone/godot_iphone.cpp
+++ b/platform/iphone/godot_iphone.cpp
@@ -67,6 +67,9 @@ int iphone_main(int width, int height, int argc, char **argv, String data_dir) {
printf("cwd %s\n", cwd);
os = new OSIPhone(width, height, data_dir);
+ // We must override main when testing is enabled
+ TEST_MAIN_OVERRIDE
+
char *fargv[64];
for (int i = 0; i < argc; i++) {
fargv[i] = argv[i];
diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp
index 99672745e7..f697887f08 100644
--- a/platform/javascript/javascript_main.cpp
+++ b/platform/javascript/javascript_main.cpp
@@ -131,6 +131,10 @@ int main(int argc, char *argv[]) {
/* clang-format on */
os = new OS_JavaScript();
+
+ // We must override main when testing is enabled
+ TEST_MAIN_OVERRIDE
+
Main::setup(argv[0], argc - 1, &argv[1], false);
emscripten_set_main_loop(main_loop_callback, -1, false);
emscripten_pause_main_loop(); // Will need to wait for FS sync.
diff --git a/platform/linuxbsd/godot_linuxbsd.cpp b/platform/linuxbsd/godot_linuxbsd.cpp
index 3ed64e9d46..e1796ccefe 100644
--- a/platform/linuxbsd/godot_linuxbsd.cpp
+++ b/platform/linuxbsd/godot_linuxbsd.cpp
@@ -41,6 +41,9 @@ int main(int argc, char *argv[]) {
setlocale(LC_CTYPE, "");
+ // We must override main when testing is enabled
+ TEST_MAIN_OVERRIDE
+
char *cwd = (char *)malloc(PATH_MAX);
ERR_FAIL_COND_V(!cwd, ERR_OUT_OF_MEMORY);
char *ret = getcwd(cwd, PATH_MAX);
diff --git a/platform/osx/godot_main_osx.mm b/platform/osx/godot_main_osx.mm
index 93d0d6168c..4e73d5441c 100644
--- a/platform/osx/godot_main_osx.mm
+++ b/platform/osx/godot_main_osx.mm
@@ -37,7 +37,7 @@
int main(int argc, char **argv) {
#if defined(VULKAN_ENABLED)
- //MoltenVK - enable full component swizzling support
+ // MoltenVK - enable full component swizzling support
setenv("MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE", "1", 1);
#endif
@@ -60,6 +60,9 @@ int main(int argc, char **argv) {
OS_OSX os;
Error err;
+ // We must override main when testing is enabled
+ TEST_MAIN_OVERRIDE
+
if (os.open_with_filename != "") {
char *argv_c = (char *)malloc(os.open_with_filename.utf8().size());
memcpy(argv_c, os.open_with_filename.utf8().get_data(), os.open_with_filename.utf8().size());
diff --git a/platform/server/godot_server.cpp b/platform/server/godot_server.cpp
index 32bd943ac3..9f22240a80 100644
--- a/platform/server/godot_server.cpp
+++ b/platform/server/godot_server.cpp
@@ -34,6 +34,9 @@
int main(int argc, char *argv[]) {
OS_Server os;
+ // We must override main when testing is enabled
+ TEST_MAIN_OVERRIDE
+
Error err = Main::setup(argv[0], argc - 1, &argv[1]);
if (err != OK)
return 255;
diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp
index 910059a9fc..add559a717 100644
--- a/platform/windows/godot_windows.cpp
+++ b/platform/windows/godot_windows.cpp
@@ -146,6 +146,8 @@ int widechar_main(int argc, wchar_t **argv) {
argv_utf8[i] = wc_to_utf8(argv[i]);
}
+ TEST_MAIN_PARAM_OVERRIDE(argc, argv_utf8)
+
Error err = Main::setup(argv_utf8[0], argc - 1, &argv_utf8[1]);
if (err != OK) {
@@ -186,10 +188,12 @@ int _main() {
return result;
}
-int main(int _argc, char **_argv) {
+int main(int argc, char **argv) {
+ // override the arguments for the test handler / if symbol is provided
+ // TEST_MAIN_OVERRIDE
+
// _argc and _argv are ignored
// we are going to use the WideChar version of them instead
-
#ifdef CRASH_HANDLER_EXCEPTION
__try {
return _main();