aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorgitlost <burmartke@gmail.com>2022-03-24 19:31:46 +0000
committergitlost <burmartke@gmail.com>2022-03-24 19:31:46 +0000
commit86614575126265a17e4a232522b7c08541375b76 (patch)
tree4a4ae36e4d7ef2583258e41fc5776f054db5704a /tests
parenta2ad16b609ddb86c410569a6786618173f58257e (diff)
Use `WIFEXITED()` and `WEXITSTATUS()` on Unix `system()` exit code
(ensures Odin run returns correct exit code of built executable) Adds test "tests/core/os/test_core_os_exit.odin" (Unix only)
Diffstat (limited to 'tests')
-rw-r--r--tests/core/Makefile5
-rw-r--r--tests/core/os/test_core_os_exit.odin10
2 files changed, 14 insertions, 1 deletions
diff --git a/tests/core/Makefile b/tests/core/Makefile
index 4160690f9..652ebb151 100644
--- a/tests/core/Makefile
+++ b/tests/core/Makefile
@@ -2,7 +2,7 @@ ODIN=../../odin
PYTHON=$(shell which python3)
all: download_test_assets image_test compress_test strings_test hash_test crypto_test noise_test encoding_test \
- math_test linalg_glsl_math_test filepath_test reflect_test
+ math_test linalg_glsl_math_test filepath_test reflect_test os_exit_test
download_test_assets:
$(PYTHON) download_assets.py
@@ -41,3 +41,6 @@ filepath_test:
reflect_test:
$(ODIN) run reflect/test_core_reflect.odin -out=test_core_reflect -collection:tests=..
+
+os_exit_test:
+ $(ODIN) run os/test_core_os_exit.odin -out=test_core_os_exit && exit 1 || exit 0
diff --git a/tests/core/os/test_core_os_exit.odin b/tests/core/os/test_core_os_exit.odin
new file mode 100644
index 000000000..2ab274f5e
--- /dev/null
+++ b/tests/core/os/test_core_os_exit.odin
@@ -0,0 +1,10 @@
+// Tests that Odin run returns exit code of built executable on Unix
+// Needs exit status to be inverted to return 0 on success, e.g.
+// $(./odin run tests/core/os/test_core_os_exit.odin && exit 1 || exit 0)
+package test_core_os_exit
+
+import "core:os"
+
+main :: proc() {
+ os.exit(1)
+}