使用IntelliJ中的文件监视器来运行Makefile。

huangapple go评论92阅读模式
英文:

Use File Watcher in IntelliJ to run Makefile

问题

我想在IntelliJ中每当源文件更改时运行一个Makefile。因此,我安装了File Watcher插件,并为Go文件添加了一个新的文件监视器。在监视器设置中,我将make添加为程序,test添加为参数。

当我现在更改一个.go文件时,我会收到以下错误消息:

make test
make: *** 没有规则可以制作目标 `test'.  停止.

进程以退出代码2结束。

所以我认为文件监视器总体上是起作用的,但是以某种方式在错误的目录中运行了make命令。

当我从项目的根目录在终端中运行make test时,一切都按预期工作,我得到:

格式化所有包...
使用go vet进行代码分析...
使用ginkgo执行测试...
[1490735873] Cmd Suite - 1/1 specs • SUCCESS! 120.183µs PASS
[1490735873] Test Helpers Suite - 4/4 specs •••• SUCCESS! 125.046µs PASS
[1490735873] Models Suite - 5/5 specs ••••• SUCCESS! 453.456µs PASS
[1490735873] Services Suite - 16/16 specs •••••••••••••••• SUCCESS! 3.035275ms PASS

Ginkgo在855.886243ms内运行了4个测试套件
测试套件通过了

我做错了什么,或者我对在IntelliJ中使用文件监视器的目的有什么误解吗?

英文:

I would like to run a Makefile in IntelliJ whenever a source file changes. Therefore I installed the File Watcher plugin and added a new File Watcher for Go files. In the Watcher Settings I added make as the Program and test for the Arguments.

When I now change a .go file, I get the following error message:

make test
make: *** No rule to make target `test'.  Stop.

Process finished with exit code 2

so I assume that the file watcher works in general but is somehow runs the make command in the wrong directory.

When I run make test in a terminal from the root of my project, everything works as expected and I get:

Formatting all packages...
Code analysis with go vet...
Execute test with ginkgo...
[1490735873] Cmd Suite - 1/1 specs • SUCCESS! 120.183µs PASS
[1490735873] Test Helpers Suite - 4/4 specs •••• SUCCESS! 125.046µs PASS
[1490735873] Models Suite - 5/5 specs ••••• SUCCESS! 453.456µs PASS
[1490735873] Services Suite - 16/16 specs •••••••••••••••• SUCCESS! 3.035275ms PASS

Ginkgo ran 4 suites in 855.886243ms
Test Suite Passed

What am I doing wrong - or am I missing the point of using file watchers in IntelliJ?

答案1

得分: 4

解决方法是我需要在“其他选项”中指定“工作目录”。当我将其设置为“$ContentRoot$”时,一切都按预期工作。

使用IntelliJ中的文件监视器来运行Makefile。

英文:

Solution was that I had to specify the Working Directory in Other Options. When I set this to $ContentRoot$, everything works as expected.

使用IntelliJ中的文件监视器来运行Makefile。

huangapple
  • 本文由 发表于 2017年3月29日 05:25:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/43080232.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定