-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-installers.sh
More file actions
64 lines (53 loc) · 1.96 KB
/
Copy pathtest-installers.sh
File metadata and controls
64 lines (53 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HELPER="$SCRIPT_DIR/install-package.sh"
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
TEST_ROOT="$(mktemp -d)"
cleanup() { rm -rf "$TEST_ROOT"; }
trap cleanup EXIT
assert_throws() {
local message="$1"
shift
if "$@" >/dev/null 2>&1; then
echo "$message" >&2
exit 1
fi
}
for package in codebase-orient install-codebase-orient; do
source_dir="$REPO_ROOT/skills/$package"
dest="$TEST_ROOT/$package-dest"
bash "$HELPER" "$package" "$source_dir" "$dest" >/dev/null
assert_throws "Normal install did not refuse existing $package destination." \
bash "$HELPER" "$package" "$source_dir" "$dest"
printf 'preserve' > "$dest/extra.txt"
bash "$HELPER" "$package" "$source_dir" "$dest" --force >/dev/null
if [ ! -f "$dest/extra.txt" ]; then
echo "Overlay reinstall deleted an extra $package file." >&2
exit 1
fi
bash "$HELPER" "$package" "$source_dir" "$dest" --clean >/dev/null
if [ -f "$dest/extra.txt" ]; then
echo "Clean reinstall retained an extra $package file." >&2
exit 1
fi
assert_throws 'Conflicting flags were accepted.' \
bash "$HELPER" "$package" "$source_dir" "$dest" --force --clean
rm -f "$dest/SKILL.md"
mkdir -p "$dest/SKILL.md"
assert_throws 'Overlay managed type conflict was accepted.' \
bash "$HELPER" "$package" "$source_dir" "$dest" --force
rm -rf "$dest"
mkdir -p "$dest"
printf 'keep' > "$dest/sentinel.txt"
bad_source="$TEST_ROOT/$package-bad-source"
cp -r "$source_dir" "$bad_source"
printf '\ncorrupt\n' >> "$bad_source/SKILL.md"
assert_throws 'Malformed source package was accepted.' \
bash "$HELPER" "$package" "$bad_source" "$dest" --clean
if [ ! -f "$dest/sentinel.txt" ]; then
echo "Source validation failure mutated the destination." >&2
exit 1
fi
done
echo "Installer tests passed."