Skip to content

Commit 033f535

Browse files
committed
hopefully stabilize tests
1 parent 5779b92 commit 033f535

2 files changed

Lines changed: 33 additions & 5 deletions

File tree

tests/test-agent-dev.expect

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ set overlay_upper "$overlay_base/upper"
3030
# Export AI_HOME for spawned processes
3131
set env(AI_HOME) $test_ai_home
3232

33+
# Global timeout handler - record failure but continue testing
34+
expect_before {
35+
timeout {
36+
global tests_failed
37+
incr tests_failed
38+
puts "\n\033\[0;31m✗ TIMEOUT:\033\[0m Expected pattern not found (test will likely fail)"
39+
}
40+
}
41+
3342
# ==============================================================================
3443
# Output Helpers
3544
# ==============================================================================
@@ -401,6 +410,8 @@ proc test_merge_workflow {} {
401410

402411
section "Test: Merge Workflow (NEW/MODIFIED/DELETED)"
403412

413+
reset_overlay
414+
404415
set ts [clock seconds]
405416

406417
# Create files in repo that we'll modify and delete
@@ -522,7 +533,8 @@ proc test_merge_workflow {} {
522533
# Cleanup
523534
catch { exec rm -f "$repo_dir/$new_accept" }
524535
catch { exec rm -f "$repo_dir/$file_to_modify" }
525-
catch { exec rm -rf "$overlay_upper/$new_skip" }
536+
catch { exec rm -f "$overlay_upper/$new_skip" }
537+
catch { exec rm -f "$overlay_upper/$new_discard" }
526538
}
527539

528540
# ==============================================================================

tests/test-merge-overlay.expect

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ set test_dir "/tmp/merge-overlay-test-[clock seconds]"
77
set repo_dir "$test_dir/repo"
88
set overlay_upper "$test_dir/overlay"
99

10+
# Global timeout handler - record failure but continue testing
11+
expect_before {
12+
timeout {
13+
global tests_failed
14+
incr tests_failed
15+
puts "\n\033\[0;31m✗ TIMEOUT:\033\[0m Expected pattern not found (test will likely fail)"
16+
}
17+
}
18+
1019
# Colors for output
1120
set GREEN "\033\[0;32m"
1221
set RED "\033\[0;31m"
@@ -55,10 +64,12 @@ proc setup_test_env {} {
5564

5665
# Initialize git repo (merge-overlay checks for .git)
5766
exec sh -c "cd $repo_dir && git init >/dev/null 2>&1"
67+
exec sh -c "cd $repo_dir && git config --local user.email 'test@example.com' && git config --local user.name 'Test User' && git config --local commit.gpgsign false"
5868

59-
# Create some base files in repo
69+
# Create some base files in repo and commit them
6070
exec sh -c "echo 'original content' > $repo_dir/file1.txt"
6171
exec sh -c "echo 'base content' > $repo_dir/file2.txt"
72+
exec sh -c "cd $repo_dir && git add file1.txt file2.txt && git commit -m 'Initial test files' >/dev/null 2>&1"
6273

6374
log_success "Test environment created"
6475
}
@@ -496,6 +507,8 @@ proc test_file_list_display {} {
496507

497508
start_test "Verify file list is displayed before processing"
498509

510+
clear_overlay
511+
499512
# Ensure files exist in repo for modified/deleted status
500513
exec sh -c "echo 'original content' > $repo_dir/file1.txt"
501514
exec sh -c "echo 'base content' > $repo_dir/file2.txt"
@@ -607,7 +620,9 @@ proc create_gitignore {patterns} {
607620
proc clear_overlay {} {
608621
global overlay_upper repo_dir
609622
exec sh -c "rm -rf $overlay_upper/* $overlay_upper/.* 2>/dev/null || true"
610-
exec sh -c "rm -f $repo_dir/.gitignore 2>/dev/null || true"
623+
# Reset git state completely to initial commit
624+
exec sh -c "cd $repo_dir && git reset --hard HEAD 2>/dev/null || true"
625+
exec sh -c "cd $repo_dir && git clean -fdx 2>/dev/null || true"
611626
}
612627

613628
# Test 12: Git-ignored files - discard all
@@ -749,12 +764,13 @@ proc test_git_ignored_keep_for_review {} {
749764
# Process first file
750765
expect -re {Action.*\?}
751766
send "y\r"
752-
expect "✓ Accepted"
767+
expect -re {Accepted}
753768

754769
# Process second file
755770
expect -re {Action.*\?}
756771
send "y\r"
757-
expect "✓ Accepted"
772+
expect -re {Accepted}
773+
758774

759775
# Wait for process to complete
760776
catch {expect eof}

0 commit comments

Comments
 (0)