-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathinstall-bats.sh
More file actions
executable file
·83 lines (72 loc) · 2.14 KB
/
install-bats.sh
File metadata and controls
executable file
·83 lines (72 loc) · 2.14 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
79
80
81
82
83
#!/bin/sh
# Script to install BATS (Bash Automated Testing System)
set -e
# Detect OS
if [ "$(uname)" = "Darwin" ]; then
# macOS
echo "Detected macOS, using Homebrew to install BATS..."
if ! command -v brew >/dev/null 2>&1; then
echo "Homebrew not found. Please install Homebrew first:"
echo " /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
exit 1
fi
if ! brew list bats-core >/dev/null 2>&1; then
brew install bats-core
else
echo "BATS already installed"
fi
elif [ -f /etc/debian_version ]; then
# Debian/Ubuntu
echo "Detected Debian/Ubuntu, using apt to install BATS..."
if ! command -v bats >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y bats
else
echo "BATS already installed"
fi
elif [ -f /etc/redhat-release ]; then
# RHEL/CentOS
echo "Detected RHEL/CentOS, installing BATS from GitHub..."
if ! command -v bats >/dev/null 2>&1; then
# Create temporary directory for installation
TEMP_DIR=$(mktemp -d)
cd "$TEMP_DIR"
# Clone and install BATS
git clone https://github.com/bats-core/bats-core.git
cd bats-core
sudo ./install.sh /usr/local
# Clean up
cd /
rm -rf "$TEMP_DIR"
else
echo "BATS already installed"
fi
else
# Other Linux or Unix
echo "Installing BATS from GitHub..."
if ! command -v bats >/dev/null 2>&1; then
# Create temporary directory for installation
TEMP_DIR=$(mktemp -d)
cd "$TEMP_DIR"
# Clone and install BATS
git clone https://github.com/bats-core/bats-core.git
cd bats-core
sudo ./install.sh /usr/local
# Clean up
cd /
rm -rf "$TEMP_DIR"
else
echo "BATS already installed"
fi
fi
# Verify installation
if command -v bats >/dev/null 2>&1; then
echo "BATS installed successfully!"
echo "Version information:"
bats --version
echo ""
echo "To run phpvm tests, use: bats test_phpvm.bats"
else
echo "BATS installation failed."
exit 1
fi