-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun-tests.sh
More file actions
executable file
·78 lines (62 loc) · 2.53 KB
/
Copy pathrun-tests.sh
File metadata and controls
executable file
·78 lines (62 loc) · 2.53 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
#!/bin/bash
# Vault.sol Test Suite Runner
# Runs all test types with detailed logging
set -e # Exit on error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Log file
LOG_FILE="test-run-$(date +%Y%m%d-%H%M%S).log"
# Logging function
log() {
echo -e "$1" | tee -a "$LOG_FILE"
}
# Header
log "${BLUE}══════════════════════════════════════════════════════════════${NC}"
log "${BLUE} Vault.sol Test Suite - $(date)${NC}"
log "${BLUE}══════════════════════════════════════════════════════════════${NC}"
echo "" | tee -a "$LOG_FILE"
# Function to run tests with error handling
run_test_suite() {
local name=$1
local pattern=$2
local extra_args=${3:-""}
log "${YELLOW}▶ Running $name...${NC}"
echo "" | tee -a "$LOG_FILE"
if forge test --match-contract "$pattern" $extra_args 2>&1 | tee -a "$LOG_FILE"; then
log "${GREEN}✓ $name passed${NC}"
echo "" | tee -a "$LOG_FILE"
return 0
else
log "${RED}✗ $name failed${NC}"
echo "" | tee -a "$LOG_FILE"
return 1
fi
}
# Run all test suites
FAILED=0
# 1. Unit Tests - Core Functionality (27 tests)
run_test_suite "Unit Tests - Core" "VaultCoreTest" "-vvv" || FAILED=$((FAILED + 1))
# 2. Unit Tests - Access Control (13 tests)
run_test_suite "Unit Tests - Access Control" "AccessControlTest" "-vvv" || FAILED=$((FAILED + 1))
# 3. Fuzz Tests (7 tests, 256 runs each)
run_test_suite "Fuzz Tests" "VaultFuzzTest" "-vvv" || FAILED=$((FAILED + 1))
# 4. Integration Tests (7 tests)
run_test_suite "Integration Tests" "VaultIntegrationTest" "-vvv" || FAILED=$((FAILED + 1))
# Summary
echo "" | tee -a "$LOG_FILE"
log "${BLUE}══════════════════════════════════════════════════════════════${NC}"
log "${BLUE} Test Summary${NC}"
log "${BLUE}══════════════════════════════════════════════════════════════${NC}"
if [ $FAILED -eq 0 ]; then
log "${GREEN}✓ All test suites passed!${NC}"
log "${GREEN}✓ Log saved to: $LOG_FILE${NC}"
exit 0
else
log "${RED}✗ $FAILED test suite(s) failed${NC}"
log "${RED}✗ Check log: $LOG_FILE${NC}"
exit 1
fi