#!/bin/bash # Test script to run both Rust and Go implementations with their respective configs # This demonstrates feature parity between the implementations set -e echo "๐Ÿงช Testing both Rust and Go implementations with identical configurations" echo "==================================================" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' BLUE='\033[0;34m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Check if test environment is running check_test_env() { echo -e "${BLUE}๐Ÿ“ก Checking test environment...${NC}" if ! curl -s http://localhost:5984 >/dev/null; then echo -e "${YELLOW}โš ๏ธ Test environment not running. Starting it...${NC}" cd test ./start-test-env.sh cd .. echo -e "${GREEN}โœ… Test environment started${NC}" else echo -e "${GREEN}โœ… Test environment is running${NC}" fi } # Build both implementations build_implementations() { echo -e "${BLUE}๐Ÿ”จ Building implementations...${NC}" # Build Go implementation echo -e "${BLUE} Building Go implementation...${NC}" cd go go build -o mail2couch . cd .. echo -e "${GREEN} โœ… Go implementation built${NC}" # Build Rust implementation echo -e "${BLUE} Building Rust implementation...${NC}" cd rust cargo build --release cd .. echo -e "${GREEN} โœ… Rust implementation built${NC}" } # Run Go implementation run_go() { echo -e "${BLUE}๐Ÿฆฌ Running Go implementation...${NC}" cd go echo -e "${BLUE} Using config: config-test-go.json${NC}" ./mail2couch -c config-test-go.json cd .. echo -e "${GREEN}โœ… Go implementation completed${NC}" } # Run Rust implementation run_rust() { echo -e "${BLUE}๐Ÿฆ€ Running Rust implementation...${NC}" cd rust echo -e "${BLUE} Using config: config-test-rust.json${NC}" ./target/release/mail2couch -c config-test-rust.json cd .. echo -e "${GREEN}โœ… Rust implementation completed${NC}" } # Check results check_results() { echo -e "${BLUE}๐Ÿ” Checking results...${NC}" echo -e "${BLUE} Listing all databases:${NC}" curl -s http://localhost:5984/_all_dbs | python3 -m json.tool echo -e "\n${BLUE} Go implementation databases:${NC}" for db in go_wildcard_all_folders_test go_work_pattern_test go_specific_folders_only; do db_name="m2c_${db}" if curl -s "http://localhost:5984/${db_name}" >/dev/null 2>&1; then doc_count=$(curl -s "http://localhost:5984/${db_name}" | python3 -c "import sys, json; print(json.load(sys.stdin).get('doc_count', 0))") echo -e "${GREEN} โœ… ${db_name}: ${doc_count} documents${NC}" else echo -e "${RED} โŒ ${db_name}: not found${NC}" fi done echo -e "\n${BLUE} Rust implementation databases:${NC}" for db in rust_wildcard_all_folders_test rust_work_pattern_test rust_specific_folders_only; do db_name="m2c_${db}" if curl -s "http://localhost:5984/${db_name}" >/dev/null 2>&1; then doc_count=$(curl -s "http://localhost:5984/${db_name}" | python3 -c "import sys, json; print(json.load(sys.stdin).get('doc_count', 0))") echo -e "${GREEN} โœ… ${db_name}: ${doc_count} documents${NC}" else echo -e "${RED} โŒ ${db_name}: not found${NC}" fi done } # Main execution main() { echo -e "${YELLOW}๐Ÿš€ Starting feature parity test...${NC}" check_test_env build_implementations echo -e "\n${YELLOW}๐Ÿ“Š Running implementations with identical configurations...${NC}" run_go echo "" run_rust echo -e "\n${YELLOW}๐Ÿ“ˆ Checking results...${NC}" check_results echo -e "\n${GREEN}๐ŸŽ‰ Feature parity test completed!${NC}" echo -e "${BLUE}๐Ÿ’ก Both implementations should have created similar databases with identical message counts.${NC}" echo -e "${BLUE}๐Ÿ”— View results at: http://localhost:5984/_utils${NC}" } # Execute main function main "$@"