mix schooner.check (schooner v1.2.0)

Copy Markdown View Source

Checks Scheme scripts for problems without running them, with Schooner.check/3.

$ mix schooner.check "scripts/**/*.scm" --env MyApp.Scripts.environment
scripts/discounts.scm:1:9: error[unknown_library]: library not found: (myapp promos)
scripts/draft.scm:1:27: error[unbound]: unbound variable: unit-prise
2 errors in 2 files

Each argument is a file, a directory (every .scm file under it) or a glob. Quote globs so the task expands them rather than the shell. The task fails when an argument matches no files.

Options

  • --env Mod.fun — check against the Schooner.Environment returned by the zero-arity function Mod.fun. Without it, the environment is the one configured with

    config :schooner, :tooling_environment, {Mod, :fun, args}

    and without that, every standard library, all imported: the surface Schooner.run/1 gives a script that imports nothing. Prefer your application's real environment, which is usually much narrower.

  • --format text|json — text (the default) prints one line per diagnostic, file:line:col: severity[code]: message, and a summary. json prints one JSON object:

    {"diagnostics": [{"file": "scripts/draft.scm", "line": 1, "column": 27,
                      "severity": "error", "code": "unbound",
                      "message": "unbound variable: unit-prise"}],
     "errors": 1, "warnings": 0, "files": 2}

    files counts the files checked. line and column are null when the position is unknown. The task keeps compiler progress out of the JSON, but Mix may compile dependencies before the task starts, so run mix compile first when another program reads the output.

  • --warnings-as-errors — fail when there are warnings, too.

The task exits with status 1 when it finds an error, and 0 otherwise.