Skip to content

Commit 2828474

Browse files
alphaqiuclaude
andcommitted
fix: add serial_test to mcp_lock_test for thread-safe execution
These tests manipulate the same global lock file and must run serially. Added serial_test import and #[serial] attribute to all tests. Co-Authored-By: Claude (glm-4.7) <noreply@anthropic.com>
1 parent 0ad5f63 commit 2828474

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

tests/mcp_lock_test.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
//! Run with: cargo test --test mcp_lock_test -- --test-threads=1
1010
1111
use keyring_cli::mcp::lock::{is_locked, McpLock};
12+
use serial_test::serial;
1213
use std::thread;
1314

15+
#[serial]
1416
#[test]
1517
fn test_lock_acquisition() {
1618
// First lock should succeed
@@ -29,6 +31,7 @@ fn test_lock_acquisition() {
2931
lock2.release().expect("Second release should succeed");
3032
}
3133

34+
#[serial]
3235
#[test]
3336
fn test_try_acquire() {
3437
// No lock held initially
@@ -42,6 +45,7 @@ fn test_try_acquire() {
4245
lock1.release().expect("Release should succeed");
4346
}
4447

48+
#[serial]
4549
#[test]
4650
fn test_pid_writing() {
4751
let lock = McpLock::acquire().expect("Lock should be acquired");
@@ -55,6 +59,7 @@ fn test_pid_writing() {
5559
lock.release().expect("Release should succeed");
5660
}
5761

62+
#[serial]
5863
#[test]
5964
fn test_double_release() {
6065
let lock = McpLock::acquire().expect("Lock should be acquired");
@@ -66,6 +71,7 @@ fn test_double_release() {
6671
// The Drop trait has already been called during release
6772
}
6873

74+
#[serial]
6975
#[test]
7076
fn test_drop_auto_release() {
7177
// Test that Drop trait automatically releases the lock
@@ -80,6 +86,7 @@ fn test_drop_auto_release() {
8086
lock2.release().expect("Release should succeed");
8187
}
8288

89+
#[serial]
8390
#[test]
8491
fn test_concurrent_lock_attempts() {
8592
let lock1 = McpLock::acquire().expect("First lock should succeed");
@@ -96,6 +103,7 @@ fn test_concurrent_lock_attempts() {
96103
lock1.release().expect("Release should succeed");
97104
}
98105

106+
#[serial]
99107
#[test]
100108
fn test_lock_file_path() {
101109
let lock = McpLock::acquire().expect("Lock should be acquired");
@@ -110,6 +118,7 @@ fn test_lock_file_path() {
110118
lock.release().expect("Release should succeed");
111119
}
112120

121+
#[serial]
113122
#[test]
114123
fn test_is_locked() {
115124
// Initially no lock

0 commit comments

Comments
 (0)