Builds and Tests
Aember builds your project and runs its tests with the project’s own tools. It reads the errors, warnings and test results from their output and links each one to its place in your code.
Build and Test a Project
Use the Build menu:
| Command | Shortcut | What it does |
|---|---|---|
| Build > Build | ⌘B | Builds the project |
| Build > Test | ⌘U | Runs the project’s tests |
| Build > Stop Build | ⌘. | Stops the build or test run |
| Build > Show Build Log | Opens the build log tab |
The same commands are in the project menu: click the folder button at the top of the navigator, or right-click the project name. They appear there when Aember knows the project’s build system or the project has a .aember/build.json.
Before a build or test run, Aember saves all modified files, because the build tools read the files on disk. To turn this off, clear Save modified files before building in Build Settings. See Build Settings.
A project runs one build or test at a time. While a run goes, the status bar shows what runs and for how long, with a stop button. Click the indicator to open the build log. When the run ends, the status bar shows its outcome, for example “Build failed in 12s: 2 error(s), 1 warning(s)”.
When a run you started fails, the build log opens. To turn this off, clear Show the build log when a build or test run fails in Build Settings.
To stop a run, choose Build > Stop Build, click the stop button in the status bar, or click Stop in the build log. Aember stops the build tool and every process it started.
AI agents can also build and test through Aember when Let agents run builds and tests is selected. Their runs show in the same status bar and build log.
Supported Build Systems
Aember detects the build system from the files in the project folder. When a folder has several, the first in this table wins:
| Build system | Detected by | Build | Test |
|---|---|---|---|
| Swift Package Manager | Package.swift | swift build | swift test |
| Cargo | Cargo.toml | cargo build | cargo test |
| CMake | CMakeLists.txt | cmake --build build | ctest --test-dir build |
| Ninja | build.ninja or rules.ninja | ninja -C dir | ctest, else ninja test |
| Xcode | .xcworkspace or .xcodeproj | xcodebuild build -scheme S | xcodebuild test -scheme S |
| Make | Makefile, makefile or GNUmakefile | make | make test |
| TypeScript | tsconfig.json or jsconfig.json | npx tsc --noEmit | npm test |
| Python | pyproject.toml, setup.py or setup.cfg | none | pytest |
Some details:
- CMake uses the first of
build,cmake-build-debugandcmake-build-releasethat exists, elsebuild. When that folder is not configured yet, Aember runscmake -S . -B buildfirst. - Ninja uses
build.ninjain the project folder, or inbuildorout. Tests usectestwhen the folder has aCTestTestfile.cmake. - Xcode uses the scheme named like the project, else the first scheme
xcodebuild -listgives. - Python projects have no build step. Choose Build > Test instead.
For other projects, and to change any of these commands, write a .aember/build.json. See Customize Build Commands.
Customize Build Commands
Put a file named build.json in the project’s .aember folder to choose the commands Aember runs. Every key is optional:
{
"build": ["make", "-j8"],
"test": ["make", "check"],
"testFilter": ["TESTS={filter}"],
"scheme": "MyApp",
"destination": "platform=macOS",
"configuration": "Debug",
"buildDirectory": "out"
}
| Key | Meaning |
|---|---|
build | The build command, replacing the one Aember would choose |
test | The test command, replacing the one Aember would choose |
testFilter | The arguments added to test to run only some tests. {filter} is replaced with the tests’ name. |
scheme | The Xcode scheme |
destination | The Xcode destination |
configuration | The Xcode build configuration |
buildDirectory | The build folder for CMake and Ninja |
A command is a list: the program, then each argument. Aember runs the program directly, without a shell, so shell features such as &&, pipes and * do not work. The program can be a name Aember finds on your PATH, a path relative to the project folder, or a full path.
If build.json cannot be read, the build does not start, and the build log says why.
The file is meant to be shared with the project. If Aember keeps .aember out of git (Hide .aember directory from git in Git Settings), add it with git add -f .aember/build.json.
Read the Build Log
Choose Build > Show Build Log to open the Build Log tab. It shows the project’s latest build or test run, whether it is running or finished, and whoever started it. It updates as the run prints.
The tab has three parts:
- The header shows the run’s outcome and time, the command that ran, the build environment, and the agent that started it, if an agent did. While the run goes, a Stop button stops it.
- The problems list shows the errors, then the warnings, then the failed tests. Click a place, such as
Sources/App/main.swift:12:5, to open the file at that line. Notes about a problem are listed under it. - The log shows everything the command printed. When you are at the end of the log, it scrolls as new lines arrive. A very long log keeps its first and last lines, and says how many it left out.
When a run fails and no error is recognized, the problems list says so. Read the log for the reason.
Aember recognizes the messages of swiftc, clang, gcc, rustc and cargo, tsc, the linker, Swift Testing, XCTest and cargo test. For Xcode projects it also reads the result bundle xcodebuild writes. For ctest and pytest it reads their JUnit reports.
The build log is read-only and is not saved.
Test Results
When you choose Build > Test, Aember runs all of the project’s tests and collects each test’s outcome. When the run ends, the status bar and the build log header show the counts, for example “Test succeeded in 4s: 52 passed” or “Test failed in 9s: 2 failed, 50 passed”.
Each failed test is listed in the build log’s problems list with a red ✗, its name, and the place where it failed. Click the place to open the file at that line. The failure message is shown under the test.
Aember reads test results from:
- Swift Testing and XCTest output, for Swift packages.
- The result bundle
xcodebuild testwrites, for Xcode projects. - The output of
cargo test, for Rust. - The JUnit reports
ctestandpytestwrite.
AI agents can run a single test or a group of tests. For a custom test command in .aember/build.json, add testFilter so this works. See Customize Build Commands.
Build Environments
Build environments hold the environment variables Aember gives to builds, tests and the tools that make the compilation database. Use them, for example, to set compiler flags in a Makefile or a CMakeLists.txt.
There are two kinds:
- Shared variables go to every run.
- Named environments, such as Debug or Release, add their variables over the shared ones while they are active. A variable in the active environment replaces a shared variable with the same name.
Edit environments
Choose Build > Environment > Build Environments…. The Build Environments dialog lists Shared Variables first, then the named environments.
- Click + (Add an environment) to add an environment. The first is named Debug. Type a new name, then press Return.
- Click the duplicate button (Duplicate the selected environment) to copy the selected environment with its variables.
- Click − (Remove the selected environment) to remove the selected environment. You cannot remove the shared variables.
- To rename a named environment, edit its name in the list.
On the right, the Name and Value table holds the selected entry’s variables. Type in the empty row at the bottom to add one. Press Tab or Return to move to the next cell. Use the table’s + and − buttons to add and remove variables.
Click Save to keep your changes, or Cancel. A name may use letters, digits, -, _ and ., and may not start with .. When a name is not allowed or two environments have the same name, Aember says so and the dialog stays open.
The variables are stored in the project’s .aember folder, in files named after the build system, such as .aember/cmake-env and .aember/cmake-env.Debug.
Choose the Active Environment
Choose the environment from Build > Environment. The menu lists Shared Variables Only, then each named environment. A check mark shows the active one. The same submenu is in the project menu of the navigator.
Choose Shared Variables Only to use no named environment.
The status bar and the build log show the environment a run used.
The active environment is a choice of your own. It is stored in .aember/active-env, apart from the environments themselves. When you rename the active environment, it stays active. When you remove it, no named environment is active.