在我的lint和单元测试之间,我想检查是否有任何php文件生成任何输出。
我正在尝试这样的事情,这显然不起作用:
.PHONY: php_inc
php_inc:
ifneq (,$(shell php -e src/*inc))
$(error PHP include files should not have any output when parsed)
endif
关于如何写这个的建议,或者更好的方法来解决问题?
您可以这样做,以避免执行两次php
:
@output=`php -e src/*inc`; '
if [ ! -z "$$output" ]; then '
echo "PHP include files should not output. Got:"; '
echo $$output; '
exit 1; '
fi
我不知道在什么时候输出会变得太大而无法处理。每当我不得不解决那些我必须根据输出而不是退出状态来检查状态的工具时,输出相当适中。
记录了我目前的工作:
@if [ ! -z "`php -e src/*inc`" ]; then '
echo "PHP include files should not output. Got:"; '
php -e src/*inc; '
exit 1; '
fi
或者更像化妆...但我喜欢那里的引号。给我温暖的安全感:)
@if [ ! -z $(shell $(PHP) -e src/*inc) ]; then '