Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Duckdb Duckdb Make Unit Test Targets

From Leeroopedia


Overview

Concrete tool for running DuckDB's unit tests via Makefile convenience targets.

The DuckDB Makefile provides two primary test invocation targets: make unittest for debug build testing and make allunit for release build full-suite testing. These targets abstract away the underlying test executable invocation and build configuration, giving developers a simple interface for build verification.

Code Reference

Source Locations

Component Location
unittest Makefile target Makefile:L393-394
allunit Makefile target Makefile:L406-407
Test entry point test/unittest.cpp

Makefile Target Definitions

# Run unit tests in debug mode with default filter
unittest:
	build/debug/test/unittest

# Run all tests in release mode (no filter restriction)
allunit:
	build/release/test/unittest "*"

Test Entry Point (test/unittest.cpp)

The unittest.cpp file serves as the main entry point for the test runner. It:

  1. Initializes the DuckDB test framework.
  2. Discovers all registered test cases.
  3. Applies any filter or tag restrictions passed via command-line arguments.
  4. Executes matching tests and reports results to stdout.
  5. Returns exit code 0 on success, non-zero on failure.

API

Target Build Configuration Test Filter Description
make unittest Debug Default (core tests) Runs the standard unit test suite against a debug build
make allunit Release "*" (all tests) Runs the complete test suite including all test categories against a release build

Parameters

Parameter Applies To Description
(default filter) unittest Runs the default subset of core unit tests; no explicit filter argument is passed
"*" allunit Wildcard filter that matches all registered test cases
--select-tag release Both (manual) Optional flag to restrict execution to tests tagged for release verification

I/O Contract

Inputs

Input Description
Built test executable build/debug/test/unittest (for make unittest) or build/release/test/unittest (for make allunit)
Test SQL files SQL test definitions located under test/sql/ directory tree
Test data files Any fixture data files referenced by test cases

Outputs

Output Description
stdout Test execution progress and results: test names, pass/fail status, timing, and summary
Exit code 0 All tests passed -- build is verified
Exit code non-zero One or more tests failed -- build verification failed

Example Output

[1/1425] test/sql/types/test_integer.test
[2/1425] test/sql/types/test_varchar.test
...
[1425/1425] test/sql/optimizer/test_cse_optimizer.test

ALL TESTS PASSED

Usage Examples

Run Standard Unit Tests (Debug)

# First ensure the debug build is up to date
make debug

# Run the default unit test suite
make unittest

This builds the project in debug mode (with assertions enabled) and runs the core test suite.

Run All Tests (Release)

# First ensure the release build is up to date
make release

# Run all tests against the release build
make allunit

This runs the complete test suite against an optimized release build, catching any optimization-related regressions.

Run Tests With Tag Filter

# Run only tests tagged for release verification
build/release/test/unittest --select-tag release

This restricts execution to tests explicitly tagged as release-critical, useful for faster pre-release smoke testing.

Run a Specific Test

# Run a single named test
build/debug/test/unittest "test/sql/types/test_integer.test"

This executes only the specified test case, useful during development when iterating on a specific feature or bug fix.

Run Tests Matching a Pattern

# Run all optimizer tests
build/debug/test/unittest "test/sql/optimizer/*"

The test runner supports glob-style patterns for selecting subsets of tests by path or name.

Related

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment