-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun_minimal_tests.sh
More file actions
executable file
·57 lines (45 loc) · 1.69 KB
/
run_minimal_tests.sh
File metadata and controls
executable file
·57 lines (45 loc) · 1.69 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
#!/bin/bash
# Script to run all minimal tests for SmashLang packages
set -e
# Define colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Base directories
BASE_DIR="$(pwd)"
PACKAGES_DIR="${BASE_DIR}/smashlang_packages"
# Create logs directory
mkdir -p "${BASE_DIR}/logs"
echo -e "${BLUE}Running minimal tests for all SmashLang packages...${NC}"
# Find all minimal test files
find "$PACKAGES_DIR" -name "minimal.test.smash" | while read -r test_file; do
# Get the package name and parent
package_dir="$(dirname "$(dirname \"$test_file\")")"
package_name="$(basename "$package_dir")"
parent_dir="$(basename "$(dirname \"$package_dir\")")"
echo -e "${YELLOW}Testing package: $parent_dir/$package_name${NC}"
# Compile the test file if not already compiled
output_file="$(dirname "$test_file")/test_${package_name}"
if [ ! -f "$output_file" ] || [ "$test_file" -nt "$output_file" ]; then
echo -e " ${YELLOW}Compiling test file...${NC}"
if smashc "$test_file" -o "$output_file" > /dev/null 2>&1; then
echo -e " ${GREEN}Successfully compiled test file${NC}"
else
echo -e " ${RED}Failed to compile test file${NC}"
continue
fi
fi
# Run the test
echo -e " ${YELLOW}Running test...${NC}"
log_file="${BASE_DIR}/logs/${parent_dir}_${package_name}_test.log"
if "$output_file" > "$log_file" 2>&1; then
echo -e " ${GREEN}Test passed${NC}"
else
echo -e " ${RED}Test failed${NC}"
echo -e " ${YELLOW}See log file: $log_file${NC}"
fi
echo ""
done
echo -e "${GREEN}All minimal tests completed!${NC}"