英文:
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$”时,一切都按预期工作。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论