Current section
Files
Jump to
Current section
Files
lib/mix/tasks/firebird.test.ex
defmodule Mix.Tasks.Firebird.Test do
@moduledoc """
Run WASM-related tests.
Finds and runs all test files that use `Firebird.TestHelpers` or
test WASM functionality.
## Usage
mix firebird.test # Run all WASM tests
mix firebird.test --verbose # Verbose output
This is a convenience wrapper around `mix test` that filters for
WASM-related test files.
"""
use Mix.Task
@shortdoc "Run WASM-related tests"
@impl Mix.Task
def run(args) do
# Find test files that reference Firebird or WASM
wasm_tests =
Path.wildcard("test/**/*_test.exs")
|> Enum.filter(fn path ->
content = File.read!(path)
String.contains?(content, "Firebird") or
String.contains?(content, "wasm") or
String.contains?(content, "WASM")
end)
if wasm_tests == [] do
Mix.shell().info("No WASM-related tests found.")
Mix.shell().info("Create tests using Firebird.TestHelpers:")
Mix.shell().info("""
defmodule MyWasmTest do
use ExUnit.Case
import Firebird.TestHelpers
setup_wasm()
test "it works", %{wasm: wasm} do
assert_wasm_result wasm, :add, [5, 3], 8
end
end
""")
else
Mix.shell().info("🔥 Running #{length(wasm_tests)} WASM test file(s)...\n")
Mix.Task.run("test", wasm_tests ++ args)
end
end
end