TestPicker
Documentation for TestPicker.
TestPicker.INTERFACESTestPicker.LATEST_EVALTestPicker.TESTENV_CACHETestPicker.TESTMODE_TRIGGERTestPicker.EvalTestTestPicker.QueryTypeTestPicker.StdTestsetTestPicker.SyntaxBlockTestPicker.TestBlockInfoTestPicker.TestBlockInterfaceTestPicker.TestInfoTestPicker.TestModeCompletionProviderREPL.LineEdit.complete_lineTestPicker.add_interface!TestPicker.blocklabelTestPicker.build_info_to_syntaxTestPicker.clean_results_fileTestPicker.clean_sourceTestPicker.clear_testenv_cacheTestPicker.create_repl_test_modeTestPicker.current_pkgTestPicker.eval_in_moduleTestPicker.expr_transformTestPicker.fzf_testblockTestPicker.fzf_testblock_from_filesTestPicker.fzf_testfileTestPicker.get_matching_filesTestPicker.get_preview_dimensionTestPicker.get_test_filesTestPicker.get_testblocksTestPicker.identify_queryTestPicker.init_test_repl_modeTestPicker.ispreambleTestPicker.istestblockTestPicker.pick_testblockTestPicker.preambleTestPicker.prepend_exTestPicker.prepend_preamble_statementsTestPicker.preview_contentTestPicker.print_test_docsTestPicker.remove_ansiTestPicker.replace_interface!TestPicker.run_test_fileTestPicker.run_test_filesTestPicker.save_test_resultsTestPicker.select_test_filesTestPicker.separatorTestPicker.test_mode_do_cmdTestPicker.testblock_listTestPicker.visualize_test_results
TestPicker.INTERFACES — Constant
INTERFACESGlobal 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.
TestPicker.LATEST_EVAL — Constant
LATEST_EVALGlobal 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.
TestPicker.TESTENV_CACHE — Constant
TESTENV_CACHECache 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.
TestPicker.TESTMODE_TRIGGER — Constant
Trigger key to get into test mode.
TestPicker.EvalTest — Type
EvalTestContainer 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.
TestPicker.QueryType — Type
QueryTypeEnumeration of different types of test queries supported by the test REPL mode.
TestPicker.StdTestset — Type
StdTestset <: TestBlockInterfaceStandard 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.
TestPicker.SyntaxBlock — Type
SyntaxBlockA 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.
TestPicker.TestBlockInfo — Type
TestBlockInfoMetadata 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.
TestPicker.TestBlockInterface — Type
TestBlockInterfaceAbstract 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.
TestPicker.TestInfo — Type
TestInfoContainer 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.
TestPicker.TestModeCompletionProvider — Type
TestModeCompletionProviderCompletion provider for test mode that suggests test file names.
REPL.LineEdit.complete_line — Method
complete_line(::TestModeCompletionProvider, s::LineEdit.PromptState)Provide completions based on available test file names (without paths).
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.
TestPicker.blocklabel — Method
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.
TestPicker.build_info_to_syntax — Method
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:
- From test block metadata to syntax information
- From human-readable display strings (for fzf) to test block metadata
TestPicker.clean_results_file — Method
This empty the file before appending new results.
TestPicker.clean_source — Method
Obtain the source from the LineNumberNode.
TestPicker.clear_testenv_cache — Method
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.
TestPicker.create_repl_test_mode — Method
create_repl_test_mode(repl::AbstractREPL, main::LineEdit.Prompt) -> LineEdit.PromptCreate 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.
TestPicker.current_pkg — Method
current_pkg() -> PackageSpecGet 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.
TestPicker.eval_in_module — Method
eval_in_module(eval_test::EvalTest, pkg::PackageSpec) -> NothingExecute 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.
TestPicker.expr_transform — Method
expr_transform(interface::TestBlockInterface, ex::Expr)::ExprTransform 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.
TestPicker.fzf_testblock — Method
fzf_testblock(interfaces, fuzzy_file, fuzzy_testset) -> NothingInteractive test block selection and execution workflow using fzf.
Provides a two-stage fuzzy finding process:
- Filter test files based on
fuzzy_filequery - Select specific test blocks from filtered files based on
fuzzy_testsetquery
TestPicker.fzf_testblock_from_files — Method
fzf_testblock_from_files(interfaces, matched_files, fuzzy_testset, pkg, root) -> NothingInteractive 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.
TestPicker.fzf_testfile — Method
fzf_testfile(query::AbstractString) -> NothingInteractive 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.
TestPicker.get_matching_files — Method
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.
TestPicker.get_preview_dimension — Function
Utility function to adapt the size of the text width and line position.
TestPicker.get_test_files — Function
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.
TestPicker.get_testblocks — Method
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.
TestPicker.identify_query — Method
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.
TestPicker.init_test_repl_mode — Method
init_test_repl_mode(repl::AbstractREPL) -> NothingInitialize 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.
TestPicker.ispreamble — Method
ispreamble(node::SyntaxNode) -> BoolCheck 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)
TestPicker.istestblock — Method
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.
TestPicker.pick_testblock — Method
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.
TestPicker.preamble — Method
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.
TestPicker.prepend_ex — Method
prepend_ex(ex, new_line::Expr) -> ExprPrepend 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.
TestPicker.prepend_preamble_statements — Method
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.
TestPicker.preview_content — Method
We connect the error with the backtrace to be previewed.
TestPicker.print_test_docs — Method
print_test_docs() -> NothingPrint 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.
TestPicker.remove_ansi — Method
File names come with ansi characters and break stuff...
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.
TestPicker.run_test_file — Method
run_test_file(file::AbstractString, pkg::PackageSpec) -> AnyExecute 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.
TestPicker.run_test_files — Method
run_test_files(files::AbstractVector{<:AbstractString}, pkg::PackageSpec) -> NothingExecute 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.
TestPicker.save_test_results — Method
save_test_results(testset::Test.TestSetException, testinfo::TestInfo, pkg::PackageSpec) -> NothingSave 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.
TestPicker.select_test_files — Function
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)
TestPicker.separator — Method
Separator used by fzf to distinguish the different data components.
TestPicker.test_mode_do_cmd — Method
test_mode_do_cmd(repl::AbstractREPL, input::String) -> NothingExecute 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.
TestPicker.testblock_list — Method
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.
TestPicker.visualize_test_results — Function
visualize_test_results(repl::AbstractREPL=Base.active_repl, pkg::PackageSpec=current_pkg()) -> NothingInteractive 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.