Remove some abort() calls
authorest31 <MTest31@outlook.com>
Mon, 26 Oct 2015 03:13:27 +0000 (04:13 +0100)
committerest31 <MTest31@outlook.com>
Mon, 26 Oct 2015 03:45:00 +0000 (04:45 +0100)
abort() doesn't benefit from the high level abstractions from FATAL_ERROR.

src/main.cpp
src/script/cpp_api/s_async.cpp
src/unittest/test.cpp
src/unittest/test.h

index 1538c15d49271b8cd9dbe4df80c8a835d1b04d63..1fa9243fa78cc2c0daba873ec238da9d4a52b970 100644 (file)
@@ -183,8 +183,7 @@ int main(int argc, char *argv[])
 #ifndef __ANDROID__
        // Run unit tests
        if (cmd_args.getFlag("run-unittests")) {
-               run_tests();
-               return 0;
+               return run_tests();
        }
 #endif
 
index d18ff6e8c47b7998f3dd4823ec21ee00caff39b3..1716326330355825b9b9e94b7fcf1de18e42bf11 100644 (file)
@@ -244,17 +244,14 @@ void* AsyncWorkerThread::run()
 
        std::string script = getServer()->getBuiltinLuaPath() + DIR_DELIM + "init.lua";
        if (!loadScript(script)) {
-               errorstream << "execution of async base environment failed!"
-                       << std::endl;
-               abort();
+               FATAL_ERROR("execution of async base environment failed!");
        }
 
        int error_handler = PUSH_ERROR_HANDLER(L);
 
        lua_getglobal(L, "core");
        if (lua_isnil(L, -1)) {
-               errorstream << "Unable to find core within async environment!";
-               abort();
+               FATAL_ERROR("Unable to find core within async environment!");
        }
 
        // Main loop
@@ -268,8 +265,7 @@ void* AsyncWorkerThread::run()
 
                lua_getfield(L, -1, "job_processor");
                if (lua_isnil(L, -1)) {
-                       errorstream << "Unable to get async job processor!" << std::endl;
-                       abort();
+                       FATAL_ERROR("Unable to get async job processor!");
                }
 
                luaL_checktype(L, -1, LUA_TFUNCTION);
index 1f3b31017b3c5068126a67451d89bc9f581ac9f4..41ccf0d2d134e38e8f31393130f817676100f360 100644 (file)
@@ -215,7 +215,7 @@ void TestGameDef::defineSomeNodes()
 //// run_tests
 ////
 
-void run_tests()
+bool run_tests()
 {
        DSTACK(FUNCTION_NAME);
 
@@ -253,8 +253,7 @@ void run_tests()
                << "++++++++++++++++++++++++++++++++++++++++"
                << "++++++++++++++++++++++++++++++++++++++++" << std::endl;
 
-       if (num_modules_failed)
-               abort();
+       return num_modules_failed;
 }
 
 ////
index f6c4711a5ce08b40fd49903ce28c985465cd420f..e60e657cc969cf43c1cb47c1ab3fbf5982bf347e 100644 (file)
@@ -142,6 +142,6 @@ extern content_t t_CONTENT_WATER;
 extern content_t t_CONTENT_LAVA;
 extern content_t t_CONTENT_BRICK;
 
-void run_tests();
+bool run_tests();
 
 #endif