MediaImporter / test_runner.sh
Newer Older
1093 lines | 39.583kb
Bogdan Timofte authored 8 months ago
1
#!/bin/bash
2

            
3
# Media Importer Test Runner
4
# Comprehensive testing framework based on Development.md specifications
5

            
6
set -e
7

            
8
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
TEST_DIR="$SCRIPT_DIR/test"
10
SOURCE_DIR="$TEST_DIR/source"
11
DEST_DIR="$TEST_DIR/destination"
12
SAMPLES_DIR="$SCRIPT_DIR/sample"  # Fixed: was 'samples' but should be 'sample'
13
MEDIA_IMPORTER="$SCRIPT_DIR/media-importer.sh"
14
TEST_REPORTS_DIR="$SCRIPT_DIR/test_reports"
15

            
16
# Colors for output
17
RED='\033[0;31m'
18
GREEN='\033[0;32m'
19
YELLOW='\033[1;33m'
20
BLUE='\033[0;34m'
21
NC='\033[0m' # No Color
22

            
23
# Function to print colored output
24
print_color() {
25
    local color="$1"
26
    local message="$2"
27
    echo -e "${color}${message}${NC}"
28
}
29

            
30
# Function to create test directories
31
create_test_dirs() {
32
    print_color "$BLUE" "Creating test directories..."
33
    mkdir -p "$SOURCE_DIR"
34
    mkdir -p "$DEST_DIR"
35
    mkdir -p "$TEST_REPORTS_DIR"
36
}
37

            
38
# Function to clean test directory
39
clean_test_dir() {
40
    print_color "$BLUE" "Cleaning test directory..."
41
    rm -rf "$TEST_DIR"/*
42
}
43

            
44
# Function to copy sample files
45
copy_sample_files() {
46
    local source_pattern="$1"
47
    local target_dir="$2"
48

            
49
    if [[ -d "$SAMPLES_DIR/$source_pattern" ]]; then
50
        # Copy all files recursively from source to target directory
51
        find "$SAMPLES_DIR/$source_pattern" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.tiff" -o -iname "*.tif" -o -iname "*.cr2" -o -iname "*.nef" -o -iname "*.arw" -o -iname "*.dng" -o -iname "*.raw" -o -iname "*.mp4" -o -iname "*.mov" -o -iname "*.avi" -o -iname "*.mts" -o -iname "*.m2ts" -o -iname "*.mkv" -o -iname "*.wmv" -o -iname "*.3gp" -o -iname "*.m4v" \) -exec cp {} "$target_dir/" \; 2>/dev/null || true
52
        print_color "$GREEN" "Copied $source_pattern files to $target_dir"
53
    else
54
        print_color "$YELLOW" "Warning: $SAMPLES_DIR/$source_pattern not found. Path: $SAMPLES_DIR/$source_pattern"
55
    fi
56
}
57

            
58
# Function to capture directory state
59
capture_state() {
60
    local dir_path="$1"
61
    local output_file="$2"
62
    local label="$3"
63

            
64
    print_color "$BLUE" "Capturing $label directory state..."
65
    if [[ -d "$dir_path" ]]; then
66
        find "$dir_path" -type f | sort > "$output_file"
67
    else
68
        echo "# Directory does not exist or is empty" > "$output_file"
69
    fi
70
}
71

            
72
# Function to run test command and capture output
73
run_test_command() {
74
    local command="$1"
75
    local log_file="$2"
76

            
77
    print_color "$YELLOW" "Executing: $command"
78
    echo "$command" > "$log_file"
79
    echo "" >> "$log_file"
80
    echo "=== SCRIPT OUTPUT ===" >> "$log_file"
81

            
82
    # Run command and capture both stdout and stderr
83
    if eval "$command" >> "$log_file" 2>&1; then
84
        echo "" >> "$log_file"
85
        echo "=== COMMAND COMPLETED SUCCESSFULLY ===" >> "$log_file"
86
        return 0
87
    else
88
        echo "" >> "$log_file"
89
        echo "=== COMMAND FAILED ===" >> "$log_file"
90
        return 1
91
    fi
92
}
93

            
94
# Function to generate test report
95
generate_test_report() {
96
    local test_name="$1"
97
    local scenario="$2"
98
    local objective="$3"
99
    local files_used="$4"
100
    local command="$5"
101
    local result_status="$6"
102

            
103
    # Determine success/failure prefix
104
    local status_prefix
105
    if [[ $result_status -eq 0 ]]; then
106
        status_prefix="s"
107
    else
108
        status_prefix="f"
109
    fi
110

            
111
    # Format date as YYYYMMDD
112
    local date_stamp=$(date '+%Y%m%d')
113

            
114
    # Create filename with new format: [s|f]_date_restul_numelei
115
    local report_file="$TEST_REPORTS_DIR/${status_prefix}_${date_stamp}_${test_name}.md"
116

            
117
    print_color "$BLUE" "Generating test report: $report_file"
118

            
119
    cat > "$report_file" << EOF
120
# Test Report: $test_name
121

            
122
## Test Information
123
- **Date**: $(date)
124
- **Scenario**: $scenario
125
- **Objective**: $objective
126
- **Files Used**: $files_used
127

            
128
## Pre-Test State
129
### Source Directory Structure
130
\`\`\`
131
$(cat "$TEST_DIR/source_before.txt" 2>/dev/null || echo "# No pre-test source state captured")
132
\`\`\`
133

            
134
### Destination Directory Structure
135
\`\`\`
136
$(cat "$TEST_DIR/dest_before.txt" 2>/dev/null || echo "# No pre-test destination state captured")
137
\`\`\`
138

            
139
## Test Execution
140
### Command Used
141
\`\`\`bash
142
$command
143
\`\`\`
144

            
145
### Script Output
146
\`\`\`
147
$(cat "$TEST_DIR/import_log.txt" 2>/dev/null || echo "# No script output captured")
148
\`\`\`
149

            
150
## Post-Test State
151
### Source Directory Structure
152
\`\`\`
153
$(cat "$TEST_DIR/source_after.txt" 2>/dev/null || echo "# No post-test source state captured")
154
\`\`\`
155

            
156
### Destination Directory Structure
157
\`\`\`
158
$(cat "$TEST_DIR/dest_after.txt" 2>/dev/null || echo "# No post-test destination state captured")
159
\`\`\`
160

            
161
## Analysis and Verification
162
### Expected Results
163
- Files should be processed according to the test scenario
164
- No data loss should occur
165
- Proper error handling for edge cases
166

            
167
### Actual Results
168
- Test execution completed with status: $result_status
169

            
170
### Issues Found
171
- [ ] No issues detected
172
- [ ] Issues found (see notes below)
173

            
174
### Protections Verified
175
- [ ] Destination exclusion working
176
- [ ] Move confirmation functional
177
- [ ] No data loss detected
178
- [ ] UTC conversion correct (for QuickTime files)
179
- [ ] Unimportable files handling (if applicable)
180

            
181
## Conclusion
182
### Test Result
183
- [ ] PASSED
184
- [ ] FAILED
185
- [ ] PARTIAL (with notes)
186

            
187
### Notes
188
Test completed as per Development.md specifications.
189

            
190
### Files Generated
191
- \`test/source_before.txt\` - Pre-test source structure
192
- \`test/dest_before.txt\` - Pre-test destination structure
193
- \`test/source_after.txt\` - Post-test source structure
194
- \`test/dest_after.txt\` - Post-test destination structure
195
- \`test/import_log.txt\` - Full script execution log
196
- \`test/test_report.md\` - This report
197
EOF
198

            
199
    print_color "$GREEN" "Test report generated: $report_file"
200

            
201
    # Clean up old reports, keeping only the last 10
202
    cleanup_old_reports
203
}
204

            
205
# Function to clean up old test reports, keeping only the last 10
206
cleanup_old_reports() {
207
    if [[ -d "$TEST_REPORTS_DIR" ]]; then
208
        # Count total reports
Bogdan Timofte authored 3 weeks ago
209
        local total_reports
210
        total_reports=$(find "$TEST_REPORTS_DIR" -name "*.md" | wc -l | tr -d ' ')
Bogdan Timofte authored 8 months ago
211

            
212
        if [[ $total_reports -gt 10 ]]; then
213
            print_color "$BLUE" "Cleaning up old test reports (keeping last 10)..."
214

            
Bogdan Timofte authored 3 weeks ago
215
            local remove_count
216
            remove_count=$((total_reports - 10))
217

            
218
            find "$TEST_REPORTS_DIR" -name "*.md" -type f | while IFS= read -r report_file; do
219
                local report_mtime
220
                if report_mtime=$(stat -f %m "$report_file" 2>/dev/null); then
221
                    :
222
                else
223
                    report_mtime=$(stat -c %Y "$report_file" 2>/dev/null || echo 0)
224
                fi
225
                printf '%s\t%s\n' "$report_mtime" "$report_file"
226
            done | sort -n | head -n "$remove_count" | cut -f2- | while IFS= read -r old_report; do
227
                rm -f "$old_report"
228
            done
229

            
230
            local remaining
231
            remaining=$(find "$TEST_REPORTS_DIR" -name "*.md" | wc -l | tr -d ' ')
Bogdan Timofte authored 8 months ago
232
            print_color "$GREEN" "Kept $remaining most recent test reports"
233
        fi
234
    fi
235
}
236

            
237
# Test Case 0: Basic Functionality Test
238
run_basic_functionality_test() {
239
    print_color "$GREEN" "=== Running Test 0: Basic Functionality Test ==="
240

            
241
    clean_test_dir
242
    create_test_dirs
243

            
244
    # Setup test files
245
    copy_sample_files "media/sortable" "$SOURCE_DIR"
246

            
247
    # Capture pre-test state
248
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
249
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
250

            
251
    # Run test
252
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" -v"
253
    local result=0
254
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
255

            
256
    # Capture post-test state
257
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
258
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
259

            
260
    # Generate report
261
    generate_test_report \
262
        "Basic_Functionality" \
263
        "Processing files with valid EXIF data" \
264
        "Verify correct sorting and organization of media files" \
265
        "Sample media files with EXIF data from samples/media/sortable/" \
266
        "$command" \
267
        "$result"
268
}
269

            
270
# Test Case 1: Unimportable Files Test
271
run_unimportable_files_test() {
272
    print_color "$GREEN" "=== Running Test 1: Unimportable Files Test ==="
273

            
274
    clean_test_dir
275
    create_test_dirs
276

            
277
    # Setup test files - mix of sortable and unimportable
278
    copy_sample_files "media/sortable" "$SOURCE_DIR"
279
    copy_sample_files "media/unimportable" "$SOURCE_DIR"
280

            
281
    # Capture pre-test state
282
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
283
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
284

            
285
    # Run test (without --collect-unimportable flag)
286
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" -v"
287
    local result=0
288
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
289

            
290
    # Capture post-test state
291
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
292
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
293

            
294
    # Generate report
295
    generate_test_report \
296
        "Unimportable_Files_Handling" \
297
        "Testing files without EXIF data in root and subfolders" \
298
        "Verify proper handling of unimportable files without collection flag" \
299
        "Mixed sortable and unimportable files from samples/media/" \
300
        "$command" \
301
        "$result"
302
}
303

            
304
# Test Case 2: Mixed Content Test
305
run_mixed_content_test() {
306
    print_color "$GREEN" "=== Running Test 2: Mixed Content Test ==="
307

            
308
    clean_test_dir
309
    create_test_dirs
310

            
311
    # Setup separate folders for sortable vs unimportable
312
    mkdir -p "$SOURCE_DIR/sortable" "$SOURCE_DIR/unimportable"
313
    copy_sample_files "media/sortable" "$SOURCE_DIR/sortable"
314
    copy_sample_files "media/unimportable" "$SOURCE_DIR/unimportable"
315

            
316
    # Capture pre-test state
317
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
318
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
319

            
320
    # Run test
321
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" -v"
322
    local result=0
323
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
324

            
325
    # Capture post-test state
326
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
327
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
328

            
329
    # Generate report
330
    generate_test_report \
331
        "Mixed_Content" \
332
        "Processing sortable and unimportable files in separate folders" \
333
        "Verify cleanup behavior for folders with different file types" \
334
        "Separate folders: sortable/ and unimportable/ with respective file types" \
335
        "$command" \
336
        "$result"
337
}
338

            
339
# Test Case 3: Safety Protections Test
340
run_safety_protections_test() {
341
    print_color "$GREEN" "=== Running Test 3: Safety Protections Test ==="
342

            
343
    clean_test_dir
344
    create_test_dirs
345

            
346
    # Setup test files
347
    copy_sample_files "media/sortable" "$SOURCE_DIR"
348

            
349
    # Create a file in destination to test exclusion
350
    echo "test file" > "$DEST_DIR/test.txt"
351

            
352
    # Capture pre-test state
353
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
354
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
355

            
356
    # Run test
357
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" -v"
358
    local result=0
359
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
360

            
361
    # Capture post-test state
362
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
363
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
364

            
365
    # Generate report
366
    generate_test_report \
367
        "Safety_Protections" \
368
        "Testing destination exclusion and move confirmation" \
369
        "Verify data integrity protections prevent data loss" \
370
        "Sample files with pre-existing destination content" \
371
        "$command" \
372
        "$result"
373
}
374

            
375
# Test Case 4: UTC Conversion Test
376
run_utc_conversion_test() {
377
    print_color "$GREEN" "=== Running Test 4: UTC Conversion Test ==="
378

            
379
    clean_test_dir
380
    create_test_dirs
381

            
382
    # Setup test files (assuming QuickTime files are available)
383
    copy_sample_files "media/sortable" "$SOURCE_DIR"
384

            
385
    # Capture pre-test state
386
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
387
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
388

            
389
    # Run test
390
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" -v"
391
    local result=0
392
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
393

            
394
    # Capture post-test state
395
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
396
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
397

            
398
    # Generate report
399
    generate_test_report \
400
        "UTC_Conversion" \
401
        "Testing UTC timestamp conversion for QuickTime files" \
402
        "Verify correct UTC to local time conversion" \
403
        "QuickTime/Apple media files with UTC timestamps" \
404
        "$command" \
405
        "$result"
406
}
407

            
408
# Test Case 5: Subdirectory Processing Test
409
run_subdirectory_processing_test() {
410
    print_color "$GREEN" "=== Running Test 5: Subdirectory Processing Test ==="
411

            
412
    clean_test_dir
413
    create_test_dirs
414

            
415
    # Create nested directory structure
416
    mkdir -p "$SOURCE_DIR/level1/level2"
417
    copy_sample_files "media/sortable" "$SOURCE_DIR/level1/level2"
418

            
419
    # Capture pre-test state
420
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
421
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
422

            
423
    # Run test
424
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" -v"
425
    local result=0
426
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
427

            
428
    # Capture post-test state
429
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
430
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
431

            
432
    # Generate report
433
    generate_test_report \
434
        "Subdirectory_Processing" \
435
        "Testing processing of files in nested subdirectories" \
436
        "Verify recursive file discovery and processing" \
437
        "Files in nested directory structure (level1/level2/)" \
438
        "$command" \
439
        "$result"
440
}
441

            
442
# Test Case 6: Keep Empty Directories Test
443
run_keep_empty_dirs_test() {
444
    print_color "$GREEN" "=== Running Test 6: Keep Empty Directories Test ==="
445

            
446
    clean_test_dir
447
    create_test_dirs
448

            
449
    # Create directory structure with some empty dirs
450
    mkdir -p "$SOURCE_DIR/sortable" "$SOURCE_DIR/empty1" "$SOURCE_DIR/empty2"
451
    copy_sample_files "media/sortable" "$SOURCE_DIR/sortable"
452

            
453
    # Capture pre-test state
454
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
455
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
456

            
457
    # Run test with --keep-empty-dirs
458
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" --keep-empty-dirs -v"
459
    local result=0
460
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
461

            
462
    # Capture post-test state
463
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
464
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
465

            
466
    # Generate report
467
    generate_test_report \
468
        "Keep_Empty_Directories" \
469
        "Testing --keep-empty-dirs functionality" \
470
        "Verify empty directory preservation when flag is used" \
471
        "Directory structure with sortable files and empty directories" \
472
        "$command" \
473
        "$result"
474
}
475

            
476
# Test Case 7: Source Only Test
477
run_source_only_test() {
478
    print_color "$GREEN" "=== Running Test 7: Source Only Test ==="
479

            
480
    clean_test_dir
481
    create_test_dirs
482

            
483
    # Setup test files
484
    copy_sample_files "media/sortable" "$SOURCE_DIR"
485

            
486
    # Capture pre-test state
487
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
488
    capture_state "$SOURCE_DIR/sorted" "$TEST_DIR/dest_before.txt" "auto-destination"
489

            
490
    # Run test with only source parameter
491
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -v"
492
    local result=0
493
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
494

            
495
    # Capture post-test state
496
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
497
    capture_state "$SOURCE_DIR/sorted" "$TEST_DIR/dest_after.txt" "auto-destination"
498

            
499
    # Generate report
500
    generate_test_report \
501
        "Source_Only_Test" \
502
        "Testing processing with only source parameter" \
503
        "Verify automatic creation of sorted subdirectory" \
504
        "Sample media files, no explicit destination specified" \
505
        "$command" \
506
        "$result"
507
}
508

            
Bogdan Timofte authored 3 weeks ago
509
# Test Case 8: Destination Inside Source Test
510
run_destination_inside_source_test() {
511
    print_color "$GREEN" "=== Running Test 8: Destination Inside Source Test ==="
512

            
513
    clean_test_dir
514
    create_test_dirs
515

            
516
    # Setup test files
517
    copy_sample_files "media/sortable" "$SOURCE_DIR"
518

            
519
    # Capture pre-test state
520
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
521
    capture_state "$SOURCE_DIR/sorted" "$TEST_DIR/dest_before.txt" "destination-inside-source"
522

            
523
    # Run test with destination explicitly inside source
524
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$SOURCE_DIR/sorted\" -v"
525
    local result=0
526
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
527

            
528
    # Guard 1: no files should remain outside sorted for sortable-only dataset
529
    local outside_count
530
    outside_count=$(find "$SOURCE_DIR" -type f ! -path "$SOURCE_DIR/sorted/*" | wc -l | tr -d ' ')
531
    if [[ "$outside_count" != "0" ]]; then
532
        echo "Destination exclusion check failed: found $outside_count file(s) outside sorted" >> "$TEST_DIR/import_log.txt"
533
        result=1
534
    fi
535

            
536
    # Guard 2: destination exclusion should prevent sorted/sorted recursion
537
    local recursive_sorted_count
538
    recursive_sorted_count=$(find "$SOURCE_DIR/sorted" -type d -path "*/sorted/sorted*" 2>/dev/null | wc -l | tr -d ' ')
539
    if [[ "$recursive_sorted_count" != "0" ]]; then
540
        echo "Destination recursion check failed: found nested sorted/sorted directories" >> "$TEST_DIR/import_log.txt"
541
        result=1
542
    fi
543

            
544
    # Capture post-test state
545
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
546
    capture_state "$SOURCE_DIR/sorted" "$TEST_DIR/dest_after.txt" "destination-inside-source"
547

            
548
    # Generate report
549
    generate_test_report \
550
        "Destination_Inside_Source" \
551
        "Testing explicit destination inside source directory" \
552
        "Verify destination exclusion and no sorted/sorted recursion" \
553
        "Sortable sample media with destination set to source/sorted" \
554
        "$command" \
555
        "$result"
556
}
557

            
558
# Test Case 9: Verify Mode Test
559
run_verify_mode_test() {
560
    print_color "$GREEN" "=== Running Test 9: Verify Mode Test ==="
561

            
562
    clean_test_dir
563
    create_test_dirs
564

            
565
    # Setup test files
566
    copy_sample_files "media/sortable" "$SOURCE_DIR"
567

            
568
    # Capture pre-test state
569
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
570
    capture_state "$SOURCE_DIR/sorted" "$TEST_DIR/dest_before.txt" "auto-destination"
571

            
572
    local log_file="$TEST_DIR/import_log.txt"
573
    local result=0
574
    : > "$log_file"
575

            
576
    local command_default="cd \"$SOURCE_DIR\" && \"$MEDIA_IMPORTER\" --dry-run"
577
    local command_strict="cd \"$SOURCE_DIR\" && \"$MEDIA_IMPORTER\" --dry-run --verify-mode strict"
578
    local command="$command_default && $command_strict"
579

            
580
    echo "$command_default" >> "$log_file"
581
    echo "" >> "$log_file"
582
    echo "=== DEFAULT VERIFY MODE OUTPUT ===" >> "$log_file"
583
    if eval "$command_default" >> "$log_file" 2>&1; then
584
        if ! grep -q "Verify mode:[[:space:]]*size" "$log_file"; then
585
            echo "Expected default verify mode 'size' not found in output" >> "$log_file"
586
            result=1
587
        fi
588
    else
589
        result=1
590
    fi
591

            
592
    echo "" >> "$log_file"
593
    echo "$command_strict" >> "$log_file"
594
    echo "" >> "$log_file"
595
    echo "=== STRICT VERIFY MODE OUTPUT ===" >> "$log_file"
596
    if eval "$command_strict" >> "$log_file" 2>&1; then
597
        if ! grep -q "Verify mode:[[:space:]]*strict" "$log_file"; then
598
            echo "Expected strict verify mode not found in output" >> "$log_file"
599
            result=1
600
        fi
601
    else
602
        result=1
603
    fi
604

            
605
    if [[ $result -eq 0 ]]; then
606
        echo "" >> "$log_file"
607
        echo "=== COMMAND COMPLETED SUCCESSFULLY ===" >> "$log_file"
608
    else
609
        echo "" >> "$log_file"
610
        echo "=== COMMAND FAILED ===" >> "$log_file"
611
    fi
612

            
613
    # Capture post-test state
614
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
615
    capture_state "$SOURCE_DIR/sorted" "$TEST_DIR/dest_after.txt" "auto-destination"
616

            
617
    # Generate report
618
    generate_test_report \
619
        "Verify_Mode" \
620
        "Testing verify-mode defaults and strict override" \
621
        "Verify default mode is size and strict mode is accepted" \
622
        "Sample sortable media in source-only dry-run mode" \
623
        "$command" \
624
        "$result"
625
}
626

            
Bogdan Timofte authored 3 weeks ago
627
# Test Case 10: Timestamp Collision No-Overwrite Test
628
run_timestamp_collision_no_overwrite_test() {
629
    print_color "$GREEN" "=== Running Test 10: Timestamp Collision No-Overwrite Test ==="
630

            
631
    clean_test_dir
632
    create_test_dirs
633

            
634
    local log_file="$TEST_DIR/import_log.txt"
635
    local result=0
636
    : > "$log_file"
637

            
638
    if ! command -v ffmpeg >/dev/null 2>&1; then
639
        echo "ffmpeg is required for this regression test" >> "$log_file"
640
        result=1
641
    elif ! command -v exiftool >/dev/null 2>&1; then
642
        echo "exiftool is required for this regression test" >> "$log_file"
643
        result=1
644
    else
645
        ffmpeg -hide_banner -loglevel error -f lavfi -i color=c=blue:s=160x120:d=1 -c:v libx264 -pix_fmt yuv420p "$SOURCE_DIR/GX011621.MP4" >> "$log_file" 2>&1 || result=1
646
        ffmpeg -hide_banner -loglevel error -f lavfi -i color=c=red:s=160x120:d=1 -c:v libx264 -pix_fmt yuv420p "$SOURCE_DIR/GX021621.MP4" >> "$log_file" 2>&1 || result=1
647
        ffmpeg -hide_banner -loglevel error -f lavfi -i color=c=green:s=160x120:d=1 -c:v libx264 -pix_fmt yuv420p "$SOURCE_DIR/GX031621.MP4" >> "$log_file" 2>&1 || result=1
648
        exiftool -overwrite_original -CreateDate="2026:05:15 19:20:09" "$SOURCE_DIR/GX011621.MP4" "$SOURCE_DIR/GX021621.MP4" "$SOURCE_DIR/GX031621.MP4" >> "$log_file" 2>&1 || result=1
649
        touch -t 202605151920.09 "$SOURCE_DIR/GX011621.MP4" "$SOURCE_DIR/GX021621.MP4" "$SOURCE_DIR/GX031621.MP4" || result=1
650
    fi
651

            
652
    # Capture pre-test state
653
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
654
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
655

            
656
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" --verify-mode size -v"
657
    if [[ $result -eq 0 ]]; then
658
        run_test_command "$command" "$log_file" || result=$?
659
    fi
660

            
661
    local dest_count
662
    dest_count=$(find "$DEST_DIR" -type f -iname "*.mp4" | wc -l | tr -d ' ')
663
    if [[ "$dest_count" != "3" ]]; then
664
        echo "Expected 3 destination MP4 files after timestamp collision import, found $dest_count" >> "$log_file"
665
        result=1
666
    fi
667

            
668
    local source_count
669
    source_count=$(find "$SOURCE_DIR" -type f -iname "*.mp4" | wc -l | tr -d ' ')
670
    if [[ "$source_count" != "0" ]]; then
671
        echo "Expected source MP4 files to be moved, found $source_count remaining" >> "$log_file"
672
        result=1
673
    fi
674

            
675
    local unique_names
676
    unique_names=$(find "$DEST_DIR" -type f -iname "*.mp4" -exec basename {} \; | sort -u | wc -l | tr -d ' ')
677
    if [[ "$unique_names" != "3" ]]; then
678
        echo "Expected 3 unique destination filenames, found $unique_names" >> "$log_file"
679
        result=1
680
    fi
681

            
682
    local expected_base="$DEST_DIR/2026-05-15/2026-05-15_19-20-09.mp4"
683
    local expected_suffix_1="$DEST_DIR/2026-05-15/2026-05-15_19-20-09_1.mp4"
684
    local expected_suffix_2="$DEST_DIR/2026-05-15/2026-05-15_19-20-09_2.mp4"
685
    if [[ ! -f "$expected_base" || ! -f "$expected_suffix_1" || ! -f "$expected_suffix_2" ]]; then
686
        echo "Expected unattended numeric conflict suffixes _1 and _2 were not created" >> "$log_file"
687
        result=1
688
    fi
689

            
690
    local legacy_suffix_count
691
    legacy_suffix_count=$(find "$DEST_DIR" -type f -name "*__GX*.mp4" | wc -l | tr -d ' ')
692
    if [[ "$legacy_suffix_count" != "0" ]]; then
693
        echo "Expected no legacy original-name conflict suffixes, found $legacy_suffix_count" >> "$log_file"
694
        result=1
695
    fi
696

            
697
    # Capture post-test state
698
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
699
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
700

            
701
    # Generate report
702
    generate_test_report \
703
        "Timestamp_Collision_No_Overwrite" \
704
        "Processing multiple GoPro-style chapters with identical CreateDate values" \
705
        "Verify timestamp filename collisions do not overwrite prior imports or delete sources" \
706
        "Synthetic MP4 files with identical QuickTime CreateDate metadata" \
707
        "$command" \
708
        "$result"
709
}
710

            
711
# Test Case 11: GoPro Sidecar Metadata Sync Test
712
run_gopro_sidecar_metadata_sync_test() {
713
    print_color "$GREEN" "=== Running Test 11: GoPro Sidecar Metadata Sync Test ==="
714

            
715
    clean_test_dir
716
    create_test_dirs
717

            
718
    local log_file="$TEST_DIR/import_log.txt"
719
    local result=0
720
    : > "$log_file"
721

            
722
    if ! command -v ffmpeg >/dev/null 2>&1; then
723
        echo "ffmpeg is required for this regression test" >> "$log_file"
724
        result=1
725
    elif ! command -v exiftool >/dev/null 2>&1; then
726
        echo "exiftool is required for this regression test" >> "$log_file"
727
        result=1
728
    else
729
        ffmpeg -hide_banner -loglevel error -f lavfi -i color=c=blue:s=160x120:d=1 -c:v libx264 -pix_fmt yuv420p "$SOURCE_DIR/GX011622.MP4" >> "$log_file" 2>&1 || result=1
730
        ffmpeg -hide_banner -loglevel error -f lavfi -i color=c=red:s=160x120:d=1 -c:v libx264 -pix_fmt yuv420p "$SOURCE_DIR/GX021622.MP4" >> "$log_file" 2>&1 || result=1
731
        ffmpeg -hide_banner -loglevel error -f lavfi -i color=c=green:s=160x120:d=1 -c:v libx264 -pix_fmt yuv420p "$SOURCE_DIR/GX031622.MP4" >> "$log_file" 2>&1 || result=1
732
        ffmpeg -hide_banner -loglevel error -f lavfi -i color=c=yellow:s=160x120:d=1 -c:v libx264 -pix_fmt yuv420p "$SOURCE_DIR/GX041622.MP4" >> "$log_file" 2>&1 || result=1
733
        exiftool -overwrite_original -QuickTime:CreateDate="2026:05:16 19:03:19" "$SOURCE_DIR/GX011622.MP4" "$SOURCE_DIR/GX021622.MP4" "$SOURCE_DIR/GX031622.MP4" "$SOURCE_DIR/GX041622.MP4" >> "$log_file" 2>&1 || result=1
734
        touch -t 202605161903.20 "$SOURCE_DIR/GX011622.THM" || result=1
735
        touch -t 202605161915.08 "$SOURCE_DIR/GX021622.THM" || result=1
736
        touch -t 202605161926.56 "$SOURCE_DIR/GX031622.LRV" || result=1
737
        touch -t 202605161938.44 "$SOURCE_DIR/GX041622.MP4" || result=1
738
    fi
739

            
740
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
741
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
742

            
743
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" --verify-mode size -v"
744
    if [[ $result -eq 0 ]]; then
745
        run_test_command "$command" "$log_file" || result=$?
746
    fi
747

            
748
    local first_dest="$DEST_DIR/2026-05-16/2026-05-16_19-03-20.mp4"
749
    local second_dest="$DEST_DIR/2026-05-16/2026-05-16_19-15-08.mp4"
750
    local third_dest="$DEST_DIR/2026-05-16/2026-05-16_19-26-56.mp4"
751
    local fourth_dest="$DEST_DIR/2026-05-16/2026-05-16_19-38-44.mp4"
752
    if [[ ! -f "$first_dest" || ! -f "$second_dest" || ! -f "$third_dest" || ! -f "$fourth_dest" ]]; then
753
        echo "Expected GoPro filesystem-based destination filenames were not created" >> "$log_file"
754
        result=1
755
    fi
756

            
757
    local first_metadata second_metadata third_metadata fourth_metadata
758
    if [[ -f "$first_dest" ]]; then
759
        first_metadata=$(exiftool -api QuickTimeUTC=0 -s -s -s -QuickTime:CreateDate "$first_dest" 2>/dev/null | head -1)
760
        if [[ "$first_metadata" != "2026:05:16 19:03:20" ]]; then
761
            echo "Expected first imported metadata CreateDate 2026:05:16 19:03:20, got ${first_metadata:-none}" >> "$log_file"
762
            result=1
763
        fi
764
    fi
765
    if [[ -f "$third_dest" ]]; then
766
        third_metadata=$(exiftool -api QuickTimeUTC=0 -s -s -s -QuickTime:CreateDate "$third_dest" 2>/dev/null | head -1)
767
        if [[ "$third_metadata" != "2026:05:16 19:26:56" ]]; then
768
            echo "Expected third imported metadata CreateDate 2026:05:16 19:26:56, got ${third_metadata:-none}" >> "$log_file"
769
            result=1
770
        fi
771
    fi
772
    if [[ -f "$fourth_dest" ]]; then
773
        fourth_metadata=$(exiftool -api QuickTimeUTC=0 -s -s -s -QuickTime:CreateDate "$fourth_dest" 2>/dev/null | head -1)
774
        if [[ "$fourth_metadata" != "2026:05:16 19:38:44" ]]; then
775
            echo "Expected fourth imported metadata CreateDate 2026:05:16 19:38:44, got ${fourth_metadata:-none}" >> "$log_file"
776
            result=1
777
        fi
778
    fi
779
    if [[ -f "$second_dest" ]]; then
780
        second_metadata=$(exiftool -api QuickTimeUTC=0 -s -s -s -QuickTime:CreateDate "$second_dest" 2>/dev/null | head -1)
781
        if [[ "$second_metadata" != "2026:05:16 19:15:08" ]]; then
782
            echo "Expected second imported metadata CreateDate 2026:05:16 19:15:08, got ${second_metadata:-none}" >> "$log_file"
783
            result=1
784
        fi
785
    fi
786

            
787
    local source_count
788
    source_count=$(find "$SOURCE_DIR" -type f -iname "*.mp4" | wc -l | tr -d ' ')
789
    if [[ "$source_count" != "0" ]]; then
790
        echo "Expected GoPro source MP4 files to be moved, found $source_count remaining" >> "$log_file"
791
        result=1
792
    fi
793

            
794
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
795
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
796

            
797
    generate_test_report \
798
        "GoPro_Sidecar_Metadata_Sync" \
799
        "Processing GoPro-style MP4 chapters with THM, LRV, and MP4 filesystem timestamps" \
800
        "Verify GoPro imports use filesystem fallback dates and sync destination metadata automatically" \
801
        "Synthetic GoPro MP4 files with shared QuickTime CreateDate plus THM/LRV/no-sidecar mtime variants" \
802
        "$command" \
803
        "$result"
804
}
805

            
806
# Test Case 12: GoPro No-Sidecar Reimport Test
807
run_gopro_no_sidecar_reimport_test() {
808
    print_color "$GREEN" "=== Running Test 12: GoPro No-Sidecar Reimport Test ==="
809

            
810
    clean_test_dir
811
    create_test_dirs
812

            
813
    local log_file="$TEST_DIR/import_log.txt"
814
    local result=0
815
    : > "$log_file"
816

            
817
    if ! command -v ffmpeg >/dev/null 2>&1; then
818
        echo "ffmpeg is required for this regression test" >> "$log_file"
819
        result=1
820
    elif ! command -v exiftool >/dev/null 2>&1; then
821
        echo "exiftool is required for this regression test" >> "$log_file"
822
        result=1
823
    else
824
        ffmpeg -hide_banner -loglevel error -f lavfi -i color=c=purple:s=160x120:d=1 -c:v libx264 -pix_fmt yuv420p "$SOURCE_DIR/GX051622.MP4" >> "$log_file" 2>&1 || result=1
825
        exiftool -overwrite_original -QuickTime:CreateDate="2026:05:16 19:03:19" "$SOURCE_DIR/GX051622.MP4" >> "$log_file" 2>&1 || result=1
826
        rm -f "$SOURCE_DIR/GX051622.THM" "$SOURCE_DIR/GX051622.thm" "$SOURCE_DIR/GX051622.LRV" "$SOURCE_DIR/GX051622.lrv"
827
        touch -t 202605161950.32 "$SOURCE_DIR/GX051622.MP4" || result=1
828
    fi
829

            
830
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
831
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
832

            
833
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" --verify-mode size -k -v && \"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" --verify-mode size -k -v"
834
    if [[ $result -eq 0 ]]; then
835
        run_test_command "$command" "$log_file" || result=$?
836
    fi
837

            
838
    local first_dest="$DEST_DIR/2026-05-16/2026-05-16_19-50-32.mp4"
839
    local reimport_dest="$DEST_DIR/2026-05-16/2026-05-16_19-50-32_1.mp4"
840
    if [[ ! -f "$first_dest" || ! -f "$reimport_dest" ]]; then
841
        echo "Expected no-sidecar GoPro reimport destinations were not created" >> "$log_file"
842
        result=1
843
    fi
844

            
845
    local dest_count
846
    dest_count=$(find "$DEST_DIR" -type f -iname "*.mp4" | wc -l | tr -d ' ')
847
    if [[ "$dest_count" != "2" ]]; then
848
        echo "Expected 2 destination MP4 files after reimport, found $dest_count" >> "$log_file"
849
        result=1
850
    fi
851

            
852
    local source_count
853
    source_count=$(find "$SOURCE_DIR" -type f -iname "*.mp4" | wc -l | tr -d ' ')
854
    if [[ "$source_count" != "1" ]]; then
855
        echo "Expected source MP4 to remain in keep-originals reimport test, found $source_count" >> "$log_file"
856
        result=1
857
    fi
858

            
859
    local sidecar_count
860
    sidecar_count=$(find "$SOURCE_DIR" -type f \( -iname "*.thm" -o -iname "*.lrv" \) | wc -l | tr -d ' ')
861
    if [[ "$sidecar_count" != "0" ]]; then
862
        echo "Expected no THM/LRV sidecars in no-sidecar test, found $sidecar_count" >> "$log_file"
863
        result=1
864
    fi
865

            
866
    if ! grep -q "Filesystem:GX051622.MP4" "$log_file"; then
867
        echo "Expected date source fallback to Filesystem:GX051622.MP4" >> "$log_file"
868
        result=1
869
    fi
870

            
871
    local first_metadata reimport_metadata
872
    if [[ -f "$first_dest" ]]; then
873
        first_metadata=$(exiftool -api QuickTimeUTC=0 -s -s -s -QuickTime:CreateDate "$first_dest" 2>/dev/null | head -1)
874
        if [[ "$first_metadata" != "2026:05:16 19:50:32" ]]; then
875
            echo "Expected first import metadata CreateDate 2026:05:16 19:50:32, got ${first_metadata:-none}" >> "$log_file"
876
            result=1
877
        fi
878
    fi
879
    if [[ -f "$reimport_dest" ]]; then
880
        reimport_metadata=$(exiftool -api QuickTimeUTC=0 -s -s -s -QuickTime:CreateDate "$reimport_dest" 2>/dev/null | head -1)
881
        if [[ "$reimport_metadata" != "2026:05:16 19:50:32" ]]; then
882
            echo "Expected reimport metadata CreateDate 2026:05:16 19:50:32, got ${reimport_metadata:-none}" >> "$log_file"
883
            result=1
884
        fi
885
    fi
886

            
887
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
888
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
889

            
890
    generate_test_report \
891
        "GoPro_No_Sidecar_Reimport" \
892
        "Importing and reimporting a GoPro MP4 with no THM/LRV sidecars" \
893
        "Verify MP4 filesystem mtime fallback, metadata sync, and numeric suffix on reimport" \
894
        "Synthetic GoPro MP4 with no sidecars and wrong QuickTime metadata" \
895
        "$command" \
896
        "$result"
897
}
898

            
Bogdan Timofte authored 8 months ago
899
# Function to show menu
900
show_menu() {
901
    echo ""
902
    print_color "$GREEN" "Media Importer Test Runner"
903
    echo "=========================="
904
    echo ""
905
    echo "Available Tests:"
906
    echo "0. Basic Functionality Test"
907
    echo "1. Unimportable Files Test"
908
    echo "2. Mixed Content Test"
909
    echo "3. Safety Protections Test"
910
    echo "4. UTC Conversion Test"
911
    echo "5. Subdirectory Processing Test"
912
    echo "6. Keep Empty Directories Test"
913
    echo "7. Source Only Test"
Bogdan Timofte authored 3 weeks ago
914
    echo "8. Destination Inside Source Test"
915
    echo "9. Verify Mode Test"
Bogdan Timofte authored 3 weeks ago
916
    echo "10. Timestamp Collision No-Overwrite Test"
917
    echo "11. GoPro Sidecar Metadata Sync Test"
918
    echo "12. GoPro No-Sidecar Reimport Test"
919
    echo "13. Run All Tests"
Bogdan Timofte authored 8 months ago
920
    echo "q. Quit"
921
    echo ""
Bogdan Timofte authored 3 weeks ago
922
    echo -n "Select test to run (0-13, q to quit): "
Bogdan Timofte authored 8 months ago
923
}
924

            
925
# Function to run all tests
926
run_all_tests() {
927
    print_color "$GREEN" "Running all tests sequentially..."
928

            
929
    run_basic_functionality_test
930
    echo ""
931
    run_unimportable_files_test
932
    echo ""
933
    run_mixed_content_test
934
    echo ""
935
    run_safety_protections_test
936
    echo ""
937
    run_utc_conversion_test
938
    echo ""
939
    run_subdirectory_processing_test
940
    echo ""
941
    run_keep_empty_dirs_test
942
    echo ""
943
    run_source_only_test
Bogdan Timofte authored 3 weeks ago
944
    echo ""
945
    run_destination_inside_source_test
946
    echo ""
947
    run_verify_mode_test
Bogdan Timofte authored 3 weeks ago
948
    echo ""
949
    run_timestamp_collision_no_overwrite_test
950
    echo ""
951
    run_gopro_sidecar_metadata_sync_test
952
    echo ""
953
    run_gopro_no_sidecar_reimport_test
Bogdan Timofte authored 8 months ago
954

            
955
    print_color "$GREEN" "All tests completed!"
956
}
957

            
958
# Main menu loop
959
main() {
960
    while true; do
961
        show_menu
962
        read -r choice
963

            
964
        case $choice in
965
            0)
966
                run_basic_functionality_test
967
                ;;
968
            1)
969
                run_unimportable_files_test
970
                ;;
971
            2)
972
                run_mixed_content_test
973
                ;;
974
            3)
975
                run_safety_protections_test
976
                ;;
977
            4)
978
                run_utc_conversion_test
979
                ;;
980
            5)
981
                run_subdirectory_processing_test
982
                ;;
983
            6)
984
                run_keep_empty_dirs_test
985
                ;;
986
            7)
987
                run_source_only_test
988
                ;;
989
            8)
Bogdan Timofte authored 3 weeks ago
990
                run_destination_inside_source_test
991
                ;;
992
            9)
993
                run_verify_mode_test
994
                ;;
995
            10)
Bogdan Timofte authored 3 weeks ago
996
                run_timestamp_collision_no_overwrite_test
997
                ;;
998
            11)
999
                run_gopro_sidecar_metadata_sync_test
1000
                ;;
1001
            12)
1002
                run_gopro_no_sidecar_reimport_test
1003
                ;;
1004
            13)
Bogdan Timofte authored 8 months ago
1005
                run_all_tests
1006
                ;;
1007
            q|Q)
1008
                print_color "$GREEN" "Exiting test runner."
1009
                exit 0
1010
                ;;
1011
            *)
Bogdan Timofte authored 3 weeks ago
1012
                print_color "$RED" "Invalid choice. Please select 0-13 or q to quit."
Bogdan Timofte authored 8 months ago
1013
                ;;
1014
        esac
1015

            
1016
        echo ""
1017
        echo -n "Press Enter to continue..."
1018
        read -r
1019
    done
1020
}
1021

            
1022
# Check if script exists
1023
if [[ ! -f "$MEDIA_IMPORTER" ]]; then
1024
    print_color "$RED" "Error: $MEDIA_IMPORTER not found!"
1025
    exit 1
1026
fi
1027

            
1028
# Check if samples directory exists
1029
if [[ ! -d "$SAMPLES_DIR" ]]; then
1030
    print_color "$YELLOW" "Warning: $SAMPLES_DIR not found. Some tests may not work properly."
1031
fi
1032

            
1033
# Run main menu if no arguments provided
1034
if [[ $# -eq 0 ]]; then
1035
    main
1036
else
1037
    # Handle command line arguments
1038
    case "$1" in
1039
        "basic"|"0")
1040
            run_basic_functionality_test
1041
            ;;
1042
        "unimportable"|"1")
1043
            run_unimportable_files_test
1044
            ;;
1045
        "mixed"|"2")
1046
            run_mixed_content_test
1047
            ;;
1048
        "safety"|"3")
1049
            run_safety_protections_test
1050
            ;;
1051
        "utc"|"4")
1052
            run_utc_conversion_test
1053
            ;;
1054
        "subdir"|"5")
1055
            run_subdirectory_processing_test
1056
            ;;
1057
        "keep-empty"|"6")
1058
            run_keep_empty_dirs_test
1059
            ;;
1060
        "source-only"|"7")
1061
            run_source_only_test
1062
            ;;
Bogdan Timofte authored 3 weeks ago
1063
        "dest-in-source"|"8")
1064
            run_destination_inside_source_test
1065
            ;;
1066
        "verify-mode"|"9")
1067
            run_verify_mode_test
1068
            ;;
Bogdan Timofte authored 3 weeks ago
1069
        "timestamp-collision"|"collision"|"10")
1070
            run_timestamp_collision_no_overwrite_test
1071
            ;;
1072
        "gopro-sidecar-sync"|"gopro-sync"|"11")
1073
            run_gopro_sidecar_metadata_sync_test
1074
            ;;
1075
        "gopro-no-sidecar-reimport"|"gopro-reimport"|"12")
1076
            run_gopro_no_sidecar_reimport_test
1077
            ;;
1078
        "all"|"13")
Bogdan Timofte authored 8 months ago
1079
            run_all_tests
1080
            ;;
1081
        "clean")
1082
            clean_test_dir
1083
            ;;
1084
        "setup")
1085
            create_test_dirs
1086
            ;;
1087
        *)
1088
            print_color "$RED" "Unknown test: $1"
Bogdan Timofte authored 3 weeks ago
1089
            echo "Usage: $0 [basic|unimportable|mixed|safety|utc|subdir|keep-empty|source-only|dest-in-source|verify-mode|timestamp-collision|gopro-sidecar-sync|gopro-no-sidecar-reimport|all|clean|setup] or [0-13]"
Bogdan Timofte authored 8 months ago
1090
            exit 1
1091
            ;;
1092
    esac
1093
fi