Skip to content

doc: expand the lake test and lint driver section#855

Merged
david-christiansen merged 10 commits into
mainfrom
test-driver-doc
Jun 15, 2026
Merged

doc: expand the lake test and lint driver section#855
david-christiansen merged 10 commits into
mainfrom
test-driver-doc

Conversation

@kim-em

@kim-em kim-em commented May 27, 2026

Copy link
Copy Markdown
Collaborator

This PR expands the "Test and Lint Drivers" chapter in the Lake reference to make lake test and lake lint substantially easier to follow on a first read. The previous text was a single short paragraph that mentioned @[test_driver] once without an example. The new section covers:

  • what a test or lint driver actually is — a target (executable, script, or library) that Lake invokes; Lake itself is not a test framework,
  • exit-code semantics for executable and script drivers, and the elaboration-error contract for library drivers,
  • a verified lakefile.toml example for both testDriver and lintDriver,
  • prose instructions for the equivalent lakefile.lean configuration (without a code example, since the surrounding chapter is currently in a :::TODO because importing Lake's attributes crashes the compiler),
  • the single-driver constraint and the conflict between the attribute and the configuration field,
  • the <pkg>/<name> syntax for drivers defined in dependency packages,
  • how testDriverArgs and lintDriverArgs compose with arguments passed after -- on the command line,
  • the restriction that library test drivers do not accept arguments,
  • notes on lake check-test and lake check-lint.

Motivated by a recent Zulip thread asking for better documentation:
https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Using.20.60lake.20test.60.20effectively/near/598083186

🤖 Prepared with Claude Code

kim-em and others added 2 commits May 28, 2026 00:20
This PR expands the "Test and Lint Drivers" chapter in the Lake reference
to cover what a test or lint driver actually is (a target — executable,
script, or library — not a test framework), with verified `lakefile.toml`
examples and prose instructions for `lakefile.lean`. New material:

* exit-code semantics for executable/script drivers and the elaboration-error
  contract for library drivers,
* configuring with `testDriver`/`lintDriver` versus `@[test_driver]`/
  `@[lint_driver]` attributes, including the single-driver constraint,
* the `<pkg>/<name>` syntax for drivers in dependency packages,
* `lake test` and `lake lint` argument handling, including how
  `testDriverArgs`/`lintDriverArgs` compose with arguments after `--`,
* the library-driver argument restriction,
* notes on `lake check-test` and `lake check-lint`.

🤖 Prepared with Claude Code
Vale flagged em dashes with surrounding spaces and the bare word
'lakefile'. Rewrite the prose without em dashes and replace 'in the
same lakefile'/'in the lakefile' with 'in the same configuration'/
elided forms that Vale accepts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Address review feedback on the previous draft:

* Add a paragraph explaining that `lake lint` also runs Lake's builtin
  linter when enabled, and that positional `MODULE` arguments go to the
  builtin linter, not to the configured driver. `lake lint Mathlib` and
  `lake lint -- Mathlib` are different things.
* Note that `check-lint` exits 0 also when `builtinLint := true` is set.
* Fix the opening sentence of "Test and Lint Drivers" to acknowledge that
  library test drivers are exercised by elaboration, not run.
* Reword "drivers in dependencies aren't run" as "Lake doesn't automatically
  run each dependency package's driver" so that the `<pkg>/<name>` form,
  covered later, doesn't read as a contradiction.
* Soften "the attribute form is the more common style" to "often
  convenient".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
mathlib-bors Bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Jun 1, 2026
This PR configures the `mathlib` package so that the standard `lake lint` command is equivalent to `lake exe runLinter Mathlib`, by setting

```
lintDriver := "batteries/runLinter"
lintDriverArgs := #["Mathlib"]
```

on the `package mathlib` declaration. `runLinter` is already a `lean_exe` in batteries, so the `<pkg>/<name>` syntax lets mathlib reuse it directly.

The CI workflows in `build_template.yml` and `nolints.yml` are also switched from invoking `lake exe runLinter [args] Mathlib` to `lake lint -- [args]` so there's a single source of truth for "lint mathlib", and so that local users get the same behaviour as CI.

### Behavior change for local users

Before this PR, `lake lint` in a Mathlib checkout errored out with "no lint driver configured" and was essentially unused. After this PR, `lake lint` runs the full Batteries linter over all of Mathlib, which is a substantial multi-minute job. Anyone who has scripts or muscle memory expecting `lake lint` to be a no-op should be aware. The previous direct invocation, `lake exe runLinter Mathlib`, continues to work for anyone who prefers it.

The `scripts/bench/lint/` benchmark intentionally keeps the direct `lake exe runLinter Mathlib` invocation so its measurements are not affected by anything `lake lint` may do above the linter.

Motivated by a recent Zulip discussion in which it became clear that very few people know `lake lint` exists, partly because few packages bother to configure a lint driver:
https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Using.20.60lake.20test.60.20effectively

Companion to leanprover/reference-manual#855 (which documents the mechanism in the Lean reference manual).

🤖 Prepared with Claude Code
b-mehta pushed a commit to b-mehta/mathlib4 that referenced this pull request Jun 2, 2026
This PR configures the `mathlib` package so that the standard `lake lint` command is equivalent to `lake exe runLinter Mathlib`, by setting

```
lintDriver := "batteries/runLinter"
lintDriverArgs := #["Mathlib"]
```

on the `package mathlib` declaration. `runLinter` is already a `lean_exe` in batteries, so the `<pkg>/<name>` syntax lets mathlib reuse it directly.

The CI workflows in `build_template.yml` and `nolints.yml` are also switched from invoking `lake exe runLinter [args] Mathlib` to `lake lint -- [args]` so there's a single source of truth for "lint mathlib", and so that local users get the same behaviour as CI.

### Behavior change for local users

Before this PR, `lake lint` in a Mathlib checkout errored out with "no lint driver configured" and was essentially unused. After this PR, `lake lint` runs the full Batteries linter over all of Mathlib, which is a substantial multi-minute job. Anyone who has scripts or muscle memory expecting `lake lint` to be a no-op should be aware. The previous direct invocation, `lake exe runLinter Mathlib`, continues to work for anyone who prefers it.

The `scripts/bench/lint/` benchmark intentionally keeps the direct `lake exe runLinter Mathlib` invocation so its measurements are not affected by anything `lake lint` may do above the linter.

Motivated by a recent Zulip discussion in which it became clear that very few people know `lake lint` exists, partly because few packages bother to configure a lint driver:
https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Using.20.60lake.20test.60.20effectively

Companion to leanprover/reference-manual#855 (which documents the mechanism in the Lean reference manual).

🤖 Prepared with Claude Code
@david-christiansen

Copy link
Copy Markdown
Collaborator

Sorry for the slow turnaround here!

I went through and added some more tests/examples and did some light prose editing. I'd like to look at it once more with fresh eyes before a merge.

Bergschaf pushed a commit to Bergschaf/mathlib4 that referenced this pull request Jun 3, 2026
This PR configures the `mathlib` package so that the standard `lake lint` command is equivalent to `lake exe runLinter Mathlib`, by setting

```
lintDriver := "batteries/runLinter"
lintDriverArgs := #["Mathlib"]
```

on the `package mathlib` declaration. `runLinter` is already a `lean_exe` in batteries, so the `<pkg>/<name>` syntax lets mathlib reuse it directly.

The CI workflows in `build_template.yml` and `nolints.yml` are also switched from invoking `lake exe runLinter [args] Mathlib` to `lake lint -- [args]` so there's a single source of truth for "lint mathlib", and so that local users get the same behaviour as CI.

### Behavior change for local users

Before this PR, `lake lint` in a Mathlib checkout errored out with "no lint driver configured" and was essentially unused. After this PR, `lake lint` runs the full Batteries linter over all of Mathlib, which is a substantial multi-minute job. Anyone who has scripts or muscle memory expecting `lake lint` to be a no-op should be aware. The previous direct invocation, `lake exe runLinter Mathlib`, continues to work for anyone who prefers it.

The `scripts/bench/lint/` benchmark intentionally keeps the direct `lake exe runLinter Mathlib` invocation so its measurements are not affected by anything `lake lint` may do above the linter.

Motivated by a recent Zulip discussion in which it became clear that very few people know `lake lint` exists, partly because few packages bother to configure a lint driver:
https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Using.20.60lake.20test.60.20effectively

Companion to leanprover/reference-manual#855 (which documents the mechanism in the Lean reference manual).

🤖 Prepared with Claude Code
@david-christiansen david-christiansen added this pull request to the merge queue Jun 12, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 12, 2026
@david-christiansen david-christiansen added this pull request to the merge queue Jun 14, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Preview for this PR is ready! 🎉 (also as a proofreading version). built with commit 00dfd62.

@david-christiansen david-christiansen added this pull request to the merge queue Jun 15, 2026
Merged via the queue into main with commit 7745381 Jun 15, 2026
10 checks passed
@david-christiansen david-christiansen deleted the test-driver-doc branch June 15, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

HTML available HTML has been generated for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants