scalameta / metals-zed

Zed plugin for Metals
Apache License 2.0
56 stars 12 forks source link

feat: add support for test runner with scala-test #29

Closed imclem closed 1 month ago

imclem commented 1 month ago

Hi there 👋

I'm not sure if it's the appropriate way to do it, but I wanted to run the tests from within ZED and got it working using the query in this commit. (Here's a video showing it in action: https://www.loom.com/share/f3c286309e064774a7a8872b5b68a99e)

This is my tasks.json

[
  {
    "label": "run tests with bloop",
    "name": "run-bloop-test",
    "command": "./run-bloop-test.sh ${ZED_WORKTREE_ROOT} ${ZED_FILE}",
    "working_directory": "${workspace_root}",
    "environment": {
      "PATH": "${env.PATH}"
    },
    "keystroke": "cmd-shift-r",
    "tags": ["scala-test"]
  }
]

And the run-bloop-test.sh script: I've haven't added guards or proper opt parsing or anything, I just wanted to hack my way around running the tests from zed:

#!/bin/bash

project_name=$(basename $1)
filename=$(basename $2 | sed 's/\.scala//')
bloop test $project_name -o "*$filename*"
imclem commented 1 month ago

Let's merge it then. If you're interested we could add some more docs in here or in Metals under Zed (I don't think we have anything yet)

@tgodzik I'll gladly add some documentation, please let me know where ? In the README.md in this project and in metals ?

tgodzik commented 1 month ago

You can add it in the README

Or if you feel like it we can add a page for Zer in https://github.com/scalameta/metals/tree/main/docs/editors