摩卡咖啡需要做.找不到适用于Windows的make.exe [英] Mocha requires make. Can't find a make.exe that works on Windows
问题描述
Mocha(Node.js的测试框架)使用make.
Mocha (test framework for Node.js) uses make.
在我的生命中,我找不到适用于Windows的兼容make.exe.
For the life of me I can't find a compatible make.exe for Windows.
在Mac上一切正常.
我尝试使用VS的nmake.exe和一个make.exe,我发现它是从Unix移植的.但是它们都是不兼容的.
I've tried using VS's nmake.exe and a make.exe I found that was ported from Unix. But they are all incompatible.
不能只是我
这是makefile:
Here's the makefile:
test:
@./node_modules/.bin/mocha -u tdd -R spec
.PHONY: test
在上制作Barfs.在PHONY中,即使删除它,它也永远不会运行mocha命令(或者至少没有输出).
make barfs on the . in PHONY, and even if I remove it, it never runs the mocha command (or at least there's no output).
运行./node_modules/.bin/mocha -u -tdd -R spec
直接给我我的测试报告:
Running ./node_modules/.bin/mocha -u -tdd -R spec
directly gives me my test report:
first suite -
? ten should always be equal to 9+1
? zero is less all positive numbers
? There is no i in team
? 3 tests complete (8ms)
修改3/25/12
- 最后,解决此问题的最简单方法是使用Cygwin,并确保已安装Cygwin的开发人员软件包.在PowerShell中,我做了
Set-Alias make "c:\dev\utils\cygwin\bin\make.exe"
,现在make test
可以在标准的Mocha Makefile中使用. - In the end, the easiest way to deal with this is to use Cygwin and ensure that the developer packages for Cygwin are installed. In PowerShell I did
Set-Alias make "c:\dev\utils\cygwin\bin\make.exe"
and nowmake test
works on standard Mocha Makefiles.
EDIT 3/25/12
推荐答案
嘿,我觉得你;)我是一个团队的成员,忙于使用node建立一个新的创业公司.我们的两个开发人员在OSX上,一个在Linux上.我在Windows上.
Heh I feel you ;) I'm part of a team busy building a new startup using node. Two of our dev's are on on OSX, one is on Linux. I am on Windows.
我下载并使用了 GNU的为Windows制作" ,现在可以很开心了进行安装和安装测试套件.
I downloaded and use GNU's "Make for Windows" and can now quite happily make our installation & test suites.
此外,我强烈建议您使用PowerShell-它有一堆别名为UNIX友好命令的命令(例如Get-ChildItem-> ls).这样一来,我们的几个脚本就可以在UNIX或Windows上运行而无需更改.
Also, I STRONGLY encourage you to use PowerShell - it has a bunch of commands aliased to UNIX-friendly commands (e.g. Get-ChildItem -> ls). This allows several of our scripts to work on UNIX or Windows without change.
因此,对于您的问题:
尝试使用以下内容替换上面的makefile:
Try replacing your makefile above with the following:
# Detect if we're running Windows
ifdef SystemRoot
# If so, set the file & folder deletion commands:
FixPath = $(subst /,\,$1)
else
# Otherwise, assume we're running *N*X:
FixPath = $1
endif
NODE_MODULES := ./node_modules/.bin/
test:
$(call FixPath, NODE_MODULES)mocha -u tdd -R spec
.PHONY: test
注意:对于Makefile,目标中的任务必须使用制表符而不是空格缩进!快点吧!
Note: with Makefiles, tasks within targets must be indented with tab characters, not spaces! Go figure!!
我从此帖子(感谢Paul :)).如果在Windows上运行,它将用\替换字符串的/.
I stole the FixPath routine from this post (thanks Paul :)). It replaces a string's / with \ if run on Windows.
在Windows上,make的问题之一是它为了执行每个任务而被外壳化到NT的命令外壳(通过CreateProcess).这意味着在执行makefile文件时,Powershell否则会处理的所有 N X-ism(例如ls,cat等)将不起作用.因此,建议用可覆盖的别名替换内联命令,对于NT,您可以将其设置为一个命令,对于 N X,可以将其设置为另一个命令.
One of the problems with make on Windows is that it shells out to NT's command shell (via CreateProcess) in order to execute each task. This means that any NX-isms that Powershell would otherwise handle (e.g. ls, cat, etc.) won't work when executing makefiles. Thus, its advisable to replace inline commands with overridable aliases that you can set to one command for NT and another for NX.
也许我会分叉Gnu Make,看看在执行命令而不是NT命令行时是否可以将它封装到Powershell中.这也将消除对上面的FixPath的需要;)
Perhaps I'll get around to forking Gnu Make and seeing if I can get it to shell out to Powershell when executing commands instead of the NT command line. That would also eliminate the need for FixPaths above ;)
如果遇到问题,请给我Ping;)
Ping me if you get stuck ;)
这篇关于摩卡咖啡需要做.找不到适用于Windows的make.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!