Skip to content

Commit

Permalink
fix: detect ERROR report in batch.sh
Browse files Browse the repository at this point in the history
exit if rap errs even if WARN is got
  • Loading branch information
zjp-CN committed Dec 26, 2024
1 parent bb8ff27 commit dda8d8c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions tests/batch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#该脚本在目录下为每个Cargo项目执行相同的命令直到报错

# All arguments passed to this script are forwarded to cargo rap
# Example: batch.sh -F -M

cur=$(pwd)

Expand All @@ -21,20 +22,24 @@ find support -type f -name "Cargo.toml" | while read -r cargo_file; do
cmd="cargo clean"
$cmd
else
#脚本有参数时按照给定参数执行cargo命令
#Example: batch.sh rap -uaf
cmd="cargo rap $@"
$cmd 2>&1 | tee $cur/rap.txt | ansi2txt | grep 'RAP|WARN|' && echo -e "\033[32m$project_dir pass\033[0m"
fi

# 返回原始目录
popd >/dev/null

if [ $? -ne 0 ]; then
# 如果命令失败,打印错误信息并退出循环
echo -e "Error: '$cmd' failed in $project_dir \nRAP output:"
echo -e "Error: '$cmd' doesn't emit WARN diagnostics in $project_dir \nRAP output:"
cat $cur/rap.txt
exit 1
fi

cat $cur/rap.txt | ansi2txt | grep 'RAP|ERROR|'
if [ $? -eq 0 ]; then
echo -e "Error: '$cmd' contains error message in $project_dir \nRAP output:"
cat $cur/rap.txt
popd >/dev/null
exit 1
fi

# 返回原始目录
popd >/dev/null
done

0 comments on commit dda8d8c

Please sign in to comment.