mirror of
https://github.com/Z3Prover/z3
synced 2026-02-01 14:57:57 +00:00
* Initial plan * Remove slash_command and blocking activation conditions from deeptest workflow - Remove slash_command configuration to eliminate team membership and command position checks - Simplify workflow to only support workflow_dispatch for ad-hoc execution - Remove pre_activation job and complex activation conditions - Update README to reflect workflow_dispatch-only usage - Keep file_path input parameter for specifying source files to test Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
4.6 KiB
4.6 KiB
DeepTest - Automated Test Case Generator
Overview
DeepTest is an AI-powered GitHub Agentic Workflow that automatically generates comprehensive test cases for Z3 source files. It analyzes a given source file and creates high-quality, production-ready tests covering basic functionality, edge cases, error handling, and integration scenarios.
Features
- Comprehensive Test Coverage: Generates tests for basic functionality, edge cases, error handling, and integration scenarios
- Multiple Languages: Supports C++, Python, Java, C#, and other Z3 API languages
- Smart Analysis: Uses Serena language server for Python code analysis and grep/glob for C++ analysis
- Automated PR Creation: Creates a pull request with generated tests automatically
- Follows Z3 Conventions: Generates tests that match existing Z3 testing patterns and style
- Persistent Memory: Uses cache memory to track progress across runs
How to Use
Workflow Dispatch (Manual Trigger)
- Go to Actions → Deeptest in the GitHub repository
- Click Run workflow
- Enter the file path (e.g.,
src/util/vector.h) - Optionally link to an issue number
- Click Run workflow
The workflow will:
- Analyze the source file
- Generate comprehensive tests
- Create a pull request with the test files
- Optionally add a comment to the linked issue with statistics and instructions
What Gets Generated
DeepTest creates test files that include:
For C++ Files
- Unit tests using Z3's testing framework
- Located in
src/test/test_<module_name>.cpp - Follows existing test patterns in the repository
- Includes necessary headers and setup/teardown code
For Python Files
- Unit tests using
unittestorpytest - Located in
src/api/python/test_<module_name>.py - Follows patterns from existing Python tests
- Includes proper imports and test fixtures
Test Categories
Generated tests cover:
- Basic Functionality: Happy path scenarios with typical inputs
- Edge Cases: Boundary values, empty inputs, zero/negative values, very large inputs
- Error Handling: Invalid parameters, null pointers, exceptions, assertion violations
- Integration Tests: Realistic SMT-LIB2 formulas, solver workflows, theory combinations
Output
After running, DeepTest will:
-
Create a Pull Request with:
- Title:
[DeepTest] Add comprehensive tests for <filename> - Generated test file(s)
- Detailed description of test coverage
- Instructions for running the tests
- Labels:
automated-tests,deeptest
- Title:
-
Post a Comment with:
- Test statistics (number of test cases by category)
- Coverage percentage
- Link to the created PR
- Instructions for running the tests
Example Usage
Example 1: Test a C++ utility file
Via workflow dispatch with file path: src/util/vector.h
Example 2: Test a Python API file
Via workflow dispatch with file path: src/api/python/z3/z3.py
Example 3: Link to an issue
- File path:
src/ast/ast.cpp - Issue number:
1234(optional)
Running Generated Tests
After the PR is merged, run the tests:
# Build Z3
python scripts/mk_make.py
cd build && make -j$(nproc)
# Run the new tests
./test-z3 [test-name-pattern]
Configuration
The workflow is configured with:
- Timeout: 30 minutes
- Permissions: Read-only (safe-outputs handle writes)
- Network: Default curated allow-list
- Tools: Serena (Python), bash, edit, grep, glob, GitHub API
- Cache: Persistent memory enabled
Customization
To modify the agent behavior without recompiling:
- Edit
.github/agentics/deeptest.md - Changes take effect immediately (no compilation needed)
- For configuration changes in
.github/workflows/deeptest.md, run:gh aw compile deeptest
Limitations
- Does not modify existing source files (only creates new test files)
- Focuses on public APIs and functions
- May not cover all internal implementation details
- Generated tests should be reviewed before merging
Security
- Read-only permissions for the main job
- Safe outputs handle all write operations (PR creation, comments)
- Network access restricted to curated allow-list
- No secrets exposed to the AI agent
Support
If DeepTest encounters issues or needs additional tools:
- It will automatically create an issue labeled
missing-tool - The issue will expire after 1 week if not addressed
- Check the workflow run logs for detailed error information