In 2026, Atlas helps Perl developers write unit tests for untested code by reading your module, understanding cpanm dependencies, and generating Test2::V0 test cases that match your repository's existing conventions. Atlas then runs these tests with prove (Test2::V0) and helps you iterate until they pass.
How does Atlas find untested Perl functions?
Atlas identifies untested Perl functions in 2026 by using its `read` tool to ingest your module and then leveraging the `lsp` tool's `documentSymbol` operation. This process enumerates all exported symbols, ensuring no public function is missed during test generation.
To begin writing unit tests for a Perl module, Atlas first needs to understand its structure and public interface. Atlas uses its `read` tool to load the target Perl module, such as `lib/MyModule.pm`, into its context. Once the module is read, Atlas employs the `lsp` tool with the `documentSymbol` operation. This operation, powered by tree-sitter, precisely identifies and lists all declared symbols within the Perl code, including functions, methods, and variables that are part of the module's public API. This AST-based indexing ensures that Atlas does not miss any exported symbols, providing a comprehensive list of functions that require test coverage. Atlas also considers the module's `cpanm` dependencies, ensuring it has the full context of the Perl distribution.
How does Atlas match my Perl test conventions?
Atlas matches your Perl repository's existing test conventions by first using the `grep` tool to locate an existing test file, such as `t/MyModule.t`. This allows Atlas to copy the framework, import style, and naming conventions, ensuring new `Test2::V0` tests integrate direct.
A crucial aspect of adding new tests to an existing Perl codebase is maintaining consistency with established conventions. Atlas achieves this by using its `grep` tool to search for existing test files within your project's `t/` directory. For instance, it might search for `use Test2::V0;` to identify the preferred testing framework. Once an existing test file is found, Atlas analyzes its structure, including the `use` statements, the style of assertions (e.g., `ok()`, `is()`), and the overall naming scheme for test subroutines. When Atlas then uses the `write` tool to draft the new test file, for example `t/NewModule.t`, it generates `Test2::V0` test cases that meticulously adhere to these discovered conventions. This ensures that the new tests look and feel like an organic part of your Perl repository, minimizing review friction and maintaining code quality.
How does Atlas run and debug Perl unit tests?
Atlas runs Perl unit tests using the `bash` tool to execute `prove (Test2::V0)` with the `-lr t/` flags, providing immediate feedback on test failures. This execution is the critical point, as a test never run is not a test, allowing for rapid iteration.
The true value of a unit test lies in its execution. Atlas facilitates this by using its `bash` tool to run the Perl test suite. Specifically, Atlas executes the command `prove -lr t/`, which invokes the `prove` test runner with `Test2::V0` to discover and run all test files in the `t/` directory. The `-l` flag adds `lib` to the include path, and `-r` recursively searches for tests. Atlas captures the TAP (Test Anything Protocol) output from `prove`, displaying it directly in the terminal. If the output exceeds 2000 lines or 50 KB, Atlas truncates it for readability but saves the full log to a file for detailed review. When tests fail, Atlas allows you to use the `edit` tool to modify the test file or the module under test. For larger modules or complex test suites, the `todowrite` tool helps manage progress by keeping a list of remaining tasks, enabling an efficient iterative debugging cycle until all tests pass.
How does Atlas ensure safe Perl code changes?
Atlas ensures safe Perl code changes through a multi-layered review process, including permission-gated tool calls and unified diffs for every file edit. In 2026, Atlas asks for approval before writing to disk, providing a clear audit trail and rollback capability.
Safety and control are paramount when an AI agent modifies your Perl codebase. Atlas incorporates several mechanisms to ensure that all changes are transparent and approved. Every Atlas tool call, including `write` and `bash`, is permission-gated, requiring explicit approval based on allow, ask, or deny rules before execution. When Atlas drafts a plan, it does so in a read-only plan agent, presenting its strategy before switching to a build agent that can make changes. Crucially, for every file edit, Atlas computes a unified diff and surfaces it for your approval. This allows you to review precisely what changes will be made to your Perl modules or test files before they are written to disk. Furthermore, Atlas snapshots file changes as git patches, providing a robust mechanism to diff edits and roll back any unwanted modifications, ensuring you always maintain control over your Perl project's integrity.
Step by step
- 01Run Atlas in your Perl distribution, ensuring it can read your `cpanfile` or `Makefile.PL` dependencies: `atlas`
- 02Identify all public symbols in the Perl module you want to test using the `lsp` tool: `atlas lsp documentSymbol --file lib/MyModule.pm`
- 03Find existing Perl test conventions in your repository by `grep`ing for `Test2::V0` usage in the `t/` directory: `atlas grep "use Test2::V0;" t/`
- 04Draft the new Perl test file, for example `t/MyModule.t`, using the `write` tool, reviewing the diff before approval: `atlas write t/MyModule.t`
- 05Run the Perl test suite with `prove (Test2::V0)` via the `bash` tool, checking the TAP output for failures: `atlas bash "prove -lr t/"`
- 06Iterate and fix any Perl test failures or module bugs using the `edit` tool, for example: `atlas edit lib/MyModule.pm`
- 07Format the changed Perl files with `perltidy` to match your `.perltidyrc` configuration: `atlas bash "perltidy t/MyModule.t lib/MyModule.pm"`
- 08Stage and commit the new Perl tests and any module changes using Atlas's git integration.
Frequently asked questions
- How does Atlas handle Perl module dependencies for testing?
- Atlas reads your Perl distribution's `cpanfile` or `Makefile.PL` to understand module dependencies. It then uses this context to generate tests that correctly import and interact with your module's external requirements, ensuring a functional test environment.
- Can Atlas write tests for legacy Perl code without `Test2::V0`?
- Yes, Atlas can adapt. While it defaults to `Test2::V0` as the modern standard, if your repository exclusively uses `Test::More` or another framework, Atlas will `grep` for those conventions and generate tests accordingly, matching your existing setup.
- What if my Perl test output is very long?
- If `prove (Test2::V0)` output exceeds 2000 lines or 50 KB, Atlas truncates it in the TUI for immediate review but saves the full log to a file. You can then review the complete TAP output at your leisure for detailed debugging.
- How does Atlas ensure new Perl tests match my `.perltidyrc`?
- After writing or editing Perl test files, you can instruct Atlas to run `perltidy` on the changed files using the `bash` tool. This ensures the new code adheres to your `.perltidyrc` configuration, maintaining consistent formatting across your Perl project.
- Can Atlas help me refactor Perl code while adding tests?
- Atlas focuses on the job of writing tests. While it can `edit` files to fix issues found during testing, its primary role here is to add `Test2::V0` cases. For larger refactoring, you would use its `todowrite` feature to manage progress on the testing task.
- Is my Perl code sent to third-party servers when using Atlas?
- No, Atlas can build its code index with local Ollama embeddings, keeping your Perl code off third-party servers. This ensures your proprietary code remains secure and private during the testing process, adhering to strict data privacy standards.
- How does Atlas know which Perl functions to test?
- Atlas uses the `lsp` tool's `documentSymbol` operation on your Perl module to enumerate all exported symbols. This ensures that every public function or method is considered for test coverage, leaving no part of your API untested and providing comprehensive test generation.
Try Atlas in your terminal
The terminal-native AI coding agent. Free core, single binary.
Install AtlasRelated guides
Write Unit Tests for Untested Code with Atlas in 2026
How to write unit tests for untested code with Atlas in 2026: the lsp tool enumerates exported symbols, grep copies repo conventions, and bash actually runs the suite.
Atlas for Perl: A Terminal-Native AI Coding Agent for CPAN Distributions in 2026
Atlas is a terminal-native AI coding agent for Perl in 2026. It reads cpanfile deps and @EXPORT lists, writes Test2::V0 cases, runs prove -lr t/, and runs perltidy on the diff.
Trace a runtime bug from a stack trace in Perl with Atlas in 2026
Pinpoint Perl runtime bugs from production stack traces using Atlas in 2026. Leverage Atlas's code indexing, grep, and lsp tools to quickly identify the root cause and apply fixes, all without a debugger.
Run the test suite and triage the failures in Perl with Atlas in 2026
Efficiently triage Perl test failures in 2026 with Atlas. Turn a wall of red `prove (Test2::V0)` output into a prioritized list of distinct root causes, using `grep` and `todowrite`.
Debug a single failing test in Perl with Atlas in 2026
Pinpoint and fix failing Perl tests with Atlas in 2026. Leverage `prove (Test2::V0)` and `cpanm` to isolate issues, walk call graphs, and apply precise code fixes.
Self-review your working diff before committing in Perl with Atlas in 2026
Catch your own mistakes in uncommitted Perl diffs before they reach review or CI. Learn how Atlas helps Perl developers in 2026 self-review code, run `prove`, and `perltidy`.
Review a Pull Request in Perl with Atlas in 2026
Review Perl pull requests efficiently in 2026 with Atlas. Catch subtle bugs by examining full file context, running prove (Test2::V0) tests, and ensuring perltidy formatting.
Plan a Multi-File Change in Perl with Atlas in 2026
Design and review complex, multi-file Perl changes with Atlas's plan agent before modifying a single line of code. Leverage prove, cpanm, and perltidy for safe development.