@chongdashu/cc-statusline 1.3.2 โ†’ 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,55 +1,55 @@
1
- #!/bin/bash
2
- # Comprehensive test for concurrent ccusage locking mechanism
3
- #
4
- # This script tests the locking mechanism under various scenarios:
5
- # 1. Concurrent execution test
6
- # 2. Stale lock cleanup test
7
- # 3. Performance verification
8
- #
9
- # Usage: ./test/test-concurrent-locking.sh
10
-
11
- set -euo pipefail
12
-
13
- TEST_DIR="$(dirname "$0")"
14
- STATUSLINE_TEST="$TEST_DIR/test-statusline-with-lock.sh"
15
-
16
- echo "๐Ÿงช Testing ccusage locking mechanism..."
17
- echo
18
-
19
- # Test 1: Concurrent execution
20
- echo "๐Ÿ“‹ Test 1: Concurrent execution (10 processes)"
21
- echo "Expected: Only 1 process runs ccusage, others skip gracefully"
22
- echo
23
-
24
- start_time=$(date +%s)
25
- for i in {1..10}; do
26
- echo '{}' | "$STATUSLINE_TEST" &
27
- done
28
- wait
29
- end_time=$(date +%s)
30
- duration=$((end_time - start_time))
31
-
32
- echo
33
- echo "โœ… Test 1 completed in ${duration}s"
34
- echo
35
-
36
- # Test 2: Lock cleanup verification
37
- echo "๐Ÿ“‹ Test 2: Verifying lock cleanup"
38
- LOCK_EXISTS=$(ls /tmp/ccusage_statusline.lock 2>/dev/null || echo "")
39
- PID_EXISTS=$(ls /tmp/ccusage_statusline.pid 2>/dev/null || echo "")
40
-
41
- if [ -z "$LOCK_EXISTS" ] && [ -z "$PID_EXISTS" ]; then
42
- echo "โœ… Lock files properly cleaned up"
43
- else
44
- echo "โŒ Lock files still exist:"
45
- [ -n "$LOCK_EXISTS" ] && echo " - Lock directory: $LOCK_EXISTS"
46
- [ -n "$PID_EXISTS" ] && echo " - PID file: $PID_EXISTS"
47
- fi
48
-
49
- echo
50
- echo "๐ŸŽ‰ All tests completed!"
51
- echo
52
- echo "๐Ÿ’ก Manual verification:"
53
- echo " 1. Check that only 1 'Running ccusage...' message appeared in stderr"
54
- echo " 2. Verify multiple 'Skipped - lock held by' messages appeared"
1
+ #!/bin/bash
2
+ # Comprehensive test for concurrent ccusage locking mechanism
3
+ #
4
+ # This script tests the locking mechanism under various scenarios:
5
+ # 1. Concurrent execution test
6
+ # 2. Stale lock cleanup test
7
+ # 3. Performance verification
8
+ #
9
+ # Usage: ./test/test-concurrent-locking.sh
10
+
11
+ set -euo pipefail
12
+
13
+ TEST_DIR="$(dirname "$0")"
14
+ STATUSLINE_TEST="$TEST_DIR/test-statusline-with-lock.sh"
15
+
16
+ echo "๐Ÿงช Testing ccusage locking mechanism..."
17
+ echo
18
+
19
+ # Test 1: Concurrent execution
20
+ echo "๐Ÿ“‹ Test 1: Concurrent execution (10 processes)"
21
+ echo "Expected: Only 1 process runs ccusage, others skip gracefully"
22
+ echo
23
+
24
+ start_time=$(date +%s)
25
+ for i in {1..10}; do
26
+ echo '{}' | "$STATUSLINE_TEST" &
27
+ done
28
+ wait
29
+ end_time=$(date +%s)
30
+ duration=$((end_time - start_time))
31
+
32
+ echo
33
+ echo "โœ… Test 1 completed in ${duration}s"
34
+ echo
35
+
36
+ # Test 2: Lock cleanup verification
37
+ echo "๐Ÿ“‹ Test 2: Verifying lock cleanup"
38
+ LOCK_EXISTS=$(ls /tmp/ccusage_statusline.lock 2>/dev/null || echo "")
39
+ PID_EXISTS=$(ls /tmp/ccusage_statusline.pid 2>/dev/null || echo "")
40
+
41
+ if [ -z "$LOCK_EXISTS" ] && [ -z "$PID_EXISTS" ]; then
42
+ echo "โœ… Lock files properly cleaned up"
43
+ else
44
+ echo "โŒ Lock files still exist:"
45
+ [ -n "$LOCK_EXISTS" ] && echo " - Lock directory: $LOCK_EXISTS"
46
+ [ -n "$PID_EXISTS" ] && echo " - PID file: $PID_EXISTS"
47
+ fi
48
+
49
+ echo
50
+ echo "๐ŸŽ‰ All tests completed!"
51
+ echo
52
+ echo "๐Ÿ’ก Manual verification:"
53
+ echo " 1. Check that only 1 'Running ccusage...' message appeared in stderr"
54
+ echo " 2. Verify multiple 'Skipped - lock held by' messages appeared"
55
55
  echo " 3. Confirm no hanging processes with: ps aux | grep ccusage"