diff --git a/AGENTS.md b/AGENTS.md index 8982617..c12d1ea 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,6 +9,9 @@ contract, migrations, assets, and tests owned by this repo. `scripts/plugin test`, `scripts/plugin precommit`, and `scripts/plugin smoke`. - Use `devenv shell -- ` when running repo commands from outside the devenv shell. +- Raw `mix test` is not the normal entrypoint for this repo; `plugin test` + invokes `mix raw_test` with the host database/services and host + plugin-manager paths. - Keep browser assets under the plugin asset pipeline and avoid host app internals unless the plugin API requires them. diff --git a/README.md b/README.md index 98c3115..c9226c4 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Install deps and run the test suite: ```bash mix deps.get -mix test +scripts/plugin test ``` If you are using the shared `tribes` devenv, run the plugin through the local `plugin` helper instead: @@ -46,7 +46,6 @@ That means the normal loop is: ```bash cd /path/to/tribes-plugin-aether mix deps.get -mix test # in another terminal cd /path/to/tribes @@ -61,6 +60,11 @@ plugin test plugin precommit ``` +Use `plugin test` / `plugin precommit` for host-backed tests. Plain `mix test` +and `mix precommit` print this guidance; use `mix raw_test` / +`mix raw_precommit` only for deliberate low-level debugging after setting the +same host environment yourself. + ## Project Structure ``` diff --git a/mix.exs b/mix.exs index 551e317..4477981 100644 --- a/mix.exs +++ b/mix.exs @@ -16,7 +16,7 @@ defmodule Aether.MixProject do def cli do [ - preferred_envs: [precommit: :test] + preferred_envs: [precommit: :test, raw_precommit: :test, raw_test: :test] ] end @@ -53,20 +53,6 @@ defmodule Aether.MixProject do defp tribes_deps(:test), do: [{:tribes, path: "../tribes", only: :test}] defp tribes_deps(_), do: [] - defp aliases do - [ - test: ["test"], - lint: ["format --check-formatted", "credo"], - precommit: [ - "format", - "compile --warnings-as-errors", - "credo --strict --all", - "deps.unlock --unused", - "test" - ] - ] - end - defp usage_rules do [ file: "AGENTS.md", @@ -87,4 +73,40 @@ defmodule Aether.MixProject do ] ] end + + defp aliases do + [ + test: &plugin_test_message/1, + raw_test: &raw_test/1, + lint: ["format --check-formatted", "credo"], + precommit: &plugin_precommit_message/1, + raw_precommit: &raw_precommit/1 + ] + end + + defp plugin_test_message(_args) do + Mix.raise(""" + This plugin test suite is host-backed. Use `plugin test` or `scripts/plugin test`. + + For low-level debugging only, set up the host environment yourself and run `mix raw_test`. + """) + end + + defp plugin_precommit_message(_args) do + Mix.raise(""" + This plugin precommit is host-backed. Use `plugin precommit` or `scripts/plugin precommit`. + + For low-level debugging only, set up the host environment yourself and run `mix raw_precommit`. + """) + end + + defp raw_precommit(args) do + Mix.Task.run("format") + Mix.Task.run("compile", ["--warnings-as-errors"]) + Mix.Task.run("credo", ["--strict", "--all"]) + Mix.Task.run("deps.unlock", ["--unused"]) + raw_test(args) + end + + defp raw_test(args), do: Mix.Tasks.Test.run(args) end