所以我正在编写一个git钩子,它调用脚本在后台运行一些测试。问题是当测试失败时,脚本永远不会超出exec。
脚本的开始
#!/usr/bin/env bash
set -x
## 4 ##
full_path="$1/$2"
cd $full_path
BODY=""
make > build.log 2> build.error
if [ $? -eq 0 ]; then
## 5 ##
PASSED=0
FAILED=0
for line in $(find . -name '*test*' -executable -type f); do
out="${line:2}.log"
error="${line:2}.error"
exec $line > $out 2> $error
echo "I AM ALIVE"
if [ $? -eq 0 ]; then
((PASSED++))
else
((FAILED++))
错误文件的内容
cat tree_insert_test.error
tree_insert_test: p2.cpp:69: tree_t insert_tree(int, tree_t): Assertion `false' failed.