Browse Source

Added GameLibTests, fix old tests

* GameLibTests.cake serves as a platform-independent way to test all
the various modules. They all are built in the same instance of
cakelisp, which makes it easier to instrument
* Fix old model references in SDLOgreApp and OgreApp
* OgreApp now closes on its own while I'm waiting on implementing
input support
* SDLOgreApp and OgreApp now have lighting
windows-imgui
Macoy Madson 6 months ago
parent
commit
f3d7baa500
  1. 22
      test/Build.sh
  2. 58
      test/src/GameLibTests.cake
  3. 9
      test/src/OgreApp.cake
  4. 3
      test/src/SDLOgreApp.cake

22
test/Build.sh

@ -14,24 +14,4 @@ cd ../..
CAKELISP=./Dependencies/cakelisp/bin/cakelisp
echo "\n\nOgre\n\n"
$CAKELISP src/Config_Linux.cake src/OgreApp.cake || exit $?
echo "\n\nSDL Ogre\n\n"
$CAKELISP src/Config_Linux.cake src/SDLOgreApp.cake || exit $?
# echo "\n\nAuto Test (Math only)\n\n"
# $CAKELISP --execute src/Config_Linux.cake src/AutoTest.cake src/Math.cake || exit $?
echo "\n\nAuto Test\n\n"
$CAKELISP --execute src/Config_Linux.cake ../src/AutoTest.cake ../src/SDL.cake ../src/Math.cake ../src/Aubio.cake ../src/ImGui.cake || exit $?
# $CAKELISP src/Config_Linux.cake ../src/AutoTest.cake ../src/SDL.cake ../src/Tracy.cake ../src/Math.cake ../src/Aubio.cake || exit $?
echo "\n\nVocal Game (hot reload)\n\n"
$CAKELISP src/Config_Linux.cake src/MakeHotReload.cake src/VocalGame.cake || exit $?
echo "\n\nLoader\n\n"
$CAKELISP --execute src/Config_Linux.cake src/Loader.cake || exit $?
echo "\n\nVocal Game (no reload)\n\n"
$CAKELISP \
src/Config_Linux.cake src/NoHotReload.cake src/VocalGame.cake || exit $?
$CAKELISP src/Config_Linux.cake src/GameLibTests.cake || exit $?

58
test/src/GameLibTests.cake

@ -0,0 +1,58 @@
;; (skip-build)
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(import &comptime-only "BuildTools.cake" "ComptimeHelpers.cake" "CHelpers.cake" "Cakelisp.cake")
;; We don't actually test anything here; we use comptime to run the tests
(defun main (&return int)
(return 0))
(defmacro gamelib-run-test (test-name string files array)
(tokenize-push output
(scope
(var files ([] (* (const char))) (token-splice files))
(Logf "\n===============\n%s\n\n" (token-splice test-name))
(unless (cakelisp-evaluate-build-execute-files files (array-size files))
(Logf "error: test %s failed\n" (token-splice test-name))
(return false))
(Logf "\n%s succeeded\n" (token-splice test-name))))
(return true))
(defmacro gamelib-build (test-name string files array)
(tokenize-push output
(scope
(var files ([] (* (const char))) (token-splice files))
(Logf "\n===============\nBuild %s\n\n" (token-splice test-name))
(unless (cakelisp-evaluate-build-files files (array-size files))
(return false))))
(return true))
(defun-comptime run-tests (manager (& ModuleManager) module (* Module) &return bool)
(var platform-config (* (const char))
(comptime-cond
('Windows
"src/Config_Windows.cake")
(true
"src/Config_Linux.cake")))
(gamelib-run-test "Ogre" (array platform-config "src/OgreApp.cake"))
(gamelib-run-test "SDL Ogre" (array platform-config "src/SDLOgreApp.cake"))
(gamelib-run-test "Auto Test"
(array platform-config
"../src/AutoTest.cake" "../src/SDL.cake" "../src/Math.cake"
"../src/Aubio.cake" "../src/ImGui.cake" "../src/Dictionary.cake"))
(gamelib-build "Vocal Game (hot reload)"
(array platform-config "src/MakeHotReload.cake" "src/VocalGame.cake"))
(gamelib-run-test "Hot-loader"
(array platform-config "src/Loader.cake"))
(gamelib-run-test "Vocal Game (no reload)"
(array platform-config "src/NoHotReload.cake" "src/VocalGame.cake"))
(Log "\nGameLibTests: All tests succeeded!\n")
(return true))
(add-compile-time-hook-module pre-build run-tests)

9
test/src/OgreApp.cake

@ -11,8 +11,9 @@
;; Ogre uses exceptions for error handling, so we can't gracefully close without getting all that
;; stuff set up (which I don't really want to do; it belongs in Gamelib)
(ogre-initialize)
(var monkey-mesh mesh-handle (ogre-load-mesh "Suzanne.mesh"))
(var monkey-mesh mesh-handle (ogre-load-mesh "Monkey_Mesh.mesh"))
(var monkey-node scene-node (ogre-node-from-item monkey-mesh))
(ogre-create-light)
(var exit-reason (* (const char)) null)
@ -28,14 +29,16 @@
(ogre-node-set-position (addr monkey-node) x y z)
(set x (+ x 0.01f))
(when (> x 0.3f)
(set exit-reason "Done animation")
(break))
(unless (ogre-render-frame)
(set exit-reason "Failed to render frame")
(break)))
(ogre-shutdown)
(when exit-reason
(printf "Exit reason: %s\n" exit-reason))
(ogre-shutdown)
(return 0))
;; We need to place the executable relative to our data folders and such

3
test/src/SDLOgreApp.cake

@ -20,8 +20,9 @@
(unless (ogre-initialize-sdl)
(return 1))
(var monkey-mesh mesh-handle (ogre-load-mesh "Suzanne.mesh"))
(var monkey-mesh mesh-handle (ogre-load-mesh "Monkey_Mesh.mesh"))
(var monkey-node scene-node (ogre-node-from-item monkey-mesh))
(ogre-create-light)
(var exit-reason (* (const char)) null)

Loading…
Cancel
Save