【发布时间】:2015-11-11 21:10:10
【问题描述】:
我有以下 Makefile 脚本,它调用一个 python 测试套件,将结果写入一个名为 test_results.txt 的文件。然后我显示文件并读取最后一行,该行的状态指示是否所有测试用例都已执行。基于该值,我回应了一个声明。
target: test.py
$(PYTHON) test.py
@cat test/test_results.txt
@if [ $(shell sed -e '$$!d' test/test_results.txt) = 0 ]; then\
echo "\nAll tests passed successfully";\
else \
echo "\nNot all the tests were passed";\
fi
当我运行它时,我收到以下错误:0/bin/sh: 1: [: =: unexpected operator
【问题讨论】:
-
不要在食谱中使用
$(shell)。时机不对。只需使用普通 shell$()命令替换即可。 -
这个问题与CMake有关吗?如果没有,请删除
cmake标签。