Browse Source

Add simple test cases as part of the Travis CI build.

Also fix Editor in case-sensitive platforms.
Yao Wei Tjong 姚伟忠 12 years ago
parent
commit
088eef9e60

+ 1 - 1
.travis.yml

@@ -4,7 +4,7 @@ before_install:
     - sudo add-apt-repository ppa:george-edison55/precise-backports -y
     - sudo add-apt-repository ppa:george-edison55/precise-backports -y
     - sudo apt-get update -q -y
     - sudo apt-get update -q -y
     - sudo apt-get install -q -y libx11-dev libxrandr-dev libasound2-dev libgl1-mesa-dev doxygen graphviz
     - sudo apt-get install -q -y libx11-dev libxrandr-dev libasound2-dev libgl1-mesa-dev doxygen graphviz
-script: ./cmake_gcc.sh -DURHO3D_LIB_TYPE=$TEST_LIB_TYPE -DENABLE_64BIT=1 -DENABLE_LUAJIT=1 -DENABLE_LUAJIT_AMALG=1 -DENABLE_SAMPLES=1 -DENABLE_TOOLS=1 -DENABLE_EXTRAS=1 && cd Build && make
+script: ./cmake_gcc.sh -DURHO3D_LIB_TYPE=$TEST_LIB_TYPE -DENABLE_64BIT=1 -DENABLE_LUAJIT=1 -DENABLE_LUAJIT_AMALG=1 -DENABLE_SAMPLES=1 -DENABLE_TOOLS=1 -DENABLE_EXTRAS=1 -DENABLE_TESTING=1 && cd Build && make && make test
 after_success: rake travis
 after_success: rake travis
 env:
 env:
   global:
   global:

+ 1 - 1
Bin/Data/Scripts/Editor.as

@@ -10,7 +10,7 @@
 #include "Scripts/Editor/EditorSettings.as"
 #include "Scripts/Editor/EditorSettings.as"
 #include "Scripts/Editor/EditorPreferences.as"
 #include "Scripts/Editor/EditorPreferences.as"
 #include "Scripts/Editor/EditorToolBar.as"
 #include "Scripts/Editor/EditorToolBar.as"
-#include "Scripts/Editor/EditorSecondaryToolBar.as"
+#include "Scripts/Editor/EditorSecondaryToolbar.as"
 #include "Scripts/Editor/EditorUI.as"
 #include "Scripts/Editor/EditorUI.as"
 #include "Scripts/Editor/EditorImport.as"
 #include "Scripts/Editor/EditorImport.as"
 
 

+ 7 - 0
Source/CMake/Modules/Urho3D-CMake-magic.cmake

@@ -34,6 +34,13 @@ if (CMAKE_HOST_WIN32)
     endif ()
     endif ()
 endif ()
 endif ()
 
 
+# Enable testing
+if (ENABLE_TESTING)
+    enable_testing ()
+    add_definitions (-DENABLE_TESTING)
+    set (TEST_TIME_OUT 5)    # in seconds
+endif ()
+
 # Enable SSE instruction set. Requires Pentium III or Athlon XP processor at minimum.
 # Enable SSE instruction set. Requires Pentium III or Athlon XP processor at minimum.
 if (NOT DEFINED ENABLE_SSE)
 if (NOT DEFINED ENABLE_SSE)
     set (ENABLE_SSE 1)
     set (ENABLE_SSE 1)

+ 23 - 1
Source/Engine/Engine/Engine.cpp

@@ -92,6 +92,9 @@ Engine::Engine(Context* context) :
     maxInactiveFps_(60),
     maxInactiveFps_(60),
     pauseMinimized_(false),
     pauseMinimized_(false),
     #endif
     #endif
+#ifdef ENABLE_TESTING
+    timeOut_(0),
+#endif
     autoExit_(true),
     autoExit_(true),
     initialized_(false),
     initialized_(false),
 #ifdef ANDROID
 #ifdef ANDROID
@@ -258,7 +261,6 @@ bool Engine::Initialize(const VariantMap& parameters)
         }
         }
     }
     }
 
 
-
     // Initialize graphics & audio output
     // Initialize graphics & audio output
     if (!headless_)
     if (!headless_)
     {
     {
@@ -302,6 +304,11 @@ bool Engine::Initialize(const VariantMap& parameters)
     // Init FPU state of main thread
     // Init FPU state of main thread
     InitFPU();
     InitFPU();
 
 
+    #ifdef ENABLE_TESTING
+    if (HasParameter(parameters, "TimeOut"))
+        timeOut_ = GetParameter(parameters, "TimeOut", 0).GetInt() * 1000000LL;
+    #endif
+
     frameTimer_.Reset();
     frameTimer_.Reset();
 
 
     initialized_ = true;
     initialized_ = true;
@@ -580,6 +587,14 @@ void Engine::ApplyFrameLimit()
     }
     }
 
 
     elapsed = frameTimer_.GetUSec(true);
     elapsed = frameTimer_.GetUSec(true);
+    #ifdef ENABLE_TESTING
+    if (timeOut_ != 0)
+    {
+        timeOut_ -= elapsed;
+        if (timeOut_ < 0)
+            Exit();
+    }
+    #endif
 
 
     // If FPS lower than minimum, clamp elapsed time
     // If FPS lower than minimum, clamp elapsed time
     if (minFps_)
     if (minFps_)
@@ -688,6 +703,13 @@ VariantMap Engine::ParseParameters(const Vector<String>& arguments)
                 ret["ResourcePaths"] = value;
                 ret["ResourcePaths"] = value;
                 ++i;
                 ++i;
             }
             }
+            #ifdef ENABLE_TESTING
+            else if (argument == "timeout" && !value.Empty())
+            {
+                ret["TimeOut"] = ToInt(value);
+                ++i;
+            }
+            #endif
         }
         }
     }
     }
 
 

+ 4 - 0
Source/Engine/Engine/Engine.h

@@ -126,6 +126,10 @@ private:
     unsigned maxInactiveFps_;
     unsigned maxInactiveFps_;
     /// Pause when minimized flag.
     /// Pause when minimized flag.
     bool pauseMinimized_;
     bool pauseMinimized_;
+#ifdef ENABLE_TESTING
+    /// Time out counter for testing.
+    long long timeOut_;
+#endif
     /// Auto-exit flag.
     /// Auto-exit flag.
     bool autoExit_;
     bool autoExit_;
     /// Initialized flag.
     /// Initialized flag.

+ 3 - 0
Source/Samples/01_HelloWorld/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/02_HelloGUI/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/03_Sprites/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/04_StaticScene/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/05_AnimatingScene/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/06_SkeletalAnimation/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/07_Billboards/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/08_Decals/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/09_MultipleViewports/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/10_RenderToTexture/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/11_Physics/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/12_PhysicsStressTest/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/13_Ragdolls/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/14_SoundEffects/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/15_Navigation/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/16_Chat/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/17_SceneReplication/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/18_CharacterDemo/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/19_VehicleDemo/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/20_HugeObjectCount/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/21_AngelScriptIntegration/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 3 - 0
Source/Samples/22_LuaIntegration/CMakeLists.txt

@@ -28,3 +28,6 @@ define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} -timeout ${TEST_TIME_OUT})

+ 5 - 0
Source/Tools/Urho3DPlayer/CMakeLists.txt

@@ -28,3 +28,8 @@ define_source_files ()
 
 
 # Setup target with resource copying
 # Setup target with resource copying
 setup_main_executable ()
 setup_main_executable ()
+
+# Setup test cases
+add_test (NAME Editor COMMAND ${TARGET_NAME} Data/Scripts/Editor.as -w -timeout ${TEST_TIME_OUT})
+add_test (NAME AngelSprites COMMAND ${TARGET_NAME} Data/Scripts/03_Sprites.as -w -timeout ${TEST_TIME_OUT})
+add_test (NAME LuaSprites COMMAND ${TARGET_NAME} Data/LuaScripts/03_Sprites.lua -w -timeout ${TEST_TIME_OUT})