Просмотр исходного кода

Merge pull request #1564 from MerryMage/this-is-only-a-test

tests: Infrastructure for unit tests
bunnei 10 лет назад
Родитель
Сommit
5edff287b6
8 измененных файлов с 48 добавлено и 2 удалено
  1. 3 0
      .gitmodules
  2. 8 1
      .travis-build.sh
  3. 2 0
      CMakeLists.txt
  4. 8 1
      appveyor.yml
  5. 1 0
      externals/catch
  6. 1 0
      src/CMakeLists.txt
  7. 16 0
      src/tests/CMakeLists.txt
  8. 9 0
      src/tests/tests.cpp

+ 3 - 0
.gitmodules

@@ -10,3 +10,6 @@
 [submodule "soundtouch"]
 [submodule "soundtouch"]
 	path = externals/soundtouch
 	path = externals/soundtouch
 	url = https://github.com/citra-emu/ext-soundtouch.git
 	url = https://github.com/citra-emu/ext-soundtouch.git
+[submodule "catch"]
+	path = externals/catch
+	url = https://github.com/philsquared/Catch.git

+ 8 - 1
.travis-build.sh

@@ -18,9 +18,16 @@ if [ "$TRAVIS_OS_NAME" = "linux" -o -z "$TRAVIS_OS_NAME" ]; then
     mkdir build && cd build
     mkdir build && cd build
     cmake -DCITRA_FORCE_QT4=ON ..
     cmake -DCITRA_FORCE_QT4=ON ..
     make -j4
     make -j4
+
+    ctest -VV -C Release
 elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
 elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
+    set -o pipefail
+
     export Qt5_DIR=$(brew --prefix)/opt/qt5
     export Qt5_DIR=$(brew --prefix)/opt/qt5
+
     mkdir build && cd build
     mkdir build && cd build
     cmake .. -GXcode
     cmake .. -GXcode
-    xcodebuild -configuration Release | xcpretty -c && exit ${PIPESTATUS[0]}
+    xcodebuild -configuration Release | xcpretty -c
+
+    ctest -VV -C Release
 fi
 fi

+ 2 - 0
CMakeLists.txt

@@ -255,6 +255,8 @@ endif()
 
 
 add_subdirectory(externals/soundtouch)
 add_subdirectory(externals/soundtouch)
 
 
+enable_testing()
+
 add_subdirectory(src)
 add_subdirectory(src)
 
 
 # Install freedesktop.org metadata files, following those specifications:
 # Install freedesktop.org metadata files, following those specifications:

+ 8 - 1
appveyor.yml

@@ -22,7 +22,14 @@ before_build:
   - cmake -G "Visual Studio 14 2015 Win64" -DCITRA_USE_BUNDLED_QT=1 -DCITRA_USE_BUNDLED_SDL2=1 ..
   - cmake -G "Visual Studio 14 2015 Win64" -DCITRA_USE_BUNDLED_QT=1 -DCITRA_USE_BUNDLED_SDL2=1 ..
   - cd ..
   - cd ..
 
 
-after_build:
+build:
+  project: build/citra.sln
+  parallel: true
+
+test_script:
+  - cd build && ctest -VV -C Release
+
+on_success:
     # copying the needed QT Dlls is now done post build. See the CMakeLists.txt file in the citra-qt folder
     # copying the needed QT Dlls is now done post build. See the CMakeLists.txt file in the citra-qt folder
   - ps: >
   - ps: >
         if (!"$env:APPVEYOR_PULL_REQUEST_TITLE" -and ("$env:APPVEYOR_REPO_BRANCH" -eq "master"))
         if (!"$env:APPVEYOR_PULL_REQUEST_TITLE" -and ("$env:APPVEYOR_REPO_BRANCH" -eq "master"))

+ 1 - 0
externals/catch

@@ -0,0 +1 @@
+Subproject commit c984fc3ecde60b59efa2203e82261acac8ac8502

+ 1 - 0
src/CMakeLists.txt

@@ -5,6 +5,7 @@ add_subdirectory(common)
 add_subdirectory(core)
 add_subdirectory(core)
 add_subdirectory(video_core)
 add_subdirectory(video_core)
 add_subdirectory(audio_core)
 add_subdirectory(audio_core)
+add_subdirectory(tests)
 if (ENABLE_SDL2)
 if (ENABLE_SDL2)
     add_subdirectory(citra)
     add_subdirectory(citra)
 endif()
 endif()

+ 16 - 0
src/tests/CMakeLists.txt

@@ -0,0 +1,16 @@
+set(SRCS
+            tests.cpp
+            )
+
+set(HEADERS
+            )
+
+create_directory_groups(${SRCS} ${HEADERS})
+
+include_directories(../../externals/catch/single_include/)
+
+add_executable(tests ${SRCS} ${HEADERS})
+target_link_libraries(tests core video_core audio_core common)
+target_link_libraries(tests ${PLATFORM_LIBRARIES})
+
+add_test(NAME tests COMMAND $<TARGET_FILE:tests>)

+ 9 - 0
src/tests/tests.cpp

@@ -0,0 +1,9 @@
+// Copyright 2016 Citra Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#define CATCH_CONFIG_MAIN
+#include <catch.hpp>
+
+// Catch provides the main function since we've given it the
+// CATCH_CONFIG_MAIN preprocessor directive.