VSCode に Makefile のタスクを追加する

結論

.vscode/tasks.json を追加すれば良い

github.com

流れ

Configure 開く
f:id:lesamoureuses:20200116125630p:plain

Create tasks.json する
f:id:lesamoureuses:20200116125635p:plain

Others 選ぶ
f:id:lesamoureuses:20200116125649p:plain

tasks.json の雛形ができるのでこんな感じで書き換え
( ${relativeFile} みたいにすると「現在開いてるファイルの相対 path 」が取れる)

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "make: test current file",
            "type": "shell",
            "command": "make",
            "args": [
                "test",
                "path=${relativeFile}"
            ],
            "presentation": {
                "panel": "dedicated",
                "clear": true,
                "focus": true
            }
        }
    ]
}

Run Task 実行
f:id:lesamoureuses:20200116125659p:plain

tasks.json につかした label が表示されているのでそれを実行
f:id:lesamoureuses:20200116125706p:plain

こんな感じで下に表示される
f:id:lesamoureuses:20200116125711p:plain