Browse Source

Convert PlatformTest over to AutoTest

filter-focus
Macoy Madson 1 year ago
parent
commit
b49f077d9b
  1. 4
      .gitignore
  2. 8
      Build_CrossCompileWindows.sh
  3. 83
      src/PlatformTest.cake

4
.gitignore

@ -74,4 +74,6 @@ UserData.cakedata
UserData_TestWrite.cakedata
# TODO Make this less general
*.txt
*.txt
autoTest

8
Build_CrossCompileWindows.sh

@ -13,8 +13,14 @@ echo "\n\nFile Helper\n\n"
CAKELISP=./Dependencies/cakelisp/bin/cakelisp
# For comparison
# $CAKELISP --execute --verbose-processes \
# src/Config_Linux.cake \
# Dependencies/gamelib/src/AutoTest.cake src/PlatformTest.cake src/FileSystem.cake || exit $?
# We can't run the full app yet until I set up SDL to build under Mingw
$CAKELISP --verbose-processes \
src/Config_Mingw.cake \
src/PlatformTest.cake src/FileSystem.cake || exit $?
Dependencies/gamelib/src/AutoTest.cake src/PlatformTest.cake src/FileSystem.cake || exit $?
wine FileHelper.exe

83
src/PlatformTest.cake

@ -1,40 +1,51 @@
(import "FileSystem.cake")
(c-import "<stdio.h>")
(defun main (&return int)
(fprintf stderr "File Helper platform-specific testing\n")
(scope ;; Test read-directory
(fprintf stderr "\nread-directory:\n")
(var directories (* directory-entry) null)
(var error-string-buffer ([] 1024 char) (array 0))
(unless (read-directory "." (addr directories) error-string-buffer (sizeof error-string-buffer))
(fprintf stderr "error: read-directory failed: %s" error-string-buffer)
(dynarray-free directories)
(return 1))
(unless (dynarray-length directories)
(fprintf stderr "error: No directories were read")
(dynarray-free directories)
(return 1))
(dynarray-free directories))
(scope ;; Test read-directory-details
(fprintf stderr "\n\nread-directory-details:\n")
(var directories (* directory-entry) null)
(var directory-details (* entry-details) null)
(var error-string-buffer ([] 1024 char) (array 0))
(unless (read-directory-details "." (addr directories) (addr directory-details)
error-string-buffer (sizeof error-string-buffer))
(fprintf stderr "error: read-directory-details failed: %s" error-string-buffer)
(dynarray-free directories)
(dynarray-free directory-details)
(return 1))
(unless (dynarray-length directories)
(fprintf stderr "error: No directories were read")
(dynarray-free directory-details)
(dynarray-free directories)
(return 1))
(dynarray-free directory-details)
(dynarray-free directories))
(fprintf stderr "\nPlatform appears to be supported.\n")
(defun test--read-directory (&return int)
(var directories (* directory-entry) null)
(var error-string-buffer ([] 1024 char) (array 0))
(unless (read-directory "." (addr directories) error-string-buffer (sizeof error-string-buffer))
(fprintf stderr "error: read-directory failed: %s" error-string-buffer)
(dynarray-free directories)
(return 1))
(unless (dynarray-length directories)
(fprintf stderr "error: No directories were read")
(dynarray-free directories)
(return 1))
(each-item-addr-in-dynarray directories
i current-entry (* directory-entry)
(fprintf stderr "%s\n" (path current-entry > name)))
(dynarray-free directories)
(return 0))
(defun test--read-directory-details (&return int)
(var directories (* directory-entry) null)
(var directory-details (* entry-details) null)
(var error-string-buffer ([] 1024 char) (array 0))
(unless (read-directory-details "." (addr directories) (addr directory-details)
error-string-buffer (sizeof error-string-buffer))
(fprintf stderr "error: read-directory-details failed: %s" error-string-buffer)
(dynarray-free directories)
(dynarray-free directory-details)
(return 1))
(unless (dynarray-length directories)
(fprintf stderr "error: No directories were read")
(dynarray-free directory-details)
(dynarray-free directories)
(return 1))
(each-item-addr-in-dynarray directories
i current-entry (* directory-entry)
(fprintf stderr "%s\n" (path current-entry > name)))
(fprintf stderr "\nFull paths:\n")
(each-item-addr-in-dynarray directory-details
i current-entry (* entry-details)
(fprintf stderr "%s\n" (path current-entry > path)))
(dynarray-free directory-details)
(dynarray-free directories)
(return 0))

Loading…
Cancel
Save