Thank you for your interest in contributing to Jech! This document provides guidelines and instructions for contributing.
We have a comprehensive test suite covering all core components. To run tests:
# Make the test script executable (first time only)
chmod +x run_tests.sh
# Run all tests
./run_tests.shOur tests are organized into four categories:
-
Tokenizer Tests (
tests/test_tokenizer.c)- Tests lexical analysis and token generation
- Covers keywords, operators, literals, and arrays
-
Parser Tests (
tests/test_parser.c)- Tests AST generation from tokens
- Covers all statement types and array syntax
-
VM Tests (
tests/test_vm.c)- Tests bytecode execution
- Covers variable management and array operations
-
Integration Tests (
tests/test_integration.c)- End-to-end tests of the complete pipeline
- Tests real-world usage scenarios
When adding new features, please add corresponding tests:
#include "test_framework.h"
TEST(test_your_feature)
{
// Arrange
const char *source = "your jech code;";
// Act
// ... execute your code
// Assert
ASSERT_EQ(actual, expected, "Description of what should happen");
ASSERT_STR_EQ(actual_str, expected_str, "String comparison");
ASSERT(condition, "General condition check");
}Then add your test to the appropriate test suite in tests/run_tests.c.
We provide a pre-commit hook that automatically runs tests before each commit:
# Install the hook (one-time setup)
./install_hooks.shWhen you run git commit, the hook will:
- ✅ Compile the project
- ✅ Run all tests (70 assertions)
- ✅ Block the commit if tests fail
- ✅ Allow the commit if tests pass
$ git commit -m "Add new feature"
🔍 Running pre-commit checks...
🔨 Compiling Jech...
✓ Compilation successful
🧪 Running test suite...
✓ All tests passed!
════════════════════════════════════════
✓ Pre-commit checks passed!
Proceeding with commit...
════════════════════════════════════════If you need to commit without running tests (not recommended):
git commit --no-verify -m "Your message"rm .git/hooks/pre-commit- Create a branch for your feature/fix
- Write tests first (TDD approach recommended)
- Implement your changes
- Run tests to ensure nothing broke
- Update documentation if needed
- Submit a pull request
- Use tabs for indentation (existing codebase convention)
- Keep functions focused and small
- Add comments for complex logic
- Follow existing naming conventions:
_JechModule_FunctionNamefor public functionsfunction_namefor static/private functions
When reporting bugs, please include:
- Description of the issue
- Steps to reproduce
- Expected behavior
- Actual behavior
- Jech version (from
./build/jech --versionif available) - Test case demonstrating the bug (if possible)
We welcome feature requests! Please:
- Check existing issues/roadmap first
- Describe the use case
- Provide example syntax (if applicable)
- Explain why it would benefit Jech users
- More test coverage (edge cases)
- Performance benchmarks
- Documentation improvements
- Example programs
- Error message improvements
- REPL enhancements
By contributing, you agree that your contributions will be licensed under the same license as the project.
Thank you for contributing to Jech! 🚀