From b3da887cc8272d2df1bb9cda5f333738e1e1596e Mon Sep 17 00:00:00 2001 From: Riyyi Date: Mon, 3 Aug 2026 21:51:48 +0200 Subject: [PATCH] Example test and git hooks --- README.md | 8 +++++++- scripts/pre-commit | 6 ++++++ test.sh | 9 +++++++++ tests/blabla.odin | 3 ++- 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100755 scripts/pre-commit create mode 100755 test.sh diff --git a/README.md b/README.md index 3107f8e..c17a11b 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,10 @@ Asset packer. ./build.sh debug ``` - +## Contributing + +Make sure to enable git hooks: + +```sh +git config core.hooksPath scripts +``` diff --git a/scripts/pre-commit b/scripts/pre-commit new file mode 100755 index 0000000..3dd43ff --- /dev/null +++ b/scripts/pre-commit @@ -0,0 +1,6 @@ +#!/bin/sh + +SCRIPT_DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd) + +"$SCRIPT_DIR/../fmt.sh" +"$SCRIPT_DIR/../test.sh" diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..e4c2dd7 --- /dev/null +++ b/test.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +mkdir -p build + +odin test tests/ -collection:src=src -out:build/tests.bin \ + -define:ODIN_TEST_THREADS=1 \ + -define:ODIN_TEST_TRACK_MEMORY=false \ + -define:ODIN_TEST_RANDOM_SEED=1 \ + "$@" diff --git a/tests/blabla.odin b/tests/blabla.odin index 7ec2495..a75f317 100644 --- a/tests/blabla.odin +++ b/tests/blabla.odin @@ -3,5 +3,6 @@ package tests import "core:testing" @(test) -foo :: proc(_: ^testing.T) { +foo :: proc(t: ^testing.T) { + testing.expect(t, 1 + 1 == 2, "pass") }