magus v0.4.2 is out. See what's new
¶ View generated markdown
3 min read

buzz

The buzz spell checks and tests Buzz sources. Each op finds every .buzz file and runs buzz --check, buzz --test, or the magus interpreter over it.

Runtime name: buzz (source spells/buzz/)

Version probe: none

Passing arguments to ops

Every op is invoked as buzz["<op>"](ctx, opts?). The first argument is the target's context, which is what carries the execution environment; the optional options map shapes the command itself:

Key Type Description Source
args [str] Extra arguments appended to the resolved command, replacing any trailing defaults the op declares (go-test's ./...), so passing args also states the scope. Omit it and a bare buzz["<op>"]() keeps the defaults and forwards magus run <target> -- <extra> to the tool automatically; pass it to set the arguments explicitly, which replaces that passthrough. source
stdin str Data written to the command's standard input. source

Working directory and environment are NOT options: they ride the context, as buzz["<op>"](ctx.withCwd("sub")) and buzz["<op>"](ctx.withEnv({"CGO_ENABLED": "0"})). Only the context reaches the cache key, so an option-table cwd or env would change what the tool did while the key said otherwise; passing either as an option is an error.

Charms (the :charm suffix, e.g. magus run test:rw) are orthogonal: they patch the base argv, while these options add to it. See Charms.

buzz-check

check type-checks every Buzz source without running it (buzz --check). buzz takes one script per invocation, so sources runs it once PER matched file (sourcesEach = true - the engine-side replacement for the find | xargs -n1 this op used to shell out to; see Command.sources/sourcesEach in spells/op.go). A glob set that matches nothing runs buzz zero times rather than failing.

Command: buzz --check

Example

// buzz-check parses every .buzz file: magus run check runs buzz --check over the tree.
import "magus";
import "magus/spell/buzz";

magus\project({ "spells": [buzz] });

export fun check(ctx: magus\Context, args: [str]) > void {
    buzz["buzz-check"](ctx);
}

buzz-test

test runs each source's Buzz test {} blocks (buzz --test), one file per invocation - see buzzCheck above.

Command: buzz --test

Example

// buzz-test runs the test blocks in every .buzz file via buzz --test.
import "magus";
import "magus/spell/buzz";

magus\project({ "spells": [buzz] });

export fun test(ctx: magus\Context, args: [str]) > void {
    buzz["buzz-test"](ctx);
}

magus-buzz

magus-buzz executes each source through magus buzz, magus's own embedded Buzz engine, one file per invocation (see buzzCheck above). It has no check-only mode - executing a file compiles, type-checks, and runs it - so this is the runtime sibling of buzz-check. bin is the literal string "$MAGUS", not a shell variable reference: the runner resolves a bare $NAME token in Bin/Args against the values it controls for this invocation (see resolveRunnerRefs in internal/interp/bindings) - the same resolution that exports MAGUS (à la GNU Make's $(MAKE)) into every spell subprocess's environment - so this always runs the current magus, even uninstalled or under go run, with no dependence on PATH and no shell needed to expand it. (A bare "$MAGUS", not "${MAGUS:-magus}": Buzz reads {...} in a string as interpolation, and this string is never interpolated - it is matched literally.)

Command: $MAGUS buzz

Example

// magus-buzz runs each .buzz file through the magus interpreter.
import "magus";
import "magus/spell/buzz";

magus\project({ "spells": [buzz] });

export fun run_buzz(ctx: magus\Context, args: [str]) > void {
    buzz["magus-buzz"](ctx);
}
generatedspells/buzz/spell.buzzbuzzspellgopherbuzzchecktesttools
Last updated (16372805)
Earlier changes on this page (7)

Full history ↗ · Blame source ↗

Glossary

Project

A directory magus recognizes as a unit of work (it has a magusfile); the unit of caching, scheduling, and dependency tracking. See workspace.

Target

A named operation (build, test, ...) you invoke with magus run <target>; it may compose a spell's tool-native operations and depend on other targets. See targets.

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). See operations.

Spell

A language/runtime adapter (e.g. go, md) that maps generic targets onto a toolchain's real commands. See spells.

Charm

An execution modifier attached with : (lint:rw) that changes how a target runs, not which one; the built-in rw flips a check-only target to mutate in place, and ci always strips it. See charms.

Ward

A coded diagnostic that inspects a resolved op and nudges or blocks an anti-pattern before it runs. See wards.

Buzz

The language magusfiles are written in (the .buzz engine). See engines.

Engine

The interpreter a magusfile runs on; magus embeds the Buzz engine. See engines.

Cache

The content-addressed store magus consults before running a target, so unchanged work is skipped. See cache.

CI

An ordinary magusfile-defined target you compose yourself with magus\needs - magus does not hardcode its stages. Magus.RunCI treats it specially only in that it strips the rw charm, it is the anchor magus affected ci keys off, and a selected scope with no project declaring it is a load error rather than a silent no-op. See targets.

Conventions

Placeholders

Angle brackets mark a value you replace with your own - never type the brackets:

magus run <target>
magus completion <shell>    # e.g. bash, zsh, fish

<target>, <path>, <shell>, <name> and the like are stand-ins, not literal text.