mocha - Forward command-line arguments to Makefile -


i have makefile wrapping around mocha can called npm test. there several targets in makefile, looks like:

compilers = --compilers coffee:coffee-script/register reporter = --reporter dot test_dir = test src = -name test_*.coffee runner = ${test_dir}/runner.coffee mocha = node_env=test ./node_modules/mocha/bin/mocha ${compilers} ${reporter} ${runner} ${test_dir}  all:     $(mocha) $(shell find ${test_dir} ${src})  subtest1:     $(mocha) $(shell find ${test_dir}/subtest1 ${src})  ... 

now, being called package.json npm test npm test subtest1 runs subtest1. however, nice allow appending arbitrary mocha flags, like:

make subtest1 -g "some test want run" 

this can done defining args variable, typing:

make subtest1 args="-g 'some test want run'" 

but that's quite verbose.

therefore, passing arguments through mocha nice.

the closest i've come defining args @ top of makefile:

args = $(filter-out subtest1, $(makecmdgoals)) 

and appending args mocha variable. can called make subtest1 -- -g "some test want run". works, runs test, make stops make: *** no rule make target-g'. stop.`

that same error message presented when doing make -- -g "some test want run".

so, there way continue down args path , somehow suppress make attempting run targets found in args, , therefore allowing both all run, , error message not appear? or should change tack , there's other way of doing this?

you might able away adding dummy rule each argument, this:

$(args): 

however should not reading arguments makecmdgoals, cause sorts of problems.

you instead use script or define aliases in shell. here's rule can that:

shortcut-%:     @echo '$* () { make -c "$(curdir)" -f $(abspath $(firstword $(makefile_list))) $* args="$$(printf "%q " "$$@")"; }' 

use this:

eval `make shortcut-subtest1` subtest1 -g test 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -