-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·78 lines (67 loc) · 1.73 KB
/
test.sh
File metadata and controls
executable file
·78 lines (67 loc) · 1.73 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
set -e
source /etc/os-release
cleanup() {
case "${ID}" in
debian|ubuntu)
rm -rf /var/lib/apt/lists/*
;;
esac
}
# Clean up
cleanup
NON_ROOT_USER=""
POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
for CURRENT_USER in "${POSSIBLE_USERS[@]}"; do
if id -u ${CURRENT_USER} >/dev/null 2>&1; then
NON_ROOT_USER=${CURRENT_USER}
break
fi
done
if [ "${NON_ROOT_USER}" = "" ]; then
NON_ROOT_USER=root
fi
apt_get_update() {
case "${ID}" in
debian|ubuntu)
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update -y
fi
;;
esac
}
# Checks if packages are installed and installs them if not
check_packages() {
case "${ID}" in
debian|ubuntu)
if ! dpkg -s "$@" >/dev/null 2>&1; then
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
;;
alpine)
if ! apk -e info "$@" >/dev/null 2>&1; then
apk add --no-cache "$@"
fi
;;
esac
}
check_packages git
LATEST_FISH_VERSION="$(git ls-remote --tags https://github.com/fish-shell/fish-shell | grep -oP "[0-9]+\\.[0-9]+\\.[0-9]+" | sort -V | tail -n 1)"
# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib
# Feature-specific tests
case "${ID}" in
debian|ubuntu)
check "fish" fish -v | grep "$LATEST_FISH_VERSION"
;;
alpine)
check "fish" fish -v
;;
esac
echo "Testing with user: ${NON_ROOT_USER}"
check "fisher" su "${NON_ROOT_USER}" -c 'fish -c "fisher -v"'
check "fishtape is not available" test ! "$(su "${NON_ROOT_USER}" -c 'fish -c "type -q fishtape"')"
# Report result
reportResults