Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: detect ERROR report in batch.sh #86

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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