MediaImporter / test_runner.sh
Newer Older
1083 lines | 39.143kb
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
209
        local total_reports=$(find "$TEST_REPORTS_DIR" -name "*.md" | wc -l)
210

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

            
214
            # Find and remove oldest reports, keeping the 10 most recent
215
            find "$TEST_REPORTS_DIR" -name "*.md" -type f -printf '%T@ %p\n' | \
216
                sort -n | \
217
                head -n -$((10)) | \
218
                cut -d' ' -f2- | \
219
                xargs -r rm
220

            
221
            local remaining=$(find "$TEST_REPORTS_DIR" -name "*.md" | wc -l)
222
            print_color "$GREEN" "Kept $remaining most recent test reports"
223
        fi
224
    fi
225
}
226

            
227
# Test Case 0: Basic Functionality Test
228
run_basic_functionality_test() {
229
    print_color "$GREEN" "=== Running Test 0: Basic Functionality Test ==="
230

            
231
    clean_test_dir
232
    create_test_dirs
233

            
234
    # Setup test files
235
    copy_sample_files "media/sortable" "$SOURCE_DIR"
236

            
237
    # Capture pre-test state
238
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
239
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
240

            
241
    # Run test
242
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" -v"
243
    local result=0
244
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
245

            
246
    # Capture post-test state
247
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
248
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
249

            
250
    # Generate report
251
    generate_test_report \
252
        "Basic_Functionality" \
253
        "Processing files with valid EXIF data" \
254
        "Verify correct sorting and organization of media files" \
255
        "Sample media files with EXIF data from samples/media/sortable/" \
256
        "$command" \
257
        "$result"
258
}
259

            
260
# Test Case 1: Unimportable Files Test
261
run_unimportable_files_test() {
262
    print_color "$GREEN" "=== Running Test 1: Unimportable Files Test ==="
263

            
264
    clean_test_dir
265
    create_test_dirs
266

            
267
    # Setup test files - mix of sortable and unimportable
268
    copy_sample_files "media/sortable" "$SOURCE_DIR"
269
    copy_sample_files "media/unimportable" "$SOURCE_DIR"
270

            
271
    # Capture pre-test state
272
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
273
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
274

            
275
    # Run test (without --collect-unimportable flag)
276
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" -v"
277
    local result=0
278
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
279

            
280
    # Capture post-test state
281
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
282
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
283

            
284
    # Generate report
285
    generate_test_report \
286
        "Unimportable_Files_Handling" \
287
        "Testing files without EXIF data in root and subfolders" \
288
        "Verify proper handling of unimportable files without collection flag" \
289
        "Mixed sortable and unimportable files from samples/media/" \
290
        "$command" \
291
        "$result"
292
}
293

            
294
# Test Case 2: Mixed Content Test
295
run_mixed_content_test() {
296
    print_color "$GREEN" "=== Running Test 2: Mixed Content Test ==="
297

            
298
    clean_test_dir
299
    create_test_dirs
300

            
301
    # Setup separate folders for sortable vs unimportable
302
    mkdir -p "$SOURCE_DIR/sortable" "$SOURCE_DIR/unimportable"
303
    copy_sample_files "media/sortable" "$SOURCE_DIR/sortable"
304
    copy_sample_files "media/unimportable" "$SOURCE_DIR/unimportable"
305

            
306
    # Capture pre-test state
307
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
308
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
309

            
310
    # Run test
311
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" -v"
312
    local result=0
313
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
314

            
315
    # Capture post-test state
316
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
317
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
318

            
319
    # Generate report
320
    generate_test_report \
321
        "Mixed_Content" \
322
        "Processing sortable and unimportable files in separate folders" \
323
        "Verify cleanup behavior for folders with different file types" \
324
        "Separate folders: sortable/ and unimportable/ with respective file types" \
325
        "$command" \
326
        "$result"
327
}
328

            
329
# Test Case 3: Safety Protections Test
330
run_safety_protections_test() {
331
    print_color "$GREEN" "=== Running Test 3: Safety Protections Test ==="
332

            
333
    clean_test_dir
334
    create_test_dirs
335

            
336
    # Setup test files
337
    copy_sample_files "media/sortable" "$SOURCE_DIR"
338

            
339
    # Create a file in destination to test exclusion
340
    echo "test file" > "$DEST_DIR/test.txt"
341

            
342
    # Capture pre-test state
343
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
344
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
345

            
346
    # Run test
347
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" -v"
348
    local result=0
349
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
350

            
351
    # Capture post-test state
352
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
353
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
354

            
355
    # Generate report
356
    generate_test_report \
357
        "Safety_Protections" \
358
        "Testing destination exclusion and move confirmation" \
359
        "Verify data integrity protections prevent data loss" \
360
        "Sample files with pre-existing destination content" \
361
        "$command" \
362
        "$result"
363
}
364

            
365
# Test Case 4: UTC Conversion Test
366
run_utc_conversion_test() {
367
    print_color "$GREEN" "=== Running Test 4: UTC Conversion Test ==="
368

            
369
    clean_test_dir
370
    create_test_dirs
371

            
372
    # Setup test files (assuming QuickTime files are available)
373
    copy_sample_files "media/sortable" "$SOURCE_DIR"
374

            
375
    # Capture pre-test state
376
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
377
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
378

            
379
    # Run test
380
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" -v"
381
    local result=0
382
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
383

            
384
    # Capture post-test state
385
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
386
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
387

            
388
    # Generate report
389
    generate_test_report \
390
        "UTC_Conversion" \
391
        "Testing UTC timestamp conversion for QuickTime files" \
392
        "Verify correct UTC to local time conversion" \
393
        "QuickTime/Apple media files with UTC timestamps" \
394
        "$command" \
395
        "$result"
396
}
397

            
398
# Test Case 5: Subdirectory Processing Test
399
run_subdirectory_processing_test() {
400
    print_color "$GREEN" "=== Running Test 5: Subdirectory Processing Test ==="
401

            
402
    clean_test_dir
403
    create_test_dirs
404

            
405
    # Create nested directory structure
406
    mkdir -p "$SOURCE_DIR/level1/level2"
407
    copy_sample_files "media/sortable" "$SOURCE_DIR/level1/level2"
408

            
409
    # Capture pre-test state
410
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
411
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
412

            
413
    # Run test
414
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" -v"
415
    local result=0
416
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
417

            
418
    # Capture post-test state
419
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
420
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
421

            
422
    # Generate report
423
    generate_test_report \
424
        "Subdirectory_Processing" \
425
        "Testing processing of files in nested subdirectories" \
426
        "Verify recursive file discovery and processing" \
427
        "Files in nested directory structure (level1/level2/)" \
428
        "$command" \
429
        "$result"
430
}
431

            
432
# Test Case 6: Keep Empty Directories Test
433
run_keep_empty_dirs_test() {
434
    print_color "$GREEN" "=== Running Test 6: Keep Empty Directories Test ==="
435

            
436
    clean_test_dir
437
    create_test_dirs
438

            
439
    # Create directory structure with some empty dirs
440
    mkdir -p "$SOURCE_DIR/sortable" "$SOURCE_DIR/empty1" "$SOURCE_DIR/empty2"
441
    copy_sample_files "media/sortable" "$SOURCE_DIR/sortable"
442

            
443
    # Capture pre-test state
444
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
445
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
446

            
447
    # Run test with --keep-empty-dirs
448
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" --keep-empty-dirs -v"
449
    local result=0
450
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
451

            
452
    # Capture post-test state
453
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
454
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
455

            
456
    # Generate report
457
    generate_test_report \
458
        "Keep_Empty_Directories" \
459
        "Testing --keep-empty-dirs functionality" \
460
        "Verify empty directory preservation when flag is used" \
461
        "Directory structure with sortable files and empty directories" \
462
        "$command" \
463
        "$result"
464
}
465

            
466
# Test Case 7: Source Only Test
467
run_source_only_test() {
468
    print_color "$GREEN" "=== Running Test 7: Source Only Test ==="
469

            
470
    clean_test_dir
471
    create_test_dirs
472

            
473
    # Setup test files
474
    copy_sample_files "media/sortable" "$SOURCE_DIR"
475

            
476
    # Capture pre-test state
477
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
478
    capture_state "$SOURCE_DIR/sorted" "$TEST_DIR/dest_before.txt" "auto-destination"
479

            
480
    # Run test with only source parameter
481
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -v"
482
    local result=0
483
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
484

            
485
    # Capture post-test state
486
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
487
    capture_state "$SOURCE_DIR/sorted" "$TEST_DIR/dest_after.txt" "auto-destination"
488

            
489
    # Generate report
490
    generate_test_report \
491
        "Source_Only_Test" \
492
        "Testing processing with only source parameter" \
493
        "Verify automatic creation of sorted subdirectory" \
494
        "Sample media files, no explicit destination specified" \
495
        "$command" \
496
        "$result"
497
}
498

            
Bogdan Timofte authored 3 weeks ago
499
# Test Case 8: Destination Inside Source Test
500
run_destination_inside_source_test() {
501
    print_color "$GREEN" "=== Running Test 8: Destination Inside Source Test ==="
502

            
503
    clean_test_dir
504
    create_test_dirs
505

            
506
    # Setup test files
507
    copy_sample_files "media/sortable" "$SOURCE_DIR"
508

            
509
    # Capture pre-test state
510
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
511
    capture_state "$SOURCE_DIR/sorted" "$TEST_DIR/dest_before.txt" "destination-inside-source"
512

            
513
    # Run test with destination explicitly inside source
514
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$SOURCE_DIR/sorted\" -v"
515
    local result=0
516
    run_test_command "$command" "$TEST_DIR/import_log.txt" || result=$?
517

            
518
    # Guard 1: no files should remain outside sorted for sortable-only dataset
519
    local outside_count
520
    outside_count=$(find "$SOURCE_DIR" -type f ! -path "$SOURCE_DIR/sorted/*" | wc -l | tr -d ' ')
521
    if [[ "$outside_count" != "0" ]]; then
522
        echo "Destination exclusion check failed: found $outside_count file(s) outside sorted" >> "$TEST_DIR/import_log.txt"
523
        result=1
524
    fi
525

            
526
    # Guard 2: destination exclusion should prevent sorted/sorted recursion
527
    local recursive_sorted_count
528
    recursive_sorted_count=$(find "$SOURCE_DIR/sorted" -type d -path "*/sorted/sorted*" 2>/dev/null | wc -l | tr -d ' ')
529
    if [[ "$recursive_sorted_count" != "0" ]]; then
530
        echo "Destination recursion check failed: found nested sorted/sorted directories" >> "$TEST_DIR/import_log.txt"
531
        result=1
532
    fi
533

            
534
    # Capture post-test state
535
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
536
    capture_state "$SOURCE_DIR/sorted" "$TEST_DIR/dest_after.txt" "destination-inside-source"
537

            
538
    # Generate report
539
    generate_test_report \
540
        "Destination_Inside_Source" \
541
        "Testing explicit destination inside source directory" \
542
        "Verify destination exclusion and no sorted/sorted recursion" \
543
        "Sortable sample media with destination set to source/sorted" \
544
        "$command" \
545
        "$result"
546
}
547

            
548
# Test Case 9: Verify Mode Test
549
run_verify_mode_test() {
550
    print_color "$GREEN" "=== Running Test 9: Verify Mode Test ==="
551

            
552
    clean_test_dir
553
    create_test_dirs
554

            
555
    # Setup test files
556
    copy_sample_files "media/sortable" "$SOURCE_DIR"
557

            
558
    # Capture pre-test state
559
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
560
    capture_state "$SOURCE_DIR/sorted" "$TEST_DIR/dest_before.txt" "auto-destination"
561

            
562
    local log_file="$TEST_DIR/import_log.txt"
563
    local result=0
564
    : > "$log_file"
565

            
566
    local command_default="cd \"$SOURCE_DIR\" && \"$MEDIA_IMPORTER\" --dry-run"
567
    local command_strict="cd \"$SOURCE_DIR\" && \"$MEDIA_IMPORTER\" --dry-run --verify-mode strict"
568
    local command="$command_default && $command_strict"
569

            
570
    echo "$command_default" >> "$log_file"
571
    echo "" >> "$log_file"
572
    echo "=== DEFAULT VERIFY MODE OUTPUT ===" >> "$log_file"
573
    if eval "$command_default" >> "$log_file" 2>&1; then
574
        if ! grep -q "Verify mode:[[:space:]]*size" "$log_file"; then
575
            echo "Expected default verify mode 'size' not found in output" >> "$log_file"
576
            result=1
577
        fi
578
    else
579
        result=1
580
    fi
581

            
582
    echo "" >> "$log_file"
583
    echo "$command_strict" >> "$log_file"
584
    echo "" >> "$log_file"
585
    echo "=== STRICT VERIFY MODE OUTPUT ===" >> "$log_file"
586
    if eval "$command_strict" >> "$log_file" 2>&1; then
587
        if ! grep -q "Verify mode:[[:space:]]*strict" "$log_file"; then
588
            echo "Expected strict verify mode not found in output" >> "$log_file"
589
            result=1
590
        fi
591
    else
592
        result=1
593
    fi
594

            
595
    if [[ $result -eq 0 ]]; then
596
        echo "" >> "$log_file"
597
        echo "=== COMMAND COMPLETED SUCCESSFULLY ===" >> "$log_file"
598
    else
599
        echo "" >> "$log_file"
600
        echo "=== COMMAND FAILED ===" >> "$log_file"
601
    fi
602

            
603
    # Capture post-test state
604
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
605
    capture_state "$SOURCE_DIR/sorted" "$TEST_DIR/dest_after.txt" "auto-destination"
606

            
607
    # Generate report
608
    generate_test_report \
609
        "Verify_Mode" \
610
        "Testing verify-mode defaults and strict override" \
611
        "Verify default mode is size and strict mode is accepted" \
612
        "Sample sortable media in source-only dry-run mode" \
613
        "$command" \
614
        "$result"
615
}
616

            
Bogdan Timofte authored 2 weeks ago
617
# Test Case 10: Timestamp Collision No-Overwrite Test
618
run_timestamp_collision_no_overwrite_test() {
619
    print_color "$GREEN" "=== Running Test 10: Timestamp Collision No-Overwrite Test ==="
620

            
621
    clean_test_dir
622
    create_test_dirs
623

            
624
    local log_file="$TEST_DIR/import_log.txt"
625
    local result=0
626
    : > "$log_file"
627

            
628
    if ! command -v ffmpeg >/dev/null 2>&1; then
629
        echo "ffmpeg is required for this regression test" >> "$log_file"
630
        result=1
631
    elif ! command -v exiftool >/dev/null 2>&1; then
632
        echo "exiftool is required for this regression test" >> "$log_file"
633
        result=1
634
    else
635
        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
636
        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
637
        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
638
        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
639
        touch -t 202605151920.09 "$SOURCE_DIR/GX011621.MP4" "$SOURCE_DIR/GX021621.MP4" "$SOURCE_DIR/GX031621.MP4" || result=1
640
    fi
641

            
642
    # Capture pre-test state
643
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
644
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
645

            
646
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" --verify-mode size -v"
647
    if [[ $result -eq 0 ]]; then
648
        run_test_command "$command" "$log_file" || result=$?
649
    fi
650

            
651
    local dest_count
652
    dest_count=$(find "$DEST_DIR" -type f -iname "*.mp4" | wc -l | tr -d ' ')
653
    if [[ "$dest_count" != "3" ]]; then
654
        echo "Expected 3 destination MP4 files after timestamp collision import, found $dest_count" >> "$log_file"
655
        result=1
656
    fi
657

            
658
    local source_count
659
    source_count=$(find "$SOURCE_DIR" -type f -iname "*.mp4" | wc -l | tr -d ' ')
660
    if [[ "$source_count" != "0" ]]; then
661
        echo "Expected source MP4 files to be moved, found $source_count remaining" >> "$log_file"
662
        result=1
663
    fi
664

            
665
    local unique_names
666
    unique_names=$(find "$DEST_DIR" -type f -iname "*.mp4" -exec basename {} \; | sort -u | wc -l | tr -d ' ')
667
    if [[ "$unique_names" != "3" ]]; then
668
        echo "Expected 3 unique destination filenames, found $unique_names" >> "$log_file"
669
        result=1
670
    fi
671

            
672
    local expected_base="$DEST_DIR/2026-05-15/2026-05-15_19-20-09.mp4"
673
    local expected_suffix_1="$DEST_DIR/2026-05-15/2026-05-15_19-20-09_1.mp4"
674
    local expected_suffix_2="$DEST_DIR/2026-05-15/2026-05-15_19-20-09_2.mp4"
675
    if [[ ! -f "$expected_base" || ! -f "$expected_suffix_1" || ! -f "$expected_suffix_2" ]]; then
676
        echo "Expected unattended numeric conflict suffixes _1 and _2 were not created" >> "$log_file"
677
        result=1
678
    fi
679

            
680
    local legacy_suffix_count
681
    legacy_suffix_count=$(find "$DEST_DIR" -type f -name "*__GX*.mp4" | wc -l | tr -d ' ')
682
    if [[ "$legacy_suffix_count" != "0" ]]; then
683
        echo "Expected no legacy original-name conflict suffixes, found $legacy_suffix_count" >> "$log_file"
684
        result=1
685
    fi
686

            
687
    # Capture post-test state
688
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
689
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
690

            
691
    # Generate report
692
    generate_test_report \
693
        "Timestamp_Collision_No_Overwrite" \
694
        "Processing multiple GoPro-style chapters with identical CreateDate values" \
695
        "Verify timestamp filename collisions do not overwrite prior imports or delete sources" \
696
        "Synthetic MP4 files with identical QuickTime CreateDate metadata" \
697
        "$command" \
698
        "$result"
699
}
700

            
701
# Test Case 11: GoPro Sidecar Metadata Sync Test
702
run_gopro_sidecar_metadata_sync_test() {
703
    print_color "$GREEN" "=== Running Test 11: GoPro Sidecar Metadata Sync Test ==="
704

            
705
    clean_test_dir
706
    create_test_dirs
707

            
708
    local log_file="$TEST_DIR/import_log.txt"
709
    local result=0
710
    : > "$log_file"
711

            
712
    if ! command -v ffmpeg >/dev/null 2>&1; then
713
        echo "ffmpeg is required for this regression test" >> "$log_file"
714
        result=1
715
    elif ! command -v exiftool >/dev/null 2>&1; then
716
        echo "exiftool is required for this regression test" >> "$log_file"
717
        result=1
718
    else
719
        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
720
        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
721
        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
722
        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
723
        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
724
        touch -t 202605161903.20 "$SOURCE_DIR/GX011622.THM" || result=1
725
        touch -t 202605161915.08 "$SOURCE_DIR/GX021622.THM" || result=1
726
        touch -t 202605161926.56 "$SOURCE_DIR/GX031622.LRV" || result=1
727
        touch -t 202605161938.44 "$SOURCE_DIR/GX041622.MP4" || result=1
728
    fi
729

            
730
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
731
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
732

            
733
    local command="\"$MEDIA_IMPORTER\" -s \"$SOURCE_DIR\" -d \"$DEST_DIR\" --verify-mode size -v"
734
    if [[ $result -eq 0 ]]; then
735
        run_test_command "$command" "$log_file" || result=$?
736
    fi
737

            
738
    local first_dest="$DEST_DIR/2026-05-16/2026-05-16_19-03-20.mp4"
739
    local second_dest="$DEST_DIR/2026-05-16/2026-05-16_19-15-08.mp4"
740
    local third_dest="$DEST_DIR/2026-05-16/2026-05-16_19-26-56.mp4"
741
    local fourth_dest="$DEST_DIR/2026-05-16/2026-05-16_19-38-44.mp4"
742
    if [[ ! -f "$first_dest" || ! -f "$second_dest" || ! -f "$third_dest" || ! -f "$fourth_dest" ]]; then
743
        echo "Expected GoPro filesystem-based destination filenames were not created" >> "$log_file"
744
        result=1
745
    fi
746

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

            
777
    local source_count
778
    source_count=$(find "$SOURCE_DIR" -type f -iname "*.mp4" | wc -l | tr -d ' ')
779
    if [[ "$source_count" != "0" ]]; then
780
        echo "Expected GoPro source MP4 files to be moved, found $source_count remaining" >> "$log_file"
781
        result=1
782
    fi
783

            
784
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
785
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
786

            
787
    generate_test_report \
788
        "GoPro_Sidecar_Metadata_Sync" \
789
        "Processing GoPro-style MP4 chapters with THM, LRV, and MP4 filesystem timestamps" \
790
        "Verify GoPro imports use filesystem fallback dates and sync destination metadata automatically" \
791
        "Synthetic GoPro MP4 files with shared QuickTime CreateDate plus THM/LRV/no-sidecar mtime variants" \
792
        "$command" \
793
        "$result"
794
}
795

            
796
# Test Case 12: GoPro No-Sidecar Reimport Test
797
run_gopro_no_sidecar_reimport_test() {
798
    print_color "$GREEN" "=== Running Test 12: GoPro No-Sidecar Reimport Test ==="
799

            
800
    clean_test_dir
801
    create_test_dirs
802

            
803
    local log_file="$TEST_DIR/import_log.txt"
804
    local result=0
805
    : > "$log_file"
806

            
807
    if ! command -v ffmpeg >/dev/null 2>&1; then
808
        echo "ffmpeg is required for this regression test" >> "$log_file"
809
        result=1
810
    elif ! command -v exiftool >/dev/null 2>&1; then
811
        echo "exiftool is required for this regression test" >> "$log_file"
812
        result=1
813
    else
814
        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
815
        exiftool -overwrite_original -QuickTime:CreateDate="2026:05:16 19:03:19" "$SOURCE_DIR/GX051622.MP4" >> "$log_file" 2>&1 || result=1
816
        rm -f "$SOURCE_DIR/GX051622.THM" "$SOURCE_DIR/GX051622.thm" "$SOURCE_DIR/GX051622.LRV" "$SOURCE_DIR/GX051622.lrv"
817
        touch -t 202605161950.32 "$SOURCE_DIR/GX051622.MP4" || result=1
818
    fi
819

            
820
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_before.txt" "source"
821
    capture_state "$DEST_DIR" "$TEST_DIR/dest_before.txt" "destination"
822

            
823
    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"
824
    if [[ $result -eq 0 ]]; then
825
        run_test_command "$command" "$log_file" || result=$?
826
    fi
827

            
828
    local first_dest="$DEST_DIR/2026-05-16/2026-05-16_19-50-32.mp4"
829
    local reimport_dest="$DEST_DIR/2026-05-16/2026-05-16_19-50-32_1.mp4"
830
    if [[ ! -f "$first_dest" || ! -f "$reimport_dest" ]]; then
831
        echo "Expected no-sidecar GoPro reimport destinations were not created" >> "$log_file"
832
        result=1
833
    fi
834

            
835
    local dest_count
836
    dest_count=$(find "$DEST_DIR" -type f -iname "*.mp4" | wc -l | tr -d ' ')
837
    if [[ "$dest_count" != "2" ]]; then
838
        echo "Expected 2 destination MP4 files after reimport, found $dest_count" >> "$log_file"
839
        result=1
840
    fi
841

            
842
    local source_count
843
    source_count=$(find "$SOURCE_DIR" -type f -iname "*.mp4" | wc -l | tr -d ' ')
844
    if [[ "$source_count" != "1" ]]; then
845
        echo "Expected source MP4 to remain in keep-originals reimport test, found $source_count" >> "$log_file"
846
        result=1
847
    fi
848

            
849
    local sidecar_count
850
    sidecar_count=$(find "$SOURCE_DIR" -type f \( -iname "*.thm" -o -iname "*.lrv" \) | wc -l | tr -d ' ')
851
    if [[ "$sidecar_count" != "0" ]]; then
852
        echo "Expected no THM/LRV sidecars in no-sidecar test, found $sidecar_count" >> "$log_file"
853
        result=1
854
    fi
855

            
856
    if ! grep -q "Filesystem:GX051622.MP4" "$log_file"; then
857
        echo "Expected date source fallback to Filesystem:GX051622.MP4" >> "$log_file"
858
        result=1
859
    fi
860

            
861
    local first_metadata reimport_metadata
862
    if [[ -f "$first_dest" ]]; then
863
        first_metadata=$(exiftool -api QuickTimeUTC=0 -s -s -s -QuickTime:CreateDate "$first_dest" 2>/dev/null | head -1)
864
        if [[ "$first_metadata" != "2026:05:16 19:50:32" ]]; then
865
            echo "Expected first import metadata CreateDate 2026:05:16 19:50:32, got ${first_metadata:-none}" >> "$log_file"
866
            result=1
867
        fi
868
    fi
869
    if [[ -f "$reimport_dest" ]]; then
870
        reimport_metadata=$(exiftool -api QuickTimeUTC=0 -s -s -s -QuickTime:CreateDate "$reimport_dest" 2>/dev/null | head -1)
871
        if [[ "$reimport_metadata" != "2026:05:16 19:50:32" ]]; then
872
            echo "Expected reimport metadata CreateDate 2026:05:16 19:50:32, got ${reimport_metadata:-none}" >> "$log_file"
873
            result=1
874
        fi
875
    fi
876

            
877
    capture_state "$SOURCE_DIR" "$TEST_DIR/source_after.txt" "source"
878
    capture_state "$DEST_DIR" "$TEST_DIR/dest_after.txt" "destination"
879

            
880
    generate_test_report \
881
        "GoPro_No_Sidecar_Reimport" \
882
        "Importing and reimporting a GoPro MP4 with no THM/LRV sidecars" \
883
        "Verify MP4 filesystem mtime fallback, metadata sync, and numeric suffix on reimport" \
884
        "Synthetic GoPro MP4 with no sidecars and wrong QuickTime metadata" \
885
        "$command" \
886
        "$result"
887
}
888

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

            
915
# Function to run all tests
916
run_all_tests() {
917
    print_color "$GREEN" "Running all tests sequentially..."
918

            
919
    run_basic_functionality_test
920
    echo ""
921
    run_unimportable_files_test
922
    echo ""
923
    run_mixed_content_test
924
    echo ""
925
    run_safety_protections_test
926
    echo ""
927
    run_utc_conversion_test
928
    echo ""
929
    run_subdirectory_processing_test
930
    echo ""
931
    run_keep_empty_dirs_test
932
    echo ""
933
    run_source_only_test
Bogdan Timofte authored 3 weeks ago
934
    echo ""
935
    run_destination_inside_source_test
936
    echo ""
937
    run_verify_mode_test
Bogdan Timofte authored 2 weeks ago
938
    echo ""
939
    run_timestamp_collision_no_overwrite_test
940
    echo ""
941
    run_gopro_sidecar_metadata_sync_test
942
    echo ""
943
    run_gopro_no_sidecar_reimport_test
Bogdan Timofte authored 8 months ago
944

            
945
    print_color "$GREEN" "All tests completed!"
946
}
947

            
948
# Main menu loop
949
main() {
950
    while true; do
951
        show_menu
952
        read -r choice
953

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

            
1006
        echo ""
1007
        echo -n "Press Enter to continue..."
1008
        read -r
1009
    done
1010
}
1011

            
1012
# Check if script exists
1013
if [[ ! -f "$MEDIA_IMPORTER" ]]; then
1014
    print_color "$RED" "Error: $MEDIA_IMPORTER not found!"
1015
    exit 1
1016
fi
1017

            
1018
# Check if samples directory exists
1019
if [[ ! -d "$SAMPLES_DIR" ]]; then
1020
    print_color "$YELLOW" "Warning: $SAMPLES_DIR not found. Some tests may not work properly."
1021
fi
1022

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