-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·158 lines (135 loc) · 4.01 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·158 lines (135 loc) · 4.01 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
#############################################
# Faber Testing Script
# Tests bash syntax and basic functionality
#############################################
set -e
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " Faber Testing Suite"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
# Test counter
TESTS_PASSED=0
TESTS_FAILED=0
# Test bash syntax
test_syntax() {
local file=$1
echo -n "Testing syntax: $file ... "
if bash -n "$file" 2>/dev/null; then
echo -e "${GREEN}✓ PASS${NC}"
((TESTS_PASSED++))
return 0
else
echo -e "${RED}✗ FAIL${NC}"
bash -n "$file"
((TESTS_FAILED++))
return 1
fi
}
# Test if file is executable
test_executable() {
local file=$1
echo -n "Testing executable: $file ... "
if [ -x "$file" ]; then
echo -e "${GREEN}✓ PASS${NC}"
((TESTS_PASSED++))
return 0
else
echo -e "${RED}✗ FAIL${NC}"
((TESTS_FAILED++))
return 1
fi
}
# Test if file exists
test_exists() {
local file=$1
echo -n "Testing exists: $file ... "
if [ -f "$file" ]; then
echo -e "${GREEN}✓ PASS${NC}"
((TESTS_PASSED++))
return 0
else
echo -e "${RED}✗ FAIL${NC}"
((TESTS_FAILED++))
return 1
fi
}
echo "1. File Existence Tests"
echo "─────────────────────────────────────"
test_exists "faber"
test_exists "install.sh"
test_exists "README.md"
test_exists "LICENSE"
test_exists "lib/storage.sh"
test_exists "lib/system.sh"
test_exists "lib/commands.sh"
test_exists "lib/app.sh"
test_exists "lib/domain.sh"
test_exists "lib/database.sh"
test_exists "lib/php.sh"
test_exists "lib/nginx.sh"
test_exists "lib/service.sh"
test_exists "lib/update.sh"
test_exists "lib/templates.sh"
echo ""
echo "2. Executable Tests"
echo "─────────────────────────────────────"
test_executable "faber"
test_executable "install.sh"
echo ""
echo "3. Bash Syntax Tests"
echo "─────────────────────────────────────"
test_syntax "faber"
test_syntax "install.sh"
for file in lib/*.sh; do
test_syntax "$file"
done
echo ""
echo "4. Content Tests"
echo "─────────────────────────────────────"
# Test if main script has proper shebang
echo -n "Testing shebang in faber ... "
if head -n 1 faber | grep -q "#!/bin/bash"; then
echo -e "${GREEN}✓ PASS${NC}"
((TESTS_PASSED++))
else
echo -e "${RED}✗ FAIL${NC}"
((TESTS_FAILED++))
fi
# Test if install.sh has proper shebang
echo -n "Testing shebang in install.sh ... "
if head -n 1 install.sh | grep -q "#!/bin/bash"; then
echo -e "${GREEN}✓ PASS${NC}"
((TESTS_PASSED++))
else
echo -e "${RED}✗ FAIL${NC}"
((TESTS_FAILED++))
fi
# Test if README has installation instructions
echo -n "Testing README has installation ... "
if grep -q "wget -O - https://raw.githubusercontent.com" README.md; then
echo -e "${GREEN}✓ PASS${NC}"
((TESTS_PASSED++))
else
echo -e "${RED}✗ FAIL${NC}"
((TESTS_FAILED++))
fi
echo ""
# Summary
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " Test Summary"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "Tests Passed: ${GREEN}$TESTS_PASSED${NC}"
echo -e "Tests Failed: ${RED}$TESTS_FAILED${NC}"
echo ""
if [ $TESTS_FAILED -eq 0 ]; then
echo -e "${GREEN}✓ All tests passed!${NC}"
exit 0
else
echo -e "${RED}✗ Some tests failed!${NC}"
exit 1
fi