Repository navigation
Expand file tree
/
Copy pathcreate_simple_tests.sh
More file actions
executable file
路90 lines (71 loc) 路 2.17 KB
/
Copy pathcreate_simple_tests.sh
File metadata and controls
executable file
路90 lines (71 loc) 路 2.17 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
#!/bin/bash
# Script to create simplified test files 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"
echo -e "${BLUE}Creating simplified test files for SmashLang packages...${NC}"
# Find all package directories
find "$PACKAGES_DIR" -type d | while read -r dir; do
# Skip non-package directories
if [[ "$dir" == *"/assets"* || "$dir" == *"/examples"* || \
"$dir" == *"/src"* || "$dir" == *"/tests"* ]]; then
continue
fi
# Skip the template
if [[ "$dir" == *"__package__template"* ]]; then
continue
fi
# Get the package name and parent
package_name="$(basename "$dir")"
parent_dir="$(basename "$(dirname "$dir")")"
# Create tests directory if it doesn't exist
tests_dir="$dir/tests"
if [ ! -d "$tests_dir" ]; then
echo -e "${YELLOW}Creating tests directory for $parent_dir/$package_name${NC}"
mkdir -p "$tests_dir"
fi
# Determine import path
if [ "$parent_dir" == "smashlang_packages" ]; then
import_path="$package_name"
else
import_path="$parent_dir/$package_name"
fi
# Create a simple test file
test_file="$tests_dir/index.test.smash"
echo -e "${YELLOW}Creating test file for $parent_dir/$package_name${NC}"
cat > "$test_file" << EOF
// $import_path/tests/index.test.smash
// Basic test for $package_name package
import "std";
import "$import_path";
// Basic test function
fn test_package() {
// Simple assertion
if (true) {
std.print("$package_name package test passed");
return true;
} else {
std.print("$package_name package test failed");
return false;
}
}
// Run the test
fn main() {
std.print("Testing $package_name package...");
const result = test_package();
std.print("Test complete.");
return result ? 0 : 1;
}
// Call main
main();
EOF
echo -e "${GREEN}Created simplified test file for $parent_dir/$package_name${NC}"
done
echo -e "${GREEN}All packages now have simplified test files!${NC}"