diff options
author | EuAndreh <eu@euandre.org> | 2021-08-05 18:07:21 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-08-05 18:07:21 -0300 |
commit | 8cb0207e09c301a02e21f5e8a395c7c958781f1b (patch) | |
tree | bb4ad55274e71bb2dc2bd4ed61958abf524df4ea /tests/integration.sh | |
parent | Move tests/resources{ => /repositories}/repo* (diff) | |
download | gistatic-8cb0207e09c301a02e21f5e8a395c7c958781f1b.tar.gz gistatic-8cb0207e09c301a02e21f5e8a395c7c958781f1b.tar.xz |
tests/: Add integration tests, also test with Valgrind
Diffstat (limited to 'tests/integration.sh')
-rwxr-xr-x | tests/integration.sh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/integration.sh b/tests/integration.sh new file mode 100755 index 0000000..27a2dfc --- /dev/null +++ b/tests/integration.sh @@ -0,0 +1,58 @@ +#!/bin/sh +set -u + +. tests/lib.sh + +assert_file() { + if ! diff "$2" "$1"; then + printf '\n%s: File content differs.\n' \ + "$(ERROR)" >&2 + printf '\nexpected: %s\ngot: %s\n\n' "$1" "$2" >&2 + print_debug_info + exit 1 + fi +} + +test_index_generation() { + testing 'index generation' + + N="$LINENO" + OUT="$(mkstemp)" + ERR="$(mkstemp)" + DIR="$(mkdtemp)" + ./src/gistatic -i -o "$DIR" tests/resources/repositories/* \ + 1>"$OUT" 2>"$ERR" + STATUS=$? + assert_empty_stdout + assert_empty_stderr + assert_status 0 + assert_file tests/resources/assets/style.css "$DIR/style.css" + assert_file tests/resources/assets/logo.svg "$DIR/logo.svg" + assert_file tests/resources/assets/index.html "$DIR/index.html" + + test_ok +} + +test_repo_generation() { + testing 'repo generation' + + N="$LINENO" + OUT="$(mkstemp)" + ERR="$(mkstemp)" + DIR="$(mkdtemp)" + ./src/gistatic -o "$DIR" -u https://example.com/ \ + tests/resources/repositories/repo-1 1>"$OUT" 2>"$ERR" + STATUS=$? + assert_empty_stdout + assert_empty_stderr + assert_status 0 + + assert_file tests/resources/assets/style.css "$DIR/style.css" + assert_file tests/resources/assets/logo.svg "$DIR/logo.svg" + assert_file tests/resources/assets/refs.html "$DIR/refs.html" + + test_ok +} + +test_index_generation +test_repo_generation |