duanji1026 2015-10-09 15:25
浏览 78
已采纳

Visual Studio代码任务参数

I'm trying to create some tasks in Visual Studio Code to run all the tests in my go project.

I usually execute the tests on the command line using:

go test ./...

In Visual Studio Code my tasks.json looks like this:

{
    "version": "0.1.0",
    "command": "go",

    "tasks": [
        {
            "taskName": "build",
            "isBuildCommand": true
        },
        {
            "taskName": "test",
            "isTestCommand": true,
            "args": ["./..."]
        }
    ]
}

So Build works fine (CTRL + SHIFT + B)

But when I try to run the tests (CTRL + SHIFT + T) the following error occurs:

go: unknown subcommand "./..."

It seems to be omitting the "test" param, but when I comment out the args it runs go test fine.

Any ideas?

  • 写回答

1条回答 默认 最新

  • drvpv7995 2015-10-13 17:09
    关注

    THIS MAY BE A BUG


    VSCode Reverse Args and Task as of v0.8.0

    This may be a bug that still persists in the newer versions. As of v0.9.1 I have not had a chance to test. Prior to 0.9.1 at least one hack worked by reversing the task and it's arg as in the following example:

    {
    "version": "0.1.0",
    "command": "go",
    
    "tasks": [
        {
            "taskName": "build",
            "isBuildCommand": true
        },
        {
            "taskName": "./...",
            "isTestCommand": true,
            "args": ["test"]
        }
      ]
    }
    

    It's hard to believe that this has still persisted until v0.8.0 so there may be a preferred solution that I have not discovered.

    Here is a link to a prior post that deals with a similar issue:

    Define multiple tasks in VSCode

    Scroll down to my answer for more explanation.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器