diff --git a/tests/batch.sh b/tests/batch.sh index eb6ba99..1831b92 100755 --- a/tests/batch.sh +++ b/tests/batch.sh @@ -2,6 +2,7 @@ #该脚本在目录下为每个Cargo项目执行相同的命令直到报错 # All arguments passed to this script are forwarded to cargo rap +# Example: batch.sh -F -M cur=$(pwd) @@ -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