forked from trent_larson/crowd-funder-for-time-pwa
migration: move to bash based build scripts
This commit is contained in:
74
scripts/test-common.sh
Executable file
74
scripts/test-common.sh
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
# test-common.sh
|
||||
# Author: Matthew Raymer
|
||||
# Description: Test script to verify common utilities work correctly
|
||||
# This script tests the common.sh utilities to ensure they function properly.
|
||||
|
||||
# Exit on any error
|
||||
set -e
|
||||
|
||||
# Source common utilities
|
||||
source "$(dirname "$0")/common.sh"
|
||||
|
||||
# Parse command line arguments
|
||||
parse_args "$@"
|
||||
|
||||
# Print test header
|
||||
print_header "Common Utilities Test"
|
||||
log_info "Testing common utilities at $(date)"
|
||||
|
||||
# Test logging functions
|
||||
log_info "Testing info logging"
|
||||
log_success "Testing success logging"
|
||||
log_warn "Testing warning logging"
|
||||
log_error "Testing error logging (this is expected)"
|
||||
log_debug "Testing debug logging"
|
||||
log_step "Testing step logging"
|
||||
|
||||
# Test timing function
|
||||
log_info "Testing timing function..."
|
||||
measure_time sleep 1
|
||||
|
||||
# Test command checking
|
||||
log_info "Testing command checking..."
|
||||
if check_command "echo"; then
|
||||
log_success "echo command found"
|
||||
else
|
||||
log_error "echo command not found"
|
||||
fi
|
||||
|
||||
# Test directory checking
|
||||
log_info "Testing directory checking..."
|
||||
if check_directory "scripts"; then
|
||||
log_success "scripts directory found"
|
||||
else
|
||||
log_error "scripts directory not found"
|
||||
fi
|
||||
|
||||
# Test file checking
|
||||
log_info "Testing file checking..."
|
||||
if check_file "scripts/common.sh"; then
|
||||
log_success "common.sh file found"
|
||||
else
|
||||
log_error "common.sh file not found"
|
||||
fi
|
||||
|
||||
# Test git hash function
|
||||
log_info "Testing git hash function..."
|
||||
GIT_HASH=$(get_git_hash)
|
||||
log_info "Git hash: $GIT_HASH"
|
||||
|
||||
# Test safe execute
|
||||
log_info "Testing safe execute..."
|
||||
safe_execute "Testing safe execute" "echo 'Hello from safe_execute'"
|
||||
|
||||
# Test build artifact cleaning
|
||||
log_info "Testing build artifact cleaning..."
|
||||
clean_build_artifacts "test-file-1" "test-file-2"
|
||||
|
||||
# Print test summary
|
||||
log_success "All common utilities tests completed successfully!"
|
||||
print_footer "Common Utilities Test"
|
||||
|
||||
# Exit with success
|
||||
exit 0
|
||||
Reference in New Issue
Block a user