build-and-test

Build the Motoko compiler with dune and run regression tests via test-runner.

588|127|Updated May 11, 2018
One-click install
npx skills add https://github.com/caffeinelabs/motoko --skill build-and-test-caffeinelabs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: build-and-test
Source: https://github.com/caffeinelabs/motoko/tree/main/.agents/skills/build-and-test
Command: npx skills add https://github.com/caffeinelabs/motoko --skill build-and-test-caffeinelabs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps developers reliably compile the Motoko compiler and validate changes by running the correct test suites in the right environment, reducing time lost to setup issues and inconsistent tooling.

Core Features & Use Cases

  • Deterministic build workflow: Builds moc and related native/JS artifacts using the repo’s dune configuration and nix-direnv environment.
  • Correct test execution with guardrails: Runs tests via test-runner from the repo root using batch mode, including category-appropriate flags (e.g., fail/, run/, run-drun/).
  • Change verification for OCaml and compiler code: Targets the common development scenario of verifying compiler behavior after modifying OCaml source files.

Quick Start

Run cd "$(git rev-parse --show-toplevel)" && eval "$(direnv export bash 2>/dev/null)" && unalias moc 2>/dev/null && dune build --root src exes/moc.exe && test-runner -baf fail/.

Frequently Asked Questions about build-and-test

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build the Motoko compiler and run regression tests after changing OCaml code?

To build the Motoko compiler and run regression tests, use the nix-direnv environment to execute `dune build --root src` for compilation, then run the `test-runner` in batch mode from the repository root to validate your OCaml changes.

What is the correct way to run the Motoko test-runner for fast fail suites?

The correct way to run the Motoko test-runner for fast fail suites is to execute `test-runner -baf fail/` from the repository root. Batch mode and acceptance flags automatically update expected outputs instead of requiring manual file edits.

How do I update expected test outputs in the Motoko compiler repository?

To update expected test outputs in the Motoko compiler repository, use the acceptance flag (`-a`) with the `test-runner` command. This automatically applies the new expected outputs rather than manually editing the test files.

Do I need nix-direnv to compile moc and run dune build targets?

Yes, you need nix-direnv to compile `moc` and run dune build targets. The deterministic build workflow relies on the repo's dune configuration combined with the nix-direnv environment to ensure correct compilation and avoid tooling inconsistencies.

Why are my Motoko regression tests failing when run outside the repository root?

Motoko regression tests fail outside the repository root because the `test-runner` workflow must be executed from the top level. Running it elsewhere breaks the required relative paths for test categories like `fail/`, `run/`, and `run-drun/`.

What test categories can I run with the Motoko test-runner?

You can run category-appropriate test suites with the Motoko test-runner by specifying directories like `fail/`, `run/`, and `run-drun/`. This targets specific regression tests based on your compiler development needs.