aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/integration
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-02-04 12:08:22 +0100
committerEgor Tensin <Egor.Tensin@gmail.com>2023-02-04 12:18:42 +0100
commit8f6582160a6dce81d6c6bc080d05aaa0b85d9537 (patch)
tree5e8f28f7e8751401d9ce267d2f6edb414f5d3fe2 /test/integration
parentMakefile: add a comment (diff)
downloadconfig-links-8f6582160a6dce81d6c6bc080d05aaa0b85d9537.tar.gz
config-links-8f6582160a6dce81d6c6bc080d05aaa0b85d9537.zip
add an "integration" test
I noticed that doing links-update for my linux-home repository didn't work on an old bash version. Building a test case to reproduce... You should be able to check out this commit later and run make test/docker/xenial and it's supposed to fail with something like /src/src/db.sh: line 194: wait: pid 1771 is not a child of this shell
Diffstat (limited to 'test/integration')
-rwxr-xr-xtest/integration/test.sh89
1 files changed, 89 insertions, 0 deletions
diff --git a/test/integration/test.sh b/test/integration/test.sh
new file mode 100755
index 0000000..3bb481f
--- /dev/null
+++ b/test/integration/test.sh
@@ -0,0 +1,89 @@
+#!/usr/bin/env bash
+
+set -o errexit -o nounset -o pipefail
+shopt -s inherit_errexit 2> /dev/null || true
+shopt -s lastpipe
+
+script_dir="$( dirname -- "${BASH_SOURCE[0]}" )"
+script_dir="$( cd -- "$script_dir" && pwd )"
+readonly script_dir
+script_name="$( basename -- "${BASH_SOURCE[0]}" )"
+readonly script_name
+
+root_dir="$( git -C "$script_dir" rev-parse --show-toplevel )"
+readonly root_dir
+
+src_name='linux-home'
+readonly src_name
+src_url="https://github.com/egor-tensin/$src_name.git"
+readonly src_url
+
+test_root_dir=
+test_src_dir=
+
+new_test() {
+ local test_name=
+ [ "${#FUNCNAME[@]}" -gt 1 ] && test_name="${FUNCNAME[1]}"
+ [ "$#" -gt 0 ] && test_name="$1"
+
+ echo
+ echo ======================================================================
+ echo "New test: $test_name"
+
+ test_root_dir="$( mktemp -d )"
+ # mktemp returns /var/..., which is actually in /private/var/... on macOS.
+ test_root_dir="$( readlink -e -- "$test_root_dir" )"
+ test_src_dir="$test_root_dir/$src_name"
+
+ echo "Root directory: $test_root_dir"
+ echo "Shared directory: $test_src_dir"
+ echo ======================================================================
+
+ git clone -q -- "$src_url" "$test_src_dir"
+ cd -- "$test_src_dir"
+}
+
+call_bin_script() {
+ echo
+ echo -n 'Executing script:'
+
+ printf -- ' %q' "$@" --shared-dir "$test_src_dir" --database "$test_root_dir/links.bin"
+ printf -- '\n'
+
+ echo
+ "$@" --shared-dir "$test_src_dir" --database "$test_root_dir/links.bin"
+}
+
+call_update() {
+ call_bin_script "$root_dir/links-update" "$@"
+}
+
+call_remove() {
+ call_bin_script "$root_dir/links-remove"
+}
+
+call_chmod() {
+ call_bin_script "$root_dir/links-chmod" "$@"
+}
+
+test_my_dotfiles_work() {
+ new_test
+ call_update
+}
+
+show_env() {
+ echo
+ echo ======================================================================
+ echo Environment
+ echo ======================================================================
+
+ bash --version
+}
+
+main() {
+ show_env
+
+ test_my_dotfiles_work
+}
+
+main