jekyll-theme-zer0 0.8.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +201 -4
- data/README.md +58 -25
- data/_data/README.md +4 -5
- data/_includes/README.md +1 -1
- data/_includes/stats/README.md +14 -2
- data/_layouts/README.md +3 -3
- data/_sass/core/_theme.scss +4 -1
- data/scripts/bin/build +115 -0
- data/scripts/bin/release +240 -0
- data/scripts/bin/test +203 -0
- data/scripts/features/generate-preview-images +846 -0
- data/scripts/features/install-preview-generator +531 -0
- data/scripts/features/preview_generator.py +646 -0
- data/scripts/generate-preview-images.sh +38 -93
- data/scripts/lib/README.md +35 -7
- data/scripts/test/integration/auto-version +243 -0
- data/scripts/test/integration/mermaid +252 -0
- data/scripts/test/lib/run_tests.sh +151 -0
- data/scripts/test/lib/test_changelog.sh +90 -0
- data/scripts/test/lib/test_gem.sh +71 -0
- data/scripts/test/lib/test_git.sh +85 -0
- data/scripts/test/lib/test_validation.sh +75 -0
- data/scripts/test/lib/test_version.sh +101 -0
- data/scripts/test/theme/validate +120 -0
- data/scripts/utils/analyze-commits +300 -0
- data/scripts/utils/fix-markdown +251 -0
- data/scripts/utils/setup +137 -0
- data/scripts/version.sh +26 -0
- metadata +20 -8
- data/scripts/build.sh +0 -33
- data/scripts/build.sh.legacy +0 -174
- data/scripts/gem-publish.sh +0 -42
- data/scripts/gem-publish.sh.legacy +0 -700
- data/scripts/release.sh +0 -33
- data/scripts/release.sh.legacy +0 -342
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
###############################################################################
|
|
4
|
+
# Mermaid Integration Test Script
|
|
5
|
+
#
|
|
6
|
+
# Purpose: Comprehensive testing of Mermaid.js integration in Jekyll
|
|
7
|
+
# Usage: ./scripts/test/integration/mermaid [options]
|
|
8
|
+
# Options:
|
|
9
|
+
# --verbose Show detailed output
|
|
10
|
+
# --headless Run in headless mode (for CI/CD)
|
|
11
|
+
# --quick Run quick validation only
|
|
12
|
+
# --local Test local Jekyll server
|
|
13
|
+
# --docker Test Docker container
|
|
14
|
+
###############################################################################
|
|
15
|
+
|
|
16
|
+
set -euo pipefail
|
|
17
|
+
|
|
18
|
+
# Get script directories
|
|
19
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
20
|
+
SCRIPTS_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
21
|
+
LIB_DIR="$SCRIPTS_ROOT/lib"
|
|
22
|
+
|
|
23
|
+
# Source common library for logging and utilities
|
|
24
|
+
source "$LIB_DIR/common.sh"
|
|
25
|
+
|
|
26
|
+
# Test counters
|
|
27
|
+
TESTS_PASSED=0
|
|
28
|
+
TESTS_FAILED=0
|
|
29
|
+
TOTAL_TESTS=0
|
|
30
|
+
|
|
31
|
+
# Configuration
|
|
32
|
+
export VERBOSE=${VERBOSE:-false}
|
|
33
|
+
HEADLESS=false
|
|
34
|
+
QUICK=false
|
|
35
|
+
TEST_MODE="both" # local, docker, both
|
|
36
|
+
|
|
37
|
+
# Parse arguments
|
|
38
|
+
for arg in "$@"; do
|
|
39
|
+
case $arg in
|
|
40
|
+
--verbose)
|
|
41
|
+
export VERBOSE=true
|
|
42
|
+
shift
|
|
43
|
+
;;
|
|
44
|
+
--headless)
|
|
45
|
+
HEADLESS=true
|
|
46
|
+
shift
|
|
47
|
+
;;
|
|
48
|
+
--quick)
|
|
49
|
+
QUICK=true
|
|
50
|
+
shift
|
|
51
|
+
;;
|
|
52
|
+
--local)
|
|
53
|
+
TEST_MODE="local"
|
|
54
|
+
shift
|
|
55
|
+
;;
|
|
56
|
+
--docker)
|
|
57
|
+
TEST_MODE="docker"
|
|
58
|
+
shift
|
|
59
|
+
;;
|
|
60
|
+
--help)
|
|
61
|
+
echo "Usage: $0 [options]"
|
|
62
|
+
echo "Options:"
|
|
63
|
+
echo " --verbose Show detailed output"
|
|
64
|
+
echo " --headless Run in headless mode (for CI/CD)"
|
|
65
|
+
echo " --quick Run quick validation only"
|
|
66
|
+
echo " --local Test local Jekyll server only"
|
|
67
|
+
echo " --docker Test Docker container only"
|
|
68
|
+
echo " --help Show this help message"
|
|
69
|
+
exit 0
|
|
70
|
+
;;
|
|
71
|
+
*)
|
|
72
|
+
echo "Unknown option: $arg"
|
|
73
|
+
echo "Use --help for usage information"
|
|
74
|
+
exit 1
|
|
75
|
+
;;
|
|
76
|
+
esac
|
|
77
|
+
done
|
|
78
|
+
|
|
79
|
+
# Logging functions
|
|
80
|
+
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
|
81
|
+
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
|
82
|
+
log_warning() { echo -e "${YELLOW}[!]${NC} $1"; }
|
|
83
|
+
log_error() { echo -e "${RED}[✗]${NC} $1"; }
|
|
84
|
+
|
|
85
|
+
# Test function
|
|
86
|
+
run_test() {
|
|
87
|
+
local test_name="$1"
|
|
88
|
+
local test_command="$2"
|
|
89
|
+
|
|
90
|
+
TOTAL_TESTS=$((TOTAL_TESTS + 1))
|
|
91
|
+
|
|
92
|
+
if [ "$VERBOSE" = true ]; then
|
|
93
|
+
log_info "Running: $test_name"
|
|
94
|
+
fi
|
|
95
|
+
|
|
96
|
+
if eval "$test_command" >/dev/null 2>&1; then
|
|
97
|
+
TESTS_PASSED=$((TESTS_PASSED + 1))
|
|
98
|
+
log_success "$test_name"
|
|
99
|
+
return 0
|
|
100
|
+
else
|
|
101
|
+
TESTS_FAILED=$((TESTS_FAILED + 1))
|
|
102
|
+
log_error "$test_name"
|
|
103
|
+
return 1
|
|
104
|
+
fi
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
# Test file existence
|
|
108
|
+
test_file_exists() {
|
|
109
|
+
local file_path="$1"
|
|
110
|
+
local description="$2"
|
|
111
|
+
|
|
112
|
+
run_test "$description" "[ -f '$file_path' ]"
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
# Test file content
|
|
116
|
+
test_file_content() {
|
|
117
|
+
local file_path="$1"
|
|
118
|
+
local pattern="$2"
|
|
119
|
+
local description="$3"
|
|
120
|
+
|
|
121
|
+
run_test "$description" "grep -q '$pattern' '$file_path'"
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
# Test URL accessibility
|
|
125
|
+
test_url() {
|
|
126
|
+
local url="$1"
|
|
127
|
+
local description="$2"
|
|
128
|
+
|
|
129
|
+
run_test "$description" "curl -s -f '$url' >/dev/null"
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
# Test Mermaid script loading
|
|
133
|
+
test_mermaid_script() {
|
|
134
|
+
local url="$1"
|
|
135
|
+
local description="$2"
|
|
136
|
+
|
|
137
|
+
run_test "$description" "curl -s '$url' | grep -q 'mermaid.min.js'"
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
# Test Mermaid initialization
|
|
141
|
+
test_mermaid_init() {
|
|
142
|
+
local url="$1"
|
|
143
|
+
local description="$2"
|
|
144
|
+
|
|
145
|
+
run_test "$description" "curl -s '$url' | grep -q 'mermaid.initialize'"
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
# Test diagram rendering
|
|
149
|
+
test_diagram_rendering() {
|
|
150
|
+
local url="$1"
|
|
151
|
+
local description="$2"
|
|
152
|
+
|
|
153
|
+
run_test "$description" "curl -s '$url' | grep -q 'class=\"mermaid\"'"
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
# Main test execution
|
|
157
|
+
main() {
|
|
158
|
+
echo "🧪 Mermaid Integration Test Suite"
|
|
159
|
+
echo "=================================="
|
|
160
|
+
echo "Mode: $TEST_MODE"
|
|
161
|
+
echo "Verbose: $VERBOSE"
|
|
162
|
+
echo "Quick: $QUICK"
|
|
163
|
+
echo ""
|
|
164
|
+
|
|
165
|
+
# Core file tests
|
|
166
|
+
log_info "Testing core files..."
|
|
167
|
+
|
|
168
|
+
test_file_exists "_includes/components/mermaid.html" "Mermaid include file exists"
|
|
169
|
+
test_file_exists "pages/_docs/jekyll/mermaid.md" "Main documentation exists"
|
|
170
|
+
test_file_exists "pages/_docs/jekyll/mermaid-test-suite.md" "Test suite exists"
|
|
171
|
+
test_file_exists "pages/_docs/jekyll/jekyll-diagram-with-mermaid.md" "Tutorial exists"
|
|
172
|
+
|
|
173
|
+
# Configuration tests
|
|
174
|
+
log_info "Testing configuration..."
|
|
175
|
+
|
|
176
|
+
test_file_content "_config.yml" "jekyll-mermaid" "Jekyll-mermaid plugin configured"
|
|
177
|
+
test_file_content "_config.yml" "mermaid:" "Mermaid configuration present"
|
|
178
|
+
test_file_content "_includes/core/head.html" "page.mermaid" "Conditional loading configured"
|
|
179
|
+
test_file_content "_includes/core/head.html" "mermaid.html" "Mermaid include referenced"
|
|
180
|
+
|
|
181
|
+
# Mermaid include file tests
|
|
182
|
+
log_info "Testing Mermaid include file..."
|
|
183
|
+
|
|
184
|
+
test_file_content "_includes/components/mermaid.html" "mermaid@10" "Mermaid v10 CDN link"
|
|
185
|
+
test_file_content "_includes/components/mermaid.html" "mermaid.initialize" "Mermaid initialization script"
|
|
186
|
+
test_file_content "_includes/components/mermaid.html" "forest" "Forest theme configured"
|
|
187
|
+
test_file_content "_includes/components/mermaid.html" "FontAwesome" "FontAwesome support included"
|
|
188
|
+
|
|
189
|
+
# Documentation tests
|
|
190
|
+
log_info "Testing documentation..."
|
|
191
|
+
|
|
192
|
+
test_file_content "pages/_docs/jekyll/mermaid.md" "mermaid: true" "Main docs have front matter"
|
|
193
|
+
test_file_content "pages/_docs/jekyll/mermaid-test-suite.md" "mermaid: true" "Test suite has front matter"
|
|
194
|
+
test_file_content "pages/_docs/jekyll/mermaid.md" "graph TD" "Main docs have examples"
|
|
195
|
+
test_file_content "pages/_docs/jekyll/mermaid-test-suite.md" "graph TD" "Test suite has examples"
|
|
196
|
+
|
|
197
|
+
# Server tests (if not quick mode)
|
|
198
|
+
if [ "$QUICK" = false ]; then
|
|
199
|
+
log_info "Testing server functionality..."
|
|
200
|
+
|
|
201
|
+
# Test local server if enabled
|
|
202
|
+
if [ "$TEST_MODE" = "local" ] || [ "$TEST_MODE" = "both" ]; then
|
|
203
|
+
log_info "Testing local Jekyll server..."
|
|
204
|
+
|
|
205
|
+
# Check if local server is running
|
|
206
|
+
if curl -s -f "http://localhost:4000" >/dev/null 2>&1; then
|
|
207
|
+
test_url "http://localhost:4000/docs/jekyll/mermaid/" "Main documentation accessible"
|
|
208
|
+
test_url "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Test suite accessible"
|
|
209
|
+
test_mermaid_script "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Mermaid script loads on test page"
|
|
210
|
+
test_mermaid_init "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Mermaid initializes on test page"
|
|
211
|
+
test_diagram_rendering "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Diagrams render on test page"
|
|
212
|
+
else
|
|
213
|
+
log_warning "Local Jekyll server not running. Start with: bundle exec jekyll serve"
|
|
214
|
+
fi
|
|
215
|
+
fi
|
|
216
|
+
|
|
217
|
+
# Test Docker server if enabled
|
|
218
|
+
if [ "$TEST_MODE" = "docker" ] || [ "$TEST_MODE" = "both" ]; then
|
|
219
|
+
log_info "Testing Docker container..."
|
|
220
|
+
|
|
221
|
+
# Check if Docker container is running
|
|
222
|
+
if docker ps | grep -q "zer0-mistakes-jekyll"; then
|
|
223
|
+
test_url "http://localhost:4000/docs/jekyll/mermaid/" "Docker: Main documentation accessible"
|
|
224
|
+
test_url "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Docker: Test suite accessible"
|
|
225
|
+
test_mermaid_script "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Docker: Mermaid script loads"
|
|
226
|
+
test_mermaid_init "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Docker: Mermaid initializes"
|
|
227
|
+
test_diagram_rendering "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Docker: Diagrams render"
|
|
228
|
+
else
|
|
229
|
+
log_warning "Docker container not running. Start with: docker-compose up -d"
|
|
230
|
+
fi
|
|
231
|
+
fi
|
|
232
|
+
fi
|
|
233
|
+
|
|
234
|
+
# Summary
|
|
235
|
+
echo ""
|
|
236
|
+
echo "📊 Test Results Summary"
|
|
237
|
+
echo "======================"
|
|
238
|
+
echo "Total Tests: $TOTAL_TESTS"
|
|
239
|
+
echo "Passed: $TESTS_PASSED"
|
|
240
|
+
echo "Failed: $TESTS_FAILED"
|
|
241
|
+
|
|
242
|
+
if [ $TESTS_FAILED -eq 0 ]; then
|
|
243
|
+
log_success "All tests passed! ✅"
|
|
244
|
+
exit 0
|
|
245
|
+
else
|
|
246
|
+
log_error "Some tests failed! ❌"
|
|
247
|
+
exit 1
|
|
248
|
+
fi
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
# Run main function
|
|
252
|
+
main "$@"
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Test runner for library unit tests
|
|
4
|
+
# Usage: ./scripts/test/lib/run_tests.sh
|
|
5
|
+
#
|
|
6
|
+
# Note: Requires Bash 4.0+ (for associative arrays in changelog.sh)
|
|
7
|
+
# On macOS: brew install bash
|
|
8
|
+
|
|
9
|
+
# Note: We intentionally don't use set -e here because test assertions
|
|
10
|
+
# may return non-zero and we want to continue running tests
|
|
11
|
+
set -uo pipefail
|
|
12
|
+
|
|
13
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
14
|
+
# Navigate from scripts/test/lib to scripts/lib
|
|
15
|
+
LIB_DIR="$(cd "$SCRIPT_DIR/../../lib" && pwd)"
|
|
16
|
+
|
|
17
|
+
# Colors
|
|
18
|
+
RED='\033[0;31m'
|
|
19
|
+
GREEN='\033[0;32m'
|
|
20
|
+
YELLOW='\033[1;33m'
|
|
21
|
+
BLUE='\033[0;34m'
|
|
22
|
+
NC='\033[0m'
|
|
23
|
+
|
|
24
|
+
# Test counters
|
|
25
|
+
TESTS_RUN=0
|
|
26
|
+
TESTS_PASSED=0
|
|
27
|
+
TESTS_FAILED=0
|
|
28
|
+
|
|
29
|
+
# Test result tracking
|
|
30
|
+
declare -a FAILED_TESTS=()
|
|
31
|
+
|
|
32
|
+
# Test assertions
|
|
33
|
+
assert_equals() {
|
|
34
|
+
local expected="$1"
|
|
35
|
+
local actual="$2"
|
|
36
|
+
local message="${3:-}"
|
|
37
|
+
|
|
38
|
+
((TESTS_RUN++))
|
|
39
|
+
|
|
40
|
+
if [[ "$expected" == "$actual" ]]; then
|
|
41
|
+
((TESTS_PASSED++))
|
|
42
|
+
echo -e "${GREEN}✓${NC} $message"
|
|
43
|
+
return 0
|
|
44
|
+
else
|
|
45
|
+
((TESTS_FAILED++))
|
|
46
|
+
echo -e "${RED}✗${NC} $message"
|
|
47
|
+
echo -e " Expected: ${YELLOW}$expected${NC}"
|
|
48
|
+
echo -e " Actual: ${YELLOW}$actual${NC}"
|
|
49
|
+
FAILED_TESTS+=("$message")
|
|
50
|
+
return 1
|
|
51
|
+
fi
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
assert_true() {
|
|
55
|
+
local condition="$1"
|
|
56
|
+
local message="${2:-}"
|
|
57
|
+
|
|
58
|
+
((TESTS_RUN++))
|
|
59
|
+
|
|
60
|
+
if eval "$condition"; then
|
|
61
|
+
((TESTS_PASSED++))
|
|
62
|
+
echo -e "${GREEN}✓${NC} $message"
|
|
63
|
+
return 0
|
|
64
|
+
else
|
|
65
|
+
((TESTS_FAILED++))
|
|
66
|
+
echo -e "${RED}✗${NC} $message"
|
|
67
|
+
echo -e " Condition failed: ${YELLOW}$condition${NC}"
|
|
68
|
+
FAILED_TESTS+=("$message")
|
|
69
|
+
return 1
|
|
70
|
+
fi
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
assert_false() {
|
|
74
|
+
local condition="$1"
|
|
75
|
+
local message="${2:-}"
|
|
76
|
+
|
|
77
|
+
((TESTS_RUN++))
|
|
78
|
+
|
|
79
|
+
if ! eval "$condition"; then
|
|
80
|
+
((TESTS_PASSED++))
|
|
81
|
+
echo -e "${GREEN}✓${NC} $message"
|
|
82
|
+
return 0
|
|
83
|
+
else
|
|
84
|
+
((TESTS_FAILED++))
|
|
85
|
+
echo -e "${RED}✗${NC} $message"
|
|
86
|
+
echo -e " Condition should have failed: ${YELLOW}$condition${NC}"
|
|
87
|
+
FAILED_TESTS+=("$message")
|
|
88
|
+
return 1
|
|
89
|
+
fi
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
# Test suite header
|
|
93
|
+
print_suite_header() {
|
|
94
|
+
echo -e "\n${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
95
|
+
echo -e "${BLUE}Testing: $1${NC}"
|
|
96
|
+
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}\n"
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# Run test files
|
|
100
|
+
run_test_file() {
|
|
101
|
+
local test_file="$1"
|
|
102
|
+
|
|
103
|
+
if [[ -f "$test_file" && -x "$test_file" ]]; then
|
|
104
|
+
bash "$test_file"
|
|
105
|
+
else
|
|
106
|
+
echo -e "${YELLOW}Skipping $test_file (not found or not executable)${NC}"
|
|
107
|
+
fi
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
# Main test execution
|
|
111
|
+
main() {
|
|
112
|
+
echo -e "${BLUE}╔═══════════════════════════════════════╗${NC}"
|
|
113
|
+
echo -e "${BLUE}║ Library Unit Test Suite ║${NC}"
|
|
114
|
+
echo -e "${BLUE}╚═══════════════════════════════════════╝${NC}"
|
|
115
|
+
|
|
116
|
+
# Save the test directory (test files may overwrite SCRIPT_DIR)
|
|
117
|
+
local TEST_DIR="$SCRIPT_DIR"
|
|
118
|
+
|
|
119
|
+
# Export test functions for use in test files
|
|
120
|
+
export -f assert_equals assert_true assert_false print_suite_header
|
|
121
|
+
export RED GREEN YELLOW BLUE NC
|
|
122
|
+
export LIB_DIR
|
|
123
|
+
|
|
124
|
+
# Run individual test files (sourced, not executed)
|
|
125
|
+
source "$TEST_DIR/test_version.sh"
|
|
126
|
+
source "$TEST_DIR/test_validation.sh"
|
|
127
|
+
source "$TEST_DIR/test_git.sh"
|
|
128
|
+
source "$TEST_DIR/test_changelog.sh"
|
|
129
|
+
source "$TEST_DIR/test_gem.sh"
|
|
130
|
+
|
|
131
|
+
# Summary
|
|
132
|
+
echo -e "\n${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
133
|
+
echo -e "${BLUE}Test Summary${NC}"
|
|
134
|
+
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
135
|
+
echo -e "Total: $TESTS_RUN"
|
|
136
|
+
echo -e "${GREEN}Passed: $TESTS_PASSED${NC}"
|
|
137
|
+
echo -e "${RED}Failed: $TESTS_FAILED${NC}"
|
|
138
|
+
|
|
139
|
+
if [[ $TESTS_FAILED -gt 0 ]]; then
|
|
140
|
+
echo -e "\n${RED}Failed tests:${NC}"
|
|
141
|
+
for test in "${FAILED_TESTS[@]}"; do
|
|
142
|
+
echo -e " ${RED}✗${NC} $test"
|
|
143
|
+
done
|
|
144
|
+
exit 1
|
|
145
|
+
else
|
|
146
|
+
echo -e "\n${GREEN}All tests passed! 🎉${NC}"
|
|
147
|
+
exit 0
|
|
148
|
+
fi
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
main "$@"
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Unit tests for changelog.sh library
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
LIB_DIR="$(cd "$SCRIPT_DIR/../../lib" && pwd)"
|
|
7
|
+
|
|
8
|
+
# Set up test environment
|
|
9
|
+
export DRY_RUN=true
|
|
10
|
+
export INTERACTIVE=false
|
|
11
|
+
export VERBOSE=false
|
|
12
|
+
|
|
13
|
+
# Source the library
|
|
14
|
+
source "$LIB_DIR/changelog.sh"
|
|
15
|
+
|
|
16
|
+
# Disable errexit for test assertions
|
|
17
|
+
set +e
|
|
18
|
+
|
|
19
|
+
print_suite_header "changelog.sh"
|
|
20
|
+
|
|
21
|
+
# Test: clean_commit_message
|
|
22
|
+
echo "Testing clean_commit_message..."
|
|
23
|
+
|
|
24
|
+
result=$(clean_commit_message "feat: add new feature")
|
|
25
|
+
assert_equals "Add new feature" "$result" "Clean 'feat:' prefix"
|
|
26
|
+
|
|
27
|
+
result=$(clean_commit_message "fix: resolve bug")
|
|
28
|
+
assert_equals "Resolve bug" "$result" "Clean 'fix:' prefix"
|
|
29
|
+
|
|
30
|
+
result=$(clean_commit_message "feat(scope): add scoped feature")
|
|
31
|
+
assert_equals "Add scoped feature" "$result" "Clean 'feat(scope):' prefix"
|
|
32
|
+
|
|
33
|
+
result=$(clean_commit_message "chore: update dependencies")
|
|
34
|
+
assert_equals "Update dependencies" "$result" "Clean 'chore:' prefix"
|
|
35
|
+
|
|
36
|
+
result=$(clean_commit_message "docs: improve readme")
|
|
37
|
+
assert_equals "Improve readme" "$result" "Clean 'docs:' prefix and capitalize"
|
|
38
|
+
|
|
39
|
+
result=$(clean_commit_message "regular commit message")
|
|
40
|
+
assert_equals "Regular commit message" "$result" "Capitalize regular message"
|
|
41
|
+
|
|
42
|
+
# Test: categorize_commit (requires git, so we test the logic patterns)
|
|
43
|
+
echo -e "\nTesting commit categorization patterns..."
|
|
44
|
+
|
|
45
|
+
# Simulate commit subjects for categorization
|
|
46
|
+
test_categorization() {
|
|
47
|
+
local subject="$1"
|
|
48
|
+
local expected="$2"
|
|
49
|
+
|
|
50
|
+
# Create temporary test function that returns category based on patterns
|
|
51
|
+
local subject_lower=$(echo "$subject" | tr '[:upper:]' '[:lower:]')
|
|
52
|
+
local category="other"
|
|
53
|
+
|
|
54
|
+
case "$subject_lower" in
|
|
55
|
+
feat:*|feature:*|add:*|new:*)
|
|
56
|
+
category="added"
|
|
57
|
+
;;
|
|
58
|
+
fix:*|bugfix:*|bug:*|patch:*)
|
|
59
|
+
category="fixed"
|
|
60
|
+
;;
|
|
61
|
+
*breaking*)
|
|
62
|
+
category="breaking"
|
|
63
|
+
;;
|
|
64
|
+
perf:*|performance:*|refactor:*|style:*|docs:*|doc:*|test:*|chore:*|ci:*|build:*)
|
|
65
|
+
category="changed"
|
|
66
|
+
;;
|
|
67
|
+
revert:*|remove:*|delete:*)
|
|
68
|
+
category="removed"
|
|
69
|
+
;;
|
|
70
|
+
deprecate:*|deprecated:*)
|
|
71
|
+
category="deprecated"
|
|
72
|
+
;;
|
|
73
|
+
security:*|sec:*)
|
|
74
|
+
category="security"
|
|
75
|
+
;;
|
|
76
|
+
esac
|
|
77
|
+
|
|
78
|
+
assert_equals "$expected" "$category" "Categorize: '$subject' → $expected"
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
test_categorization "feat: new feature" "added"
|
|
82
|
+
test_categorization "fix: bug fix" "fixed"
|
|
83
|
+
test_categorization "chore: update" "changed"
|
|
84
|
+
test_categorization "docs: improve" "changed"
|
|
85
|
+
test_categorization "remove: old code" "removed"
|
|
86
|
+
test_categorization "security: patch vulnerability" "security"
|
|
87
|
+
test_categorization "BREAKING: major change" "breaking"
|
|
88
|
+
test_categorization "random commit" "other"
|
|
89
|
+
|
|
90
|
+
echo -e "\n${GREEN}changelog.sh tests complete${NC}"
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Unit tests for gem.sh library
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
LIB_DIR="$(cd "$SCRIPT_DIR/../../lib" && pwd)"
|
|
7
|
+
|
|
8
|
+
# Set up test environment
|
|
9
|
+
export DRY_RUN=true
|
|
10
|
+
export INTERACTIVE=false
|
|
11
|
+
export VERBOSE=false
|
|
12
|
+
|
|
13
|
+
# Source the library
|
|
14
|
+
source "$LIB_DIR/gem.sh"
|
|
15
|
+
|
|
16
|
+
# Disable errexit for test assertions
|
|
17
|
+
set +e
|
|
18
|
+
|
|
19
|
+
print_suite_header "gem.sh"
|
|
20
|
+
|
|
21
|
+
# Test: gem_version_exists
|
|
22
|
+
echo "Testing gem_version_exists..."
|
|
23
|
+
|
|
24
|
+
# Test with a version that should exist (v1.0.0 is common)
|
|
25
|
+
if gem_version_exists "1.0.0" 2>/dev/null; then
|
|
26
|
+
echo -e "${YELLOW}ℹ${NC} Version 1.0.0 exists on RubyGems"
|
|
27
|
+
else
|
|
28
|
+
echo -e "${YELLOW}ℹ${NC} Version 1.0.0 does not exist on RubyGems"
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
# Test with a version that definitely shouldn't exist
|
|
32
|
+
if gem_version_exists "999.999.999" 2>/dev/null; then
|
|
33
|
+
assert_false "true" "Non-existent version not found"
|
|
34
|
+
else
|
|
35
|
+
assert_false "false" "Non-existent version not found"
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
# Test: Gem operations (dry run)
|
|
39
|
+
echo -e "\nTesting gem operations in dry run mode..."
|
|
40
|
+
|
|
41
|
+
# Test build_gem in dry run
|
|
42
|
+
if build_gem "1.0.0" 2>/dev/null; then
|
|
43
|
+
assert_true "true" "Dry run: build_gem"
|
|
44
|
+
else
|
|
45
|
+
assert_true "false" "Dry run: build_gem"
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# Test publish_gem in dry run
|
|
49
|
+
if publish_gem "1.0.0" 2>/dev/null; then
|
|
50
|
+
assert_true "true" "Dry run: publish_gem"
|
|
51
|
+
else
|
|
52
|
+
# May fail due to missing gem file, that's ok in dry run
|
|
53
|
+
echo -e "${YELLOW}ℹ${NC} Dry run: publish_gem (skipped - no gem file)"
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
# Test create_github_release in dry run
|
|
57
|
+
if create_github_release "1.0.0" 2>/dev/null; then
|
|
58
|
+
assert_true "true" "Dry run: create_github_release"
|
|
59
|
+
else
|
|
60
|
+
# May fail if gh CLI not available, that's ok
|
|
61
|
+
echo -e "${YELLOW}ℹ${NC} Dry run: create_github_release (skipped - gh CLI may not be available)"
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
# Test run_tests in dry run
|
|
65
|
+
if run_tests 2>/dev/null; then
|
|
66
|
+
assert_true "true" "Dry run: run_tests"
|
|
67
|
+
else
|
|
68
|
+
assert_true "false" "Dry run: run_tests"
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
echo -e "\n${GREEN}gem.sh tests complete${NC}"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Unit tests for git.sh library
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
LIB_DIR="$(cd "$SCRIPT_DIR/../../lib" && pwd)"
|
|
7
|
+
|
|
8
|
+
# Set up test environment
|
|
9
|
+
export DRY_RUN=true
|
|
10
|
+
export INTERACTIVE=false
|
|
11
|
+
export VERBOSE=false
|
|
12
|
+
|
|
13
|
+
# Source the library
|
|
14
|
+
source "$LIB_DIR/git.sh"
|
|
15
|
+
|
|
16
|
+
# Disable errexit for test assertions
|
|
17
|
+
set +e
|
|
18
|
+
|
|
19
|
+
print_suite_header "git.sh"
|
|
20
|
+
|
|
21
|
+
# Test: get_current_branch
|
|
22
|
+
echo "Testing get_current_branch..."
|
|
23
|
+
|
|
24
|
+
current_branch=$(get_current_branch)
|
|
25
|
+
if [[ -n "$current_branch" ]]; then
|
|
26
|
+
assert_true "true" "Get current branch: $current_branch"
|
|
27
|
+
else
|
|
28
|
+
assert_true "false" "Get current branch"
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
# Test: get_remote_url
|
|
32
|
+
echo -e "\nTesting get_remote_url..."
|
|
33
|
+
|
|
34
|
+
remote_url=$(get_remote_url "origin" 2>/dev/null)
|
|
35
|
+
if [[ -n "$remote_url" ]]; then
|
|
36
|
+
assert_true "true" "Get remote URL: $remote_url"
|
|
37
|
+
else
|
|
38
|
+
echo -e "${YELLOW}ℹ${NC} No remote URL found (may not be in git repo)"
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# Test: get_repo_info
|
|
42
|
+
echo -e "\nTesting get_repo_info..."
|
|
43
|
+
|
|
44
|
+
if [[ -n "$remote_url" ]]; then
|
|
45
|
+
repo_info=$(get_repo_info "origin" 2>/dev/null)
|
|
46
|
+
if [[ -n "$repo_info" ]]; then
|
|
47
|
+
assert_true "true" "Extract repo info: $repo_info"
|
|
48
|
+
else
|
|
49
|
+
echo -e "${YELLOW}ℹ${NC} Could not extract repo info from URL"
|
|
50
|
+
fi
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# Test: tag_exists
|
|
54
|
+
echo -e "\nTesting tag_exists..."
|
|
55
|
+
|
|
56
|
+
# Test with a tag that likely doesn't exist
|
|
57
|
+
if tag_exists "v999.999.999"; then
|
|
58
|
+
assert_false "true" "Non-existent tag not found"
|
|
59
|
+
else
|
|
60
|
+
assert_false "false" "Non-existent tag not found"
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
# Test: get_last_version_tag
|
|
64
|
+
echo -e "\nTesting get_last_version_tag..."
|
|
65
|
+
|
|
66
|
+
last_tag=$(get_last_version_tag 2>/dev/null)
|
|
67
|
+
if [[ -n "$last_tag" ]]; then
|
|
68
|
+
assert_true "true" "Get last version tag: $last_tag"
|
|
69
|
+
else
|
|
70
|
+
echo -e "${YELLOW}ℹ${NC} No version tags found (using initial commit)"
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
# Test: count_commits_since
|
|
74
|
+
echo -e "\nTesting count_commits_since..."
|
|
75
|
+
|
|
76
|
+
if [[ -n "$last_tag" ]]; then
|
|
77
|
+
commit_count=$(count_commits_since "$last_tag" 2>/dev/null)
|
|
78
|
+
if [[ "$commit_count" =~ ^[0-9]+$ ]]; then
|
|
79
|
+
assert_true "true" "Count commits since $last_tag: $commit_count"
|
|
80
|
+
else
|
|
81
|
+
assert_true "false" "Count commits returns number"
|
|
82
|
+
fi
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
echo -e "\n${GREEN}git.sh tests complete${NC}"
|