From e48e27fb523189d1652d53a8a78c7a5e976ea6b9 Mon Sep 17 00:00:00 2001 From: Sven van Heugten Date: Mon, 2 Mar 2026 20:06:53 +0100 Subject: [PATCH] Add helper modules for bats According to these instructions: https://bats-core.readthedocs.io/en/stable/tutorial.html#quick-installation --- .gitmodules | 9 +++++++++ README.md | 6 ++++++ default.nix | 4 ++-- test/git-check-assertions.bats | 6 +++++- test/test_helper/bats-assert | 1 + test/test_helper/bats-file | 1 + test/test_helper/bats-support | 1 + 7 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 .gitmodules create mode 160000 test/test_helper/bats-assert create mode 160000 test/test_helper/bats-file create mode 160000 test/test_helper/bats-support diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..9ec278b --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "test/test_helper/bats-support"] + path = test/test_helper/bats-support + url = https://github.com/bats-core/bats-support.git +[submodule "test/test_helper/bats-assert"] + path = test/test_helper/bats-assert + url = https://github.com/bats-core/bats-assert.git +[submodule "test/test_helper/bats-file"] + path = test/test_helper/bats-file + url = https://github.com/bats-core/bats-file.git diff --git a/README.md b/README.md index 0b302ca..01c4cb6 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,12 @@ You include a small bash script inside your commit messages, and `git-check-asse ⚠️ Only run this on repositories and branches that you trust, since the `bash` scripts in the commit messages can do whatever they want. +## Building + +```bash +nix build .?submodules=1 +``` + ## Examples of commit messages Assert that a commit builds: diff --git a/default.nix b/default.nix index ecb1f69..47212a6 100644 --- a/default.nix +++ b/default.nix @@ -20,8 +20,8 @@ resholve.mkDerivation { src = fs.toSource { root = ./.; fileset = fs.unions [ - ./bin/git-check-assertions - ./test/git-check-assertions.bats + ./bin + ./test ]; }; diff --git a/test/git-check-assertions.bats b/test/git-check-assertions.bats index 8371aea..8de6cf7 100755 --- a/test/git-check-assertions.bats +++ b/test/git-check-assertions.bats @@ -1,10 +1,14 @@ #!/usr/bin/env bats setup() { + load 'test_helper/bats-support/load' + load 'test_helper/bats-assert/load' + DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" PATH="$DIR/../bin:$PATH" } @test "can run" { - git-check-assertions + run git-check-assertions + assert_success } diff --git a/test/test_helper/bats-assert b/test/test_helper/bats-assert new file mode 160000 index 0000000..697471b --- /dev/null +++ b/test/test_helper/bats-assert @@ -0,0 +1 @@ +Subproject commit 697471b7a89d3ab38571f38c6c7c4b460d1f5e35 diff --git a/test/test_helper/bats-file b/test/test_helper/bats-file new file mode 160000 index 0000000..6bee58b --- /dev/null +++ b/test/test_helper/bats-file @@ -0,0 +1 @@ +Subproject commit 6bee58bec7c2f4aed1a7425ccd4bdc42b4a84599 diff --git a/test/test_helper/bats-support b/test/test_helper/bats-support new file mode 160000 index 0000000..0954abb --- /dev/null +++ b/test/test_helper/bats-support @@ -0,0 +1 @@ +Subproject commit 0954abb9925cad550424cebca2b99255d4eabe96