每次执行前提条件 [英] Execute make prerequisite every time
问题描述
我的制作文件:
.PHONY: test-unit test-functional mocha
test: test-unit test-functional
test-unit: SUITE = "unit"
test-unit: mocha
@echo "unit"
test-functional: SUITE = "functional"
test-functional: mocha
@echo "functional"
mocha:
@echo ===== RUNNING TESTS: $(SUITE) =====
我想使用此makefile来运行我的两个测试套件,而不必复制运行套件所需要的代码(抽象到mocha
任务中).但是,Make很聪明,意识到test-functional
在test-functional
上已经运行了,因此不再运行.
I'd like to use this makefile to run both of my test suites without duplicating the code for what it takes to run a suite (abstracted into the mocha
task). However, Make is being smart and realizes that mocha
has already been run when it comes to test-functional
and doesn't run it again.
make test
:
===== RUNNING TESTS: unit =====
unit
functional
是否有更好的方法来实现类似的抽象,或者将mocha
标记为需要每次运行?
Is there a better way to approach this perhaps to achieve similar abstraction, or perhaps flag mocha
as needing to be run every time?
推荐答案
使用mocha任务的正文的"nofollow>罐装食谱,并将其粘贴在两个测试任务中.
Use a Canned Recipe for the body of the mocha
task and stick it in both test tasks.
代替
mocha:
@echo ===== RUNNING TESTS: $(SUITE) =====
test: mocha
使用
define mocha
@echo ===== RUNNING TESTS: $(SUITE) =====
endef
test:
$(mocha)
....
我相信
define mocha =
(或:=
等)要达到4.0以上.
define mocha =
(or :=
etc.) for make 4.0+ I believe.
这篇关于每次执行前提条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!