aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-09-27 16:08:02 +0500
committerEgor Tensin <egor@tensin.name>2026-09-27 16:08:02 +0500
commitb80c608504d4a9cc95b951ddfeebac764933098a (patch)
treeae17593102d7cec5c673131b4ae6667d52e3b009
parentdebian/README: fix a typo (diff)
parenttest: add tst-root.sh (diff)
downloadconfig-links-b80c608504d4a9cc95b951ddfeebac764933098a.tar.gz
config-links-b80c608504d4a9cc95b951ddfeebac764933098a.zip
Merge tag 'v2.1.5' into debian
v2.1.5
-rw-r--r--Makefile15
-rw-r--r--test/data/dest/1.txt (renamed from test/local/data/dest/1.txt)0
-rw-r--r--test/data/dest/bar/3.txt (renamed from test/local/data/dest/bar/3.txt)0
-rw-r--r--test/data/src/%DEST%/1.txt (renamed from test/local/data/src/%DEST%/1.txt)0
-rw-r--r--test/data/src/%DEST%/bar/3.txt (renamed from test/local/data/src/%DEST%/bar/3.txt)0
-rw-r--r--test/data/src/%DEST%/bar/baz/4.txt (renamed from test/local/data/src/%DEST%/bar/baz/4.txt)0
-rw-r--r--test/data/src/%DEST%/foo/2.txt (renamed from test/local/data/src/%DEST%/foo/2.txt)0
-rw-r--r--test/docker/Dockerfile2
-rw-r--r--test/lib/log.sh (renamed from test/local/lib/log.sh)0
-rw-r--r--test/lib/test.sh (renamed from test/local/lib/test.sh)6
-rwxr-xr-xtest/linux-home/test.sh95
-rwxr-xr-xtest/main.sh (renamed from test/local/main.sh)13
-rw-r--r--test/tst-chmod.sh (renamed from test/local/tst-chmod.sh)0
-rw-r--r--test/tst-dir-symlink-delete.sh (renamed from test/local/tst-dir-symlink-delete.sh)0
-rw-r--r--test/tst-dir-symlink-remove-shared-file.sh (renamed from test/local/tst-dir-symlink-remove-shared-file.sh)0
-rw-r--r--test/tst-linux-home.sh42
-rw-r--r--test/tst-remove-dir-symlink.sh (renamed from test/local/tst-remove-dir-symlink.sh)0
-rw-r--r--test/tst-remove-does-not-delete-user-dirs.sh (renamed from test/local/tst-remove-does-not-delete-user-dirs.sh)0
-rw-r--r--test/tst-remove-does-not-overwrite-files.sh (renamed from test/local/tst-remove-does-not-overwrite-files.sh)0
-rw-r--r--test/tst-remove-symlink.sh (renamed from test/local/tst-remove-symlink.sh)0
-rw-r--r--test/tst-remove.sh (renamed from test/local/tst-remove.sh)0
-rw-r--r--test/tst-root.sh42
-rw-r--r--test/tst-update-chmod.sh (renamed from test/local/tst-update-chmod.sh)0
-rw-r--r--test/tst-update-dir-symlink.sh (renamed from test/local/tst-update-dir-symlink.sh)0
-rw-r--r--test/tst-update-symlink.sh (renamed from test/local/tst-update-symlink.sh)0
-rw-r--r--test/tst-update.sh (renamed from test/local/tst-update.sh)0
26 files changed, 102 insertions, 113 deletions
diff --git a/Makefile b/Makefile
index b9c6cb2..fe20548 100644
--- a/Makefile
+++ b/Makefile
@@ -7,19 +7,8 @@ DO:
all: test
.PHONY: test
-test: test/local
-
-.PHONY: test/all
-test/all: test/local test/docker
-
-.PHONY: test/local
-test/local:
- ./test/local/main.sh
-
-# This is deliberately excluded from test/all, because it's quite destructive.
-.PHONY: test/linux-home
-test/linux-home:
- ./test/linux-home/test.sh
+test:
+ ./test/main.sh
test/docker/%: DO
cd test/docker && \
diff --git a/test/local/data/dest/1.txt b/test/data/dest/1.txt
index 3a2e3f4..3a2e3f4 100644
--- a/test/local/data/dest/1.txt
+++ b/test/data/dest/1.txt
diff --git a/test/local/data/dest/bar/3.txt b/test/data/dest/bar/3.txt
index a83d1d5..a83d1d5 100644
--- a/test/local/data/dest/bar/3.txt
+++ b/test/data/dest/bar/3.txt
diff --git a/test/local/data/src/%DEST%/1.txt b/test/data/src/%DEST%/1.txt
index d00491f..d00491f 100644
--- a/test/local/data/src/%DEST%/1.txt
+++ b/test/data/src/%DEST%/1.txt
diff --git a/test/local/data/src/%DEST%/bar/3.txt b/test/data/src/%DEST%/bar/3.txt
index 00750ed..00750ed 100644
--- a/test/local/data/src/%DEST%/bar/3.txt
+++ b/test/data/src/%DEST%/bar/3.txt
diff --git a/test/local/data/src/%DEST%/bar/baz/4.txt b/test/data/src/%DEST%/bar/baz/4.txt
index b8626c4..b8626c4 100644
--- a/test/local/data/src/%DEST%/bar/baz/4.txt
+++ b/test/data/src/%DEST%/bar/baz/4.txt
diff --git a/test/local/data/src/%DEST%/foo/2.txt b/test/data/src/%DEST%/foo/2.txt
index 0cfbf08..0cfbf08 100644
--- a/test/local/data/src/%DEST%/foo/2.txt
+++ b/test/data/src/%DEST%/foo/2.txt
diff --git a/test/docker/Dockerfile b/test/docker/Dockerfile
index 1090ccf..8cbae4f 100644
--- a/test/docker/Dockerfile
+++ b/test/docker/Dockerfile
@@ -12,4 +12,4 @@ COPY [".", "/src"]
WORKDIR /src
-CMD ["make", "test/local", "test/linux-home"]
+CMD ["make", "test"]
diff --git a/test/local/lib/log.sh b/test/lib/log.sh
index b26e16a..b26e16a 100644
--- a/test/local/lib/log.sh
+++ b/test/lib/log.sh
diff --git a/test/local/lib/test.sh b/test/lib/test.sh
index 43cf55b..1406a78 100644
--- a/test/local/lib/test.sh
+++ b/test/lib/test.sh
@@ -66,15 +66,15 @@ test_run_script() {
}
test_run_update() {
- test_run_script "$script_dir/../../bin/links-update" "$@"
+ test_run_script "$script_dir/../bin/links-update" "$@"
}
test_run_remove() {
- test_run_script "$script_dir/../../bin/links-remove"
+ test_run_script "$script_dir/../bin/links-remove"
}
test_run_chmod() {
- test_run_script "$script_dir/../../bin/links-chmod" "$@"
+ test_run_script "$script_dir/../bin/links-chmod" "$@"
}
test_verify_output() {
diff --git a/test/linux-home/test.sh b/test/linux-home/test.sh
deleted file mode 100755
index 5021048..0000000
--- a/test/linux-home/test.sh
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/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/bin/links-update" "$@"
-}
-
-call_remove() {
- call_bin_script "$root_dir/bin/links-remove"
-}
-
-call_chmod() {
- call_bin_script "$root_dir/bin/links-chmod" "$@"
-}
-
-test_my_dotfiles_work() {
- new_test
- call_update
- # Again:
- call_update
-}
-
-show_env() {
- echo
- echo ======================================================================
- echo Environment
- echo ======================================================================
-
- bash --version
-}
-
-main() {
- if [ -z "${CI:+x}" ]; then
- echo "$script_name: please don't run it outside of CI runs" >&2
- exit 1
- fi
-
- show_env
- test_my_dotfiles_work
-}
-
-main
diff --git a/test/local/main.sh b/test/main.sh
index 5713366..52b19ad 100755
--- a/test/local/main.sh
+++ b/test/main.sh
@@ -12,6 +12,8 @@ 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
source "$script_dir/lib/log.sh"
@@ -45,15 +47,24 @@ run_test_file() {
}
main() {
+ if [ "$#" -gt 1 ]; then
+ echo "usage: $script_name [PATTERN]" >&2
+ return 1
+ fi
+
local -a test_files=()
local test_file
+ local pattern='*'
+ [ "$#" -gt 0 ] && pattern="$1"
+
find "$script_dir" \
-mindepth 1 \
-maxdepth 1 \
-type f \
-regex '.*/tst-.*\.sh$' \
-regextype posix-basic \
+ -name "$pattern" \
-printf '%P\0' \
| sort -z \
| \
@@ -65,4 +76,4 @@ main() {
log_tests_summary
}
-main
+main "$@"
diff --git a/test/local/tst-chmod.sh b/test/tst-chmod.sh
index b118e5e..b118e5e 100644
--- a/test/local/tst-chmod.sh
+++ b/test/tst-chmod.sh
diff --git a/test/local/tst-dir-symlink-delete.sh b/test/tst-dir-symlink-delete.sh
index f53d87c..f53d87c 100644
--- a/test/local/tst-dir-symlink-delete.sh
+++ b/test/tst-dir-symlink-delete.sh
diff --git a/test/local/tst-dir-symlink-remove-shared-file.sh b/test/tst-dir-symlink-remove-shared-file.sh
index 3e20ab0..3e20ab0 100644
--- a/test/local/tst-dir-symlink-remove-shared-file.sh
+++ b/test/tst-dir-symlink-remove-shared-file.sh
diff --git a/test/tst-linux-home.sh b/test/tst-linux-home.sh
new file mode 100644
index 0000000..4d099ee
--- /dev/null
+++ b/test/tst-linux-home.sh
@@ -0,0 +1,42 @@
+[ -z "${CI+y}" ] && test_should_fail=y
+
+test_run() {
+ if [ -z "${CI+y}" ]; then
+ fail "Don't run this test locally, it'll mess up your \$HOME"
+ return 1
+ fi
+
+ readonly src_name=linux-home
+ src_url="https://github.com/egor-tensin/$src_name.git"
+ readonly src_url
+
+ 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"
+
+ log "Cloning $src_url to $test_src_dir..."
+ git clone -q -- "$src_url" "$test_src_dir"
+
+ test_run_update
+ # Again:
+ test_run_update
+
+ log "Checking a couple of well-known files..."
+ local file
+ for file in .gitconfig .ssh/config; do
+ local actual
+ actual="$( readlink -e -- "$HOME/$file" )"
+
+ local expected
+ expected="$test_src_dir/%HOME%/$file"
+
+ if [ "$actual" != "$expected" ]; then
+ fail "There was a problem with symlink $file:"
+ fail_details "Expected target: $expected"
+ fail_details "Actual target: $actual"
+ return 1
+ fi
+ done
+}
diff --git a/test/local/tst-remove-dir-symlink.sh b/test/tst-remove-dir-symlink.sh
index c524ee6..c524ee6 100644
--- a/test/local/tst-remove-dir-symlink.sh
+++ b/test/tst-remove-dir-symlink.sh
diff --git a/test/local/tst-remove-does-not-delete-user-dirs.sh b/test/tst-remove-does-not-delete-user-dirs.sh
index aa013c8..aa013c8 100644
--- a/test/local/tst-remove-does-not-delete-user-dirs.sh
+++ b/test/tst-remove-does-not-delete-user-dirs.sh
diff --git a/test/local/tst-remove-does-not-overwrite-files.sh b/test/tst-remove-does-not-overwrite-files.sh
index baef2ef..baef2ef 100644
--- a/test/local/tst-remove-does-not-overwrite-files.sh
+++ b/test/tst-remove-does-not-overwrite-files.sh
diff --git a/test/local/tst-remove-symlink.sh b/test/tst-remove-symlink.sh
index aa27435..aa27435 100644
--- a/test/local/tst-remove-symlink.sh
+++ b/test/tst-remove-symlink.sh
diff --git a/test/local/tst-remove.sh b/test/tst-remove.sh
index c79a3b4..c79a3b4 100644
--- a/test/local/tst-remove.sh
+++ b/test/tst-remove.sh
diff --git a/test/tst-root.sh b/test/tst-root.sh
new file mode 100644
index 0000000..e31661e
--- /dev/null
+++ b/test/tst-root.sh
@@ -0,0 +1,42 @@
+if [ -z "${CI+y}" ] || [ "$EUID" -ne 0 ]; then
+ test_should_fail=y
+fi
+
+test_run() {
+ if [ -z "${CI+y}" ]; then
+ fail "Don't run this test locally, it'll mess up your /"
+ return 1
+ fi
+ if [ "$EUID" -ne 0 ]; then
+ fail "This test requires root privileges"
+ return 1
+ fi
+
+ 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"
+
+ mkdir -p -- "$test_src_dir/%CONFIG_LINKS_ROOT%/foo"
+ mkdir /foo
+ chmod 0777 /foo
+ touch -- "$test_src_dir/%CONFIG_LINKS_ROOT%/foo/bar.txt"
+
+ test_run_update
+
+ log "Checking /foo/bar.txt..."
+
+ local actual
+ actual="$( readlink -e -- "/foo/bar.txt" )"
+
+ local expected
+ expected="$test_src_dir/%CONFIG_LINKS_ROOT%/foo/bar.txt"
+
+ if [ "$actual" != "$expected" ]; then
+ fail "There was a problem with symlink /foo/bar.txt:"
+ fail_details "Expected target: $expected"
+ fail_details "Actual target: $actual"
+ return 1
+ fi
+}
diff --git a/test/local/tst-update-chmod.sh b/test/tst-update-chmod.sh
index a78ee15..a78ee15 100644
--- a/test/local/tst-update-chmod.sh
+++ b/test/tst-update-chmod.sh
diff --git a/test/local/tst-update-dir-symlink.sh b/test/tst-update-dir-symlink.sh
index 27418ab..27418ab 100644
--- a/test/local/tst-update-dir-symlink.sh
+++ b/test/tst-update-dir-symlink.sh
diff --git a/test/local/tst-update-symlink.sh b/test/tst-update-symlink.sh
index 6a90491..6a90491 100644
--- a/test/local/tst-update-symlink.sh
+++ b/test/tst-update-symlink.sh
diff --git a/test/local/tst-update.sh b/test/tst-update.sh
index f33b929..f33b929 100644
--- a/test/local/tst-update.sh
+++ b/test/tst-update.sh