🧪 Add simple test framework

Now that the project is finding a little adoption it is really high time
to bring some tests into the code to ensure everything works as it
should.
This first version will only provide a simple test harness from which
tests can slowly be written for other parts of the program.
This commit is contained in:
Marty Oehme 2022-06-29 09:25:28 +02:00
parent edd5ebd743
commit ceea79eb3a
Signed by: Marty
GPG Key ID: B7538B8F50A1C800
5 changed files with 29 additions and 0 deletions

9
.gitmodules vendored Normal file
View File

@ -0,0 +1,9 @@
[submodule "test/bats"]
path = test/bats
url = https://github.com/bats-core/bats-core.git
[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

1
test/bats Submodule

@ -0,0 +1 @@
Subproject commit 26c9b18983c3ce4cf24c6f6ee942abd8b1c3ee18

17
test/bemoji.bats Normal file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
setup() {
load 'test_helper/bats-support/load'
load 'test_helper/bats-assert/load'
# make bemoji executable from anywhere relative to current testfile
TEST_DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
PATH="$TEST_DIR/..:$PATH"
}
@test "test can run script" {
# closing FD3 manually to prevent hangs, see
# https://bats-core.readthedocs.io/en/stable/writing-tests.html#file-descriptor-3-read-this-if-bats-hangs
run bemoji 3>&-
assert_success
}

@ -0,0 +1 @@
Subproject commit ffe84ea5dd43b568851549b3e241db150c12929c

@ -0,0 +1 @@
Subproject commit 3c8fadc5097c9acfc96d836dced2bb598e48b009