Post · 2 min read· pp. 78–79

Build and test

DocsCLI

Build, test and clean the packages of a source workspace with as2 build, as2 test and as2 clean.

Authored by

  • @alvgaona

These commands run colcon in the workspace, so they work from any directory. They need a ROS 2 distro loaded, and stop with ROS_DISTRO is not set otherwise.

Build

as2 build builds the whole workspace. Given package names, it builds those packages and every package they depend on:

text
as2 build
as2 build as2_motion_controller
FlagWhat it does
-d, --debugBuilds in debug mode instead of release
-v, --verboseShows the compiler's output as it runs

The build always uses --symlink-install, so changes to existing Python, launch and configuration files take effect without rebuilding. New files still need a build. After a build, open a new terminal or source setup_env.bash again to pick up new packages.

Building a single package sources the workspace's install/setup.bash first, and stops if it doesn't exist yet. Run a full as2 build once in a fresh workspace.

Test

as2 test runs the tests of the whole workspace and prints a summary of the results. Given a package, it only runs that package's tests:

text
as2 test
as2 test as2_core

With -v, colcon's full output is shown as the tests run, and the summary is left out. The package has to be built before its tests can run.

Clean

as2 clean removes build output. It asks for confirmation first, and only goes ahead on y:

text
as2 clean as2_core as2_msgs
as2 clean -a

Given package names, it removes each package's folders in build and install, plus the workspace's whole log folder. A name that isn't a package in the workspace stops the command, leaving the packages after it as they were.

-a removes the workspace's build, install and log folders. Rebuild with as2 build afterwards.

Last updated on November 11, 2026

[diagram

Overview

The as2 command for building, testing and moving around a source workspace, and fetching example projects.](018_2026-12-05_cli.md)[diagram

Packages and folders

List the packages in a source workspace with as2 list, and jump to their folders with as2 cd.](020_2026-12-05_packages.md)