Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ jobs:
# still accept (and get wrong in the documented way).
- name: Caught and uncaught
run: pixi run check

# mojolint must be silent on the post's corrected listing, and must
# flag every case in tests/uncaught/ — the flip side of the step above.
- name: Lint (mojolint --lsp)
run: |
pixi run lint
pixi run lint-uncaught
116 changes: 116 additions & 0 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,23 @@ run-post = { cmd = "mkdir -p build && mojo build src/post.mojo -o build/post &&
# Deliberate misuse: what the compiler rejects, and what it lets through.
check = { cmd = "bash tests/check.sh" }
fmt = { cmd = "mojo format src tests" }
# mojolint (lint-mojo, below): the origin and threading mistakes the compiler
# lets through, with mojo-lsp-server behind the rules. Exit 1 on findings.
# Only src/origins.mojo — the post's corrected listing — is linted here.
# src/post.mojo and tests/uncaught/*.mojo are deliberate positives (see
# tests/lint_uncaught.sh); tests/caught/*.mojo are deliberately rejected by
# the compiler and never reach mojolint at all.
lint = { cmd = "mojolint --lsp -I src src/origins.mojo" }
# The other half of the claim: mojolint must flag every file in
# tests/uncaught/. See tests/lint_uncaught.sh for what "flag" means here.
lint-uncaught = { cmd = "bash tests/lint_uncaught.sh" }

[dependencies]
mojo = "==1.0.0"
# Added by `pixi shelf add threads-mojo`: the tin comes from GitHub as a pixi
# source dependency, pinned at the revision mojoshelf published.
threads-mojo = { git = "https://github.com/magmalake/threads.mojo.git", rev = "1133606d6de0f48039e7ba2b427575b39b0d2010" }
# Added by `pixi shelf add lint-mojo`: the linter comes from GitHub as a pixi
# source dependency pinned at the revision mojoshelf published, and builds
# the `mojolint` executable into every environment next to mojo-lsp-server.
lint-mojo = { git = "https://github.com/magmalake/lint.mojo.git", rev = "2a12807b7847984aff2c8bf148b0eb7515a99844" }
34 changes: 34 additions & 0 deletions tests/lint_uncaught.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# The flip side of tests/check.sh: tests/uncaught/*.mojo are deliberate
# positives for mojolint (lint-mojo) — the origin and threading mistakes the
# compiler lets through, which is the whole point of the post. This asserts
# the linter actually catches all four: `mojolint --lsp -I src tests/uncaught`
# must exit non-zero, and its output must name every file in the directory.
#
# If a file stops being flagged, the linter has regressed on a case the post
# relies on. If mojolint starts exiting 0 here, something is badly wrong.
set -u
cd "$(dirname "$0")/.."
command -v mojolint >/dev/null || { echo "mojolint not on PATH — run as: pixi run lint-uncaught"; exit 2; }

out=$(mojolint --lsp -I src tests/uncaught 2>&1)
status=$?
fail=0

if [ "$status" -eq 0 ]; then
echo "FAIL: mojolint exited 0 on tests/uncaught — expected findings"
fail=1
fi

for f in tests/uncaught/*.mojo; do
name=$(basename "$f")
if grep -qF -- "$name" <<<"$out"; then
echo "ok flagged $name"
else
echo "FAIL: no finding reported for $name"
fail=1
fi
done

echo "$out"
[ "$fail" = 0 ]
Loading