TestPicker

Documentation for TestPicker.

TestPicker.INTERFACESConstant
INTERFACES

Global collection of test block interfaces used by TestPicker.

Contains all registered TestBlockInterface implementations that TestPicker uses to recognize and parse different types of test blocks. By default includes StdTestset for standard @testset blocks.

source
TestPicker.LATEST_EVALConstant
LATEST_EVAL

Global reference to the most recently executed test evaluations.

Stores a vector of EvalTest objects representing the last set of tests that were executed. This allows for re-running the same tests without going through the selection interface again.

source
TestPicker.TESTENV_CACHEConstant
TESTENV_CACHE

Cache for TestEnv temporary environments to avoid triggering recompilation on every test run.

This constant stores a mapping from PackageSpec objects to their corresponding temporary test environment paths. Reusing these environments improves performance by avoiding the overhead of recreating test environments.

source
TestPicker.EvalTestType
EvalTest

Container for executable test code and its associated metadata.

Combines a Julia expression representing test code with metadata about its source and context. Used throughout TestPicker for tracking and executing tests.

source
TestPicker.StdTestsetType
StdTestset <: TestBlockInterface

Standard implementation of TestBlockInterface for @testset blocks from Julia's Test.jl standard library.

This is the built-in interface for recognizing and processing standard Julia test sets. It handles @testset blocks commonly used in Julia testing and provides the necessary preamble to load the Test.jl package.

source
TestPicker.SyntaxBlockType
SyntaxBlock

A container for a test block and its associated preamble statements.

Contains all the necessary components to execute a test block, including any setup code that needs to run beforehand. Can be easily converted into an evaluatable expression.

source
TestPicker.TestBlockInfoType
TestBlockInfo

Metadata container for a test block, including its location and identification information.

Stores essential information about a test block's location within a file and provides a label for identification and display purposes.

source
TestPicker.TestBlockInterfaceType
TestBlockInterface

Abstract interface for defining and recognizing different types of test blocks in Julia code.

The TestBlockInterface allows you to define different types of test blocks that you would like TestPicker to find and evaluate. The interface is relatively simple and flexible.

source
TestPicker.TestInfoType
TestInfo

Container for test execution metadata and location information.

Stores essential information about a test's source location and context, used for tracking test execution and displaying results.

source
REPL.LineEdit.complete_lineMethod
complete_line(::TestModeCompletionProvider, s::LineEdit.PromptState)

Provide completions based on available test file names (without paths).

source
TestPicker.add_interface!Method
add_interface!(interface::TestBlockInterface) -> Vector{TestBlockInterface}

Register a new test block interface with TestPicker.

Adds the provided interface to the global INTERFACES collection, enabling TestPicker to recognize and process the corresponding test block types. Duplicates are automatically removed to prevent redundant processing.

source
TestPicker.blocklabelMethod
blocklabel(interface::T, node::SyntaxNode)::String where {T<:TestBlockInterface}

Generate a descriptive label for a test block to be used in filtering and display.

This is a required method that must be implemented by all concrete subtypes of TestBlockInterface. It should produce a (preferably) unique label that helps users identify and select specific test blocks.

source
TestPicker.build_info_to_syntaxMethod
build_info_to_syntax(interfaces, root, matched_files) -> (Dict{TestBlockInfo,SyntaxBlock}, Dict{String,TestBlockInfo})

Parse matched files and build mapping structures for test block selection and display.

Extracts all test blocks from the provided files and creates two mappings:

  1. From test block metadata to syntax information
  2. From human-readable display strings (for fzf) to test block metadata
source
TestPicker.clear_testenv_cacheMethod
clear_testenv_cache()

Clear the TestEnv cache to force recreation of test environments on next use.

Empties the TESTENV_CACHE dictionary, which will cause subsequent test evaluations to create fresh test environments. This can be useful when test dependencies have changed or when troubleshooting environment-related issues.

source
TestPicker.create_repl_test_modeMethod
create_repl_test_mode(repl::AbstractREPL, main::LineEdit.Prompt) -> LineEdit.Prompt

Create a new REPL mode specifically for test operations.

Constructs a custom REPL prompt mode that handles test-specific commands and provides an isolated interface for TestPicker operations. The mode includes proper history support, key bindings, and command processing.

source
TestPicker.current_pkgMethod
current_pkg() -> PackageSpec

Get the current package specification from the active Pkg environment.

This is a more flexible version of current_pkg_name from TestEnv that returns the full PackageSpec object rather than just the package name. This provides access to additional package metadata needed by TestPicker.

source
TestPicker.eval_in_moduleMethod
eval_in_module(eval_test::EvalTest, pkg::PackageSpec) -> Nothing

Execute a test block in an isolated module with the appropriate test environment activated.

This function provides the core test execution functionality for TestPicker. It creates a temporary module, activates the package's test environment, and evaluates the test code in isolation to prevent interference between different test runs.

source
TestPicker.expr_transformMethod
expr_transform(interface::TestBlockInterface, ex::Expr)::Expr

Transform a test block expression before evaluation.

This optional method allows test block interfaces to modify the test block expression before it is executed. This can be useful for adding wrapper code, modifying test behavior, or adapting different test formats.

source
TestPicker.fzf_testblockMethod
fzf_testblock(interfaces, fuzzy_file, fuzzy_testset) -> Nothing

Interactive test block selection and execution workflow using fzf.

Provides a two-stage fuzzy finding process:

  1. Filter test files based on fuzzy_file query
  2. Select specific test blocks from filtered files based on fuzzy_testset query
source
TestPicker.fzf_testblock_from_filesMethod
fzf_testblock_from_files(interfaces, matched_files, fuzzy_testset, pkg, root) -> Nothing

Interactive test block selection and execution from a list of matched files.

Takes a list of already-filtered files and presents an fzf interface to select specific test blocks from those files based on fuzzy_testset query.

source
TestPicker.fzf_testfileMethod
fzf_testfile(query::AbstractString) -> Nothing

Interactive test file selection and execution workflow.

Combines file selection and execution in a single workflow: uses fzf to select test files based on the query, then runs all selected files in the test environment. If ctrl-b is pressed during file selection, switches to testblock selection mode instead.

source
TestPicker.get_matching_filesMethod
get_matching_files(file_query::AbstractString, test_files::AbstractVector{<:AbstractString}) -> Vector{String}

Filter test files using fzf's non-interactive filtering based on the given query.

Uses fzf --filter to perform fuzzy matching on the provided list of test files, returning only those that match the query pattern.

source
TestPicker.get_test_filesFunction
get_test_files(pkg::PackageSpec=current_pkg()) -> (String, Vector{String})

Discover and return all Julia test files for a package.

Recursively searches the package's test directory to find all .jl files, returning both the test directory path and the collection of relative file paths.

source
TestPicker.get_testblocksMethod
get_testblocks(interfaces::Vector{<:TestBlockInterface}, file::AbstractString) -> Vector{SyntaxBlock}

Parse a Julia file and extract all test blocks with their associated preamble statements.

For each test block found (including nested ones), collects all preceding preamble statements that should be executed before the test block. Uses the provided interfaces to determine what constitutes a test block.

source
TestPicker.identify_queryMethod
identify_query(input::AbstractString) -> (QueryType, Tuple)

Parse user input in test mode and identify the type of operation requested.

Analyzes the input string to determine what kind of test operation the user wants to perform and extracts the relevant parameters for that operation.

source
TestPicker.init_test_repl_modeMethod
init_test_repl_mode(repl::AbstractREPL) -> Nothing

Initialize and add test mode to the REPL interface.

Sets up a custom REPL mode for TestPicker that can be accessed by typing '!' at the beginning of a line. The test mode provides specialized commands for running and inspecting tests interactively.

source
TestPicker.ispreambleMethod
ispreamble(node::SyntaxNode) -> Bool

Check if a statement qualifies as a preamble that should be executed before test blocks.

A preamble statement is any statement that sets up the testing environment, such as:

  • Function calls (:call)
  • Import/using statements (:using, :import)
  • Variable assignments (:=)
  • Macro calls (:macrocall)
  • Function definitions (:function)
source
TestPicker.istestblockMethod
istestblock(interface::T, node::SyntaxNode)::Bool where {T<:TestBlockInterface}

Determine whether a syntax node represents a test block according to the given interface.

This is a required method that must be implemented by all concrete subtypes of TestBlockInterface. It examines a syntax node and decides whether it represents a test block that should be recognized by TestPicker.

source
TestPicker.pick_testblockMethod
pick_testblock(tabled_keys, testset_query, root) -> Vector{String}

Present an interactive fzf interface for selecting test blocks to execute.

Launches fzf with a preview window (using bat) that allows users to select one or more test blocks from the filtered list. The preview shows the actual test code with syntax highlighting.

source
TestPicker.preambleMethod
preamble(interface::TestBlockInterface)::Union{Nothing, Expr}

Return additional preamble code specific to the test block interface.

This optional method allows test block interfaces to specify setup code that should be executed before any test blocks of this type. Common uses include importing required packages or setting up test environment variables.

source
TestPicker.prepend_exMethod
prepend_ex(ex, new_line::Expr) -> Expr

Prepend a new expression to an existing expression, handling block structure appropriately.

If the target expression is already a block, the new expression is prepended to the beginning of the block. Otherwise, a new block is created containing both expressions.

source
TestPicker.prepend_preamble_statementsMethod
prepend_preamble_statements(interface::TestBlockInterface, preambles::Vector{Expr}) -> Vector{Expr}

Combine interface-specific preamble with existing preamble statements.

Takes the preamble from the interface (if any) and prepends it to the existing collection of preamble statements, ensuring interface requirements are satisfied before test execution.

source
TestPicker.print_test_docsMethod
print_test_docs() -> Nothing

Print a summary of available features and commands in test mode.

Displays a help message showing all the different ways to interact with TestPicker's test REPL mode.

source
TestPicker.replace_interface!Method
replace_interface!(interface::TestBlockInterface) -> Vector{TestBlockInterface}

Similar to add_interface! but empty the interface first before adding the new one so that it becomes the unique interface.

source
TestPicker.run_test_fileMethod
run_test_file(file::AbstractString, pkg::PackageSpec) -> Any

Execute a single test file in an isolated testset within the package test environment.

Wraps the test file in a testset named after the package and file, handles test failures gracefully, and updates the global test state for later inspection.

source
TestPicker.run_test_filesMethod
run_test_files(files::AbstractVector{<:AbstractString}, pkg::PackageSpec) -> Nothing

Execute a collection of test files in the package test environment.

Runs each provided test file in sequence, handling errors gracefully and updating the test evaluation state. Each file is wrapped in a testset and executed in isolation.

source
TestPicker.save_test_resultsMethod
save_test_results(testset::Test.TestSetException, testinfo::TestInfo, pkg::PackageSpec) -> Nothing

Save test failures and errors from a test set to the package's results file.

Processes a test set exception containing failed and errored tests, formats them for display in the results viewer, and appends them to the package's results file. Each test result includes the test description, source location, detailed error information, and context.

source
TestPicker.select_test_filesFunction
select_test_files(query::AbstractString, pkg::PackageSpec=current_pkg()) -> (Symbol, String, Vector{String})

Interactively select test files using fzf based on a fuzzy search query.

Presents an fzf interface showing all test files for the package, with syntax-highlighted preview using bat. Users can select multiple files and the query pre-filters the results.

Returns a tuple of (mode, root, files) where:

  • mode is either :file or :testblock depending on whether the user pressed Enter or Ctrl+B
  • root is the test directory path
  • files are relative paths (not joined with root yet)
source
TestPicker.test_mode_do_cmdMethod
test_mode_do_cmd(repl::AbstractREPL, input::String) -> Nothing

Execute test commands received in the test REPL mode.

Processes user input from the test mode, identifies the requested operation, and dispatches to the appropriate test execution or inspection function.

source
TestPicker.testblock_listMethod
testblock_list(choices, info_to_syntax, display_to_info, pkg) -> Vector{EvalTest}

Convert user-selected test block choices into executable test objects.

Takes the selected display strings from fzf and converts them into EvalTest objects that can be evaluated. Each test is wrapped in a try-catch block to handle test failures gracefully and save results.

source
TestPicker.visualize_test_resultsFunction
visualize_test_results(repl::AbstractREPL=Base.active_repl, pkg::PackageSpec=current_pkg()) -> Nothing

Interactive visualization of test failures and errors using fzf interface.

Creates a loop-based interface for browsing test failures and errors from the most recent test execution. Provides syntax-highlighted previews of stack traces and allows editing of test files directly from the interface.

source