@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.
- package/CHANGELOG.md +184 -157
- package/CLAUDE.md +76 -76
- package/CONTRIBUTING.md +207 -207
- package/LICENSE +20 -20
- package/README.md +361 -373
- package/dist/index.js +102 -73
- package/dist/index.js.map +1 -1
- package/package.json +57 -57
- package/test/test-concurrent-locking.sh +54 -54
- package/test/test-installation.sh +335 -335
- package/test/test-statusline-with-lock.sh +67 -67
|
@@ -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"
|