Browse Source

Make early progress on AutoUpdate, separate tests

master
Macoy Madson 2 years ago
parent
commit
af0e1e377a
  1. 44
      src/AutoUpdate.cake
  2. 2
      src/Curl.cake
  3. 19
      test/src/GameLibTests.cake

44
src/AutoUpdate.cake

@ -22,3 +22,47 @@
;; a subprocess, etc.
;; - On subsequent executions, check the user data directory for any update files, and run those
;; as a subprocess instead. (In the case where the update is an entire executable).
(import
;; Cakelisp
"FileUtilities.cake"
;; GameLib
"Introspection.cake" "DynamicArray.cake" "Curl.cake")
(defun auto-update-get-latest-version-metadata (update-cakedata-url (* (const char)) &return bool)
(when (!= (curl_global_init CURL_GLOBAL_DEFAULT) 0)
(fprintf stderr "error: Failed to initialize curl\n")
(return false))
(var curl (* CURL) (curl_easy_init))
(unless curl
(fprintf stderr "error: Failed to get curl\n")
(curl_global_cleanup)
(return false))
(scope
(curl_easy_setopt curl CURLOPT_URL update-cakedata-url)
(curl_easy_setopt curl CURLOPT_SSL_VERIFYPEER 0) ;; TODO TODO TODO REMOVE!
(curl_easy_setopt curl CURLOPT_SSL_VERIFYHOST 0) ;; TODO TODO TODO REMOVE!
(var result CURLcode (curl_easy_perform curl))
(unless (= CURLE_OK result)
(fprintf stderr "error: failed to get url %s with result %s\n"
update-cakedata-url (curl-code-to-string result))
(curl_easy_cleanup curl)
(curl_global_cleanup)
(return false))
(curl_easy_cleanup curl))
(fflush stdout)
(curl_global_cleanup)
(return true))
(comptime-cond
('auto-test
(c-import "<stdio.h>")
(defun test--auto-update (&return int)
(unless (auto-update-get-latest-version-metadata
"https://localhost:8888/updates/Machsearch/machsearch.cakedata")
(fprintf stderr "error: expected server to be running before doing this test\n")
(return 1))
(return 0))))

2
src/Curl.cake

@ -41,6 +41,8 @@
(curl_easy_cleanup curl))
(curl_global_cleanup)
(fflush stderr)
(fflush stdout)
(return 0))))
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")

19
test/src/GameLibTests.cake

@ -38,11 +38,8 @@
(true
"src/Config_Linux.cake")))
(comptime-cond
('Windows
(var test-curl-only bool true))
(true
(var test-curl-only bool false)))
;; (var test-network bool true)
(var test-network bool false)
(var test-minimal bool true)
;; (var test-minimal bool false)
@ -54,13 +51,15 @@
;; (var test-ogre bool true)
(cond
(test-curl-only
(test-network
(gamelib-run-test
"Auto Test (CURL only)"
"Auto Test (network)\n(Note: this will require running a server on localhost)"
(array platform-config
"../src/AutoTest.cake"
;; Note: Must come before Curl because curl requires openssl
"../src/OpenSSL.cake" "../src/Curl.cake")))
"../src/OpenSSL.cake" "../src/Curl.cake"
"../src/AutoUpdate.cake")))
(test-minimal
(gamelib-run-test
@ -70,9 +69,7 @@
"../src/Dictionary.cake" "../src/DynamicArray.cake"
"../src/TaskSystem.cake" "../src/Image.cake" "../src/DataBundle.cake"
"../src/TinyCCompiler.cake" "../src/FreeType.cake" "../src/Allocator.cake"
"../src/Oniguruma.cake" "../src/Cryptography.cake"
;; Note: Must come before Curl because curl requires openssl
"../src/OpenSSL.cake" "../src/Curl.cake")))
"../src/Oniguruma.cake" "../src/Cryptography.cake")))
(test-opengl-only
(gamelib-run-test

Loading…
Cancel
Save