# run_tests.R # # TEST RUNNER FOR SMARTCANE # ======================= # This script runs all tests for the SmartCane project. # Usage: Rscript run_tests.R [test_pattern] # - test_pattern: Optional regex pattern to match test files (default: all test_*.R files) # # Process command line arguments args <- commandArgs(trailingOnly = TRUE) test_pattern <- if (length(args) > 0) args[1] else "^test_.+\\.R$" # Set working directory to script location script_dir <- dirname(normalizePath(sys.frame(1)$ofile)) setwd(script_dir) # Source test framework source("tests/test_framework.R") # Set up test environment env <- setup_test_env() # Run tests cat("Running tests with pattern:", test_pattern, "\n\n") success <- run_tests(test_pattern) # Clean up teardown_test_env() # Exit with appropriate status code if (success) { cat("\n✓ All tests passed successfully!\n") quit(save = "no", status = 0) } else { cat("\n✗ Some tests failed.\n") quit(save = "no", status = 1) }