Skip to content

Commit

Permalink
test: save output to rap.txt and display it if error
Browse files Browse the repository at this point in the history
  • Loading branch information
zjp-CN committed Dec 26, 2024
1 parent a1fd766 commit 1a24dc0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.vscode/
target/
Cargo.lock
rap.txt
7 changes: 5 additions & 2 deletions tests/batch.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
#该脚本在目录下为每个Cargo项目执行相同的命令直到报错

cur=$(pwd)

# 查找并编译当前目录下的所有 Rust 项目
find support -type f -name "Cargo.toml" | while read -r cargo_file; do
# 获取 Cargo.toml 文件所在的目录
Expand All @@ -20,12 +22,13 @@ find support -type f -name "Cargo.toml" | while read -r cargo_file; do
#脚本有参数时按照给定参数执行cargo命令
#Example: batch.sh rap -uaf
cmd="cargo rap $@"
$cmd 2>&1 | grep 'RAP|WARN|'
$cmd 2>&1 | tee $cur/rap.txt | grep 'RAP|WARN|'
fi

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

0 comments on commit 1a24dc0

Please sign in to comment.