Skip to content

Commit eecbf04

Browse files
authored
Merge pull request #157 from link-foundation/claude/review-test-standards-01GsYvAqSF7k3oxTeEwYsX9W
Review test standardization and coverage plans
2 parents a5db396 + e0b9a97 commit eecbf04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3388
-2131
lines changed

.githooks/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Git Hooks
2+
3+
This directory contains git hooks for the Links Notation project to ensure code quality and consistency.
4+
5+
## Installation
6+
7+
To install the git hooks, run:
8+
9+
```bash
10+
bash .githooks/install-hooks.sh
11+
```
12+
13+
Or configure git to use this directory for hooks:
14+
15+
```bash
16+
git config core.hooksPath .githooks
17+
```
18+
19+
## Available Hooks
20+
21+
### pre-commit
22+
23+
Automatically regenerates `TEST_CASE_COMPARISON.md` when test files are modified.
24+
25+
**Triggers when:**
26+
- Any Python test file (`*/tests/*.py`) is staged
27+
- Any JavaScript test file (`*/tests/*.js`) is staged
28+
- Any Rust test file (`*/tests/*.rs`) is staged
29+
- Any C# test file (`*/tests/*.cs`) is staged
30+
31+
**What it does:**
32+
1. Detects that test files have been modified
33+
2. Runs `node scripts/create-test-case-comparison.mjs` to regenerate the comparison document
34+
3. If `TEST_CASE_COMPARISON.md` changed, automatically stages it for the commit
35+
4. Fails the commit if regeneration fails (with instructions to fix)
36+
37+
**Why this is important:**
38+
The test comparison document provides a comprehensive overview of test parity across all language implementations. Keeping it up-to-date ensures developers can always see the current state of test coverage.
39+
40+
## Bypassing Hooks
41+
42+
If you need to bypass the hooks for a specific commit (not recommended), use:
43+
44+
```bash
45+
git commit --no-verify
46+
```
47+
48+
## Troubleshooting
49+
50+
### Hook not running
51+
52+
Make sure the hooks are executable:
53+
54+
```bash
55+
chmod +x .githooks/*
56+
```
57+
58+
### Regeneration fails
59+
60+
If the comparison script fails:
61+
62+
1. Check that Node.js is installed
63+
2. Run the script manually: `node scripts/create-test-case-comparison.mjs`
64+
3. Review any error messages
65+
4. Fix any issues and try committing again
66+
67+
## Adding New Hooks
68+
69+
To add a new hook:
70+
71+
1. Create the hook file in `.githooks/`
72+
2. Make it executable: `chmod +x .githooks/your-hook`
73+
3. Update this README to document it
74+
4. Run the install script or notify team members to reinstall hooks

.githooks/install-hooks.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
#
3+
# Install git hooks from .githooks directory
4+
#
5+
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
HOOKS_DIR="$(git rev-parse --git-dir)/hooks"
8+
9+
echo "Installing git hooks..."
10+
11+
for hook in "$SCRIPT_DIR"/*; do
12+
hook_name=$(basename "$hook")
13+
14+
# Skip this install script and README
15+
if [[ "$hook_name" == "install-hooks.sh" ]] || [[ "$hook_name" == "README.md" ]]; then
16+
continue
17+
fi
18+
19+
# Skip if not a file
20+
if [[ ! -f "$hook" ]]; then
21+
continue
22+
fi
23+
24+
target="$HOOKS_DIR/$hook_name"
25+
26+
# Copy hook
27+
cp "$hook" "$target"
28+
chmod +x "$target"
29+
30+
echo "✓ Installed $hook_name"
31+
done
32+
33+
echo ""
34+
echo "Git hooks installed successfully!"
35+
echo "These hooks will now run automatically on git operations."

.githooks/pre-commit

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
#
3+
# Pre-commit hook to automatically regenerate TEST_CASE_COMPARISON.md
4+
# when test files are modified.
5+
#
6+
7+
# Colors for output
8+
RED='\033[0;31m'
9+
GREEN='\033[0;32m'
10+
YELLOW='\033[1;33m'
11+
NC='\033[0m' # No Color
12+
13+
# Check if any test files are being committed
14+
test_files_changed=$(git diff --cached --name-only | grep -E 'tests?/.*\.(py|js|rs|cs)$')
15+
16+
if [ -n "$test_files_changed" ]; then
17+
echo -e "${YELLOW}Test files modified, regenerating TEST_CASE_COMPARISON.md...${NC}"
18+
19+
# Run the comparison script
20+
if node scripts/create-test-case-comparison.mjs > /dev/null 2>&1; then
21+
# Check if TEST_CASE_COMPARISON.md was modified
22+
if git diff --name-only TEST_CASE_COMPARISON.md | grep -q "TEST_CASE_COMPARISON.md"; then
23+
echo -e "${GREEN}✓ TEST_CASE_COMPARISON.md regenerated${NC}"
24+
git add TEST_CASE_COMPARISON.md
25+
echo -e "${GREEN}✓ TEST_CASE_COMPARISON.md staged for commit${NC}"
26+
else
27+
echo -e "${GREEN}✓ TEST_CASE_COMPARISON.md is up-to-date${NC}"
28+
fi
29+
else
30+
echo -e "${RED}✗ Failed to regenerate TEST_CASE_COMPARISON.md${NC}"
31+
echo -e "${YELLOW}Please run: node scripts/create-test-case-comparison.mjs${NC}"
32+
exit 1
33+
fi
34+
fi
35+
36+
# Run any other pre-commit checks here
37+
38+
exit 0

FEATURE_COMPARISON.md

Lines changed: 0 additions & 225 deletions
This file was deleted.

0 commit comments

Comments
 (0)