Loading...
No commits yet
Not committed History
Blame
test_cleanup.sh • 3.6 KB
#!/bin/bash
# -*- coding: utf-8 -*-
# Test file for: cleanup.sh

THIS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(realpath "$THIS_DIR/../..")"

# Test counter
TESTS_RUN=0
TESTS_PASSED=0
TESTS_FAILED=0

# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'

assert_success() {
    local cmd="$1"
    local desc="${2:-$cmd}"
    ((TESTS_RUN++))
    if eval "$cmd" > /dev/null 2>&1; then
        echo -e "${GREEN}✓${NC} $desc"
        ((TESTS_PASSED++))
    else
        echo -e "${RED}✗${NC} $desc"
        ((TESTS_FAILED++))
    fi
}

assert_file_exists() {
    local file="$1"
    ((TESTS_RUN++))
    if [ -f "$file" ]; then
        echo -e "${GREEN}✓${NC} File exists: $file"
        ((TESTS_PASSED++))
    else
        echo -e "${RED}✗${NC} File missing: $file"
        ((TESTS_FAILED++))
    fi
}

# Add your tests here
test_placeholder() {
    echo "TODO: Add tests for cleanup.sh"
}

# Run tests
main() {
    echo "Testing: cleanup.sh"
    echo "========================================"

    test_placeholder

    echo "========================================"
    echo "Results: $TESTS_PASSED/$TESTS_RUN passed"
    [ $TESTS_FAILED -gt 0 ] && exit 1
    exit 0
}

main "$@"

# --------------------------------------------------------------------------------
# Start of Source Code from: /home/ywatanabe/proj/scitex-writer/scripts/shell/modules/cleanup.sh
# --------------------------------------------------------------------------------
# #!/bin/bash
# # -*- coding: utf-8 -*-
# # Timestamp: "2025-09-27 16:35:00 (ywatanabe)"
# # File: ./paper/scripts/shell/modules/cleanup.sh
# 
# ORIG_DIR="$(pwd)"
# THIS_DIR="$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)"
# LOG_PATH="$THIS_DIR/.$(basename $0).log"
# echo > "$LOG_PATH"
# 
# GIT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null)"
# 
# GRAY='\033[0;90m'
# GREEN='\033[0;32m'
# YELLOW='\033[0;33m'
# RED='\033[0;31m'
# NC='\033[0m' # No Color
# 
# echo_info() { echo -e "${GRAY}INFO: $1${NC}"; }
# log_info() {
#     if [ "${SCITEX_LOG_LEVEL:-1}" -ge 2 ]; then
#         echo -e "  \033[0;90m→ $1\033[0m"
#     fi
# }
# echo_success() { echo -e "${GREEN}SUCC: $1${NC}"; }
# echo_warning() { echo -e "${YELLOW}WARN: $1${NC}"; }
# echo_error() { echo -e "${RED}ERRO: $1${NC}"; }
# echo_header() { echo_info "=== $1 ==="; }
# # ---------------------------------------
# 
# # Configurations
# source ./config/load_config.sh $SCITEX_WRITER_DOC_TYPE
# 
# # Logging
# touch "$LOG_PATH" >/dev/null 2>&1
# echo
# log_info "Running ${BASH_SOURCE[0]}..."
# 
# function cleanup() {
#     # Ensure logging directory
#     mkdir -p $LOG_DIR
# 
#     # Remove all bak files from the repository
#     find "$SCITEX_WRITER_ROOT_DIR" -type f -name "*bak*" -exec rm {} \;
# 
#     # Remove Emacs temporary files
#     find "$SCITEX_WRITER_ROOT_DIR" -type f -name "#*#" -exec rm {} \;
# 
#     # Move files with these extensions to LOG_DIR
#     for ext in log out bbl blg spl dvi toc bak stderr stdout aux fls fdb_latexmk synctex.gz cb cb2; do
#         find "$SCITEX_WRITER_ROOT_DIR" -maxdepth 1 -type f -name "*.$ext" -exec mv {} $LOG_DIR/ \; 2>/dev/null
#     done
#     
#     # Remove progress.log files (from parallel commands)
#     find "$SCITEX_WRITER_ROOT_DIR" -name "progress.log" -type f -delete 2>/dev/null
# 
#     echo_info "    Removing versioned files from current directory..."
#     rm -f *_v*.pdf *_v*.tex 2>/dev/null
# }
# 
# # Main
# cleanup
# 
# # EOF
# --------------------------------------------------------------------------------
# End of Source Code from: /home/ywatanabe/proj/scitex-writer/scripts/shell/modules/cleanup.sh
# --------------------------------------------------------------------------------