Skip to content

DRAFT: Erospector#6

Draft
aadhar-agarwal wants to merge 4 commits intomainfrom
aadagarwal/hackathon
Draft

DRAFT: Erospector#6
aadhar-agarwal wants to merge 4 commits intomainfrom
aadagarwal/hackathon

Conversation

@aadhar-agarwal
Copy link
Owner

@aadhar-agarwal aadhar-agarwal commented Jul 17, 2025

PR Description

This pull request introduces a new tool called Erospector for the containerd project, designed to help automatically generate Go unit tests using Azure OpenAI (GPT) integration. The changes add the full source code for the Erospector utility in a dedicated directory, including Go and Python files that work together to parse Go source files, extract functions, generate context, and produce unit tests.

Summary of changes:

  • New directory erospector/: Contains all the tooling for the Erospector utility.
  • Go files added:
    • main.go: Implements the command-line interface for Erospector. Handles argument parsing, manages function selection, loads context files as a "primer," and coordinates the test generation process.
    • parser.go: Extracts functions from Go source files for targeted test generation.
    • primer_loader.go: Recursively finds Go files in key directories and loads their contents to provide context to the test generator.
    • writer.go: Handles writing generated test files to disk, with logic to extract code blocks from GPT output.
    • gpt_python.go: Bridges the Go code to the Python script, managing communication and error handling.
  • Python integration:
    • gpt.py: The Python script responsible for interacting with Azure OpenAI, generating test code, and running Go tests with coverage calculation. Implements both "simple" and "iterative test-and-run" modes.

Key Features:

  • CLI tool for generating Go unit tests automatically.
  • Can target specific functions or entire files.
  • Supports iterative improvement: generates tests, runs them, and fixes issues until tests pass.
  • Loads context from related files to improve test relevance.
  • Integrates Azure OpenAI for advanced code understanding and test synthesis.
  • Writes generated tests to appropriately named _test.go files.

This PR adds an advanced, AI-powered test generation tool for Go code within the containerd repository, enabling developers to automate and streamline the creation of unit tests.

Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
@aadhar-agarwal aadhar-agarwal changed the title Erospecor DRAFT: Erospector Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant