-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests.sh
More file actions
executable file
·117 lines (95 loc) · 2.77 KB
/
run-tests.sh
File metadata and controls
executable file
·117 lines (95 loc) · 2.77 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
#!/bin/bash
# =============================================================================
# Generic Project Starter Script
# =============================================================================
# Description: Configurable script to start development tests
# Usage: ./run-tests.sh [target_subdirectory]
# Author: Marc Haye
# Version: 1.0
# =============================================================================
# -----------------------------------------------------------------------------
# Configuration Variables
# -----------------------------------------------------------------------------
# Export .env variables
set -a # auto-export enable
source docker/.env
set +a # auto-export disable
# Project config
PROJECT_NAME="falloutdle"
PROJECT_PATH="$HOME/dev/$PROJECT_NAME"
# Test config
TESTS_PATH="$PROJECT_PATH/tests"
VERBOSE=false
# -----------------------------------------------------------------------------
# Utility Functions
# -----------------------------------------------------------------------------
# Print colored output for better visibility
print_info() {
echo -e "\e[32m[INFO]\e[0m $1"
}
print_error() {
echo -e "\e[31m[ERROR]\e[0m $1"
}
print_warning() {
echo -e "\e[33m[WARNING]\e[0m $1"
}
# Display help information
show_help() {
cat << EOF
Usage: $0 [OPTIONS] [SUBDIRECTORY]
Generic project dev tests script for $PROJECT_NAME
OPTIONS:
-h, --help Show this help message
-v, --verbose Enable verbose output in tests
EXAMPLES:
$0 # Start server in default location
$0 -v # Start tests with verbose enabled
EOF
}
# -----------------------------------------------------------------------------
# Main Execution Logic
# -----------------------------------------------------------------------------
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
show_help
exit 0
;;
-v|--verbose)
VERBOSE=true # Enable verbose mode
shift
;;
-*)
print_error "Unknown option: $1"
show_help
exit 1
;;
*)
TARGET_SUBDIRECTORY="$1"
shift
;;
esac
done
print_info "Starting $PROJECT_NAME tests..."
# Pre-flight checks
# Navigate to target directory if specified
if [[ -n "$TARGET_SUBDIRECTORY" ]]; then
EXECUTION_PATH="$TARGET_SUBDIRECTORY"
else
EXECUTION_PATH="$TESTS_PATH"
fi
print_info "Execution path: $EXECUTION_PATH"
cd "$EXECUTION_PATH"
if ($VERBOSE)
then
print_warning "Verbose enabled !"
EXECUTION_COMMAND="go test -v"
else
EXECUTION_COMMAND="go test"
fi
print_info "Execution command: $EXECUTION_COMMAND [file].go"
for file in *
do
print_info "Testing file: $file"
$EXECUTION_COMMAND $file
done