From 76c457163112697b925cd35ccfb99be42e2f0af4 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 12:27:57 +0800 Subject: [PATCH 01/20] chore: move rust-toolchain.toml to root project so we don't need to run with +nightly for all tests --- rap/rust-toolchain.toml => rust-toolchain.toml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename rap/rust-toolchain.toml => rust-toolchain.toml (100%) diff --git a/rap/rust-toolchain.toml b/rust-toolchain.toml similarity index 100% rename from rap/rust-toolchain.toml rename to rust-toolchain.toml From 928c2dd5c63f25105d37c8d431fd1eb08ee04586 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 12:58:40 +0800 Subject: [PATCH 02/20] test: batch.sh exit with 1 if RAP|WARN is not found in rap's output --- tests/batch.sh | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/batch.sh b/tests/batch.sh index 0ccc0ba..4ff509b 100755 --- a/tests/batch.sh +++ b/tests/batch.sh @@ -1,35 +1,35 @@ #!/bin/bash #该脚本在目录下为每个Cargo项目执行相同的命令直到报错 -if [ $# -eq 0 ]; then +# 查找并编译当前目录下的所有 Rust 项目 +find CI_* -type f -name "Cargo.toml" | while read -r cargo_file; do + # 获取 Cargo.toml 文件所在的目录 + project_dir=$(dirname "$cargo_file") + + echo "Processing project in: $project_dir" + + # 切换到项目目录 + pushd "$project_dir" >/dev/null + + if [ $# -eq 0 ]; then #脚本无参数时执行cargo clean #Example: batch.sh cmd="cargo clean" -else + $cmd + else #脚本有参数时按照给定参数执行cargo命令 #Example: batch.sh rap -uaf - cmd="cargo $@" -fi + cmd="cargo rap $@" + $cmd 2>&1 | grep 'RAP|WARN|' + fi -# 查找并编译当前目录下的所有 Rust 项目 -find . -type f -name "Cargo.toml" | while read -r cargo_file; do - # 获取 Cargo.toml 文件所在的目录 - project_dir=$(dirname "$cargo_file") - - echo "Processing project in: $project_dir" - - # 切换到项目目录 - pushd "$project_dir" > /dev/null - - $cmd - if [ $? -ne 0 ]; then - # 如果命令失败,打印错误信息并退出循环 - echo "Error: '$cmd' failed in $project_dir" - popd > /dev/null - exit 1 - fi - - # 返回原始目录 - popd > /dev/null -done + if [ $? -ne 0 ]; then + # 如果命令失败,打印错误信息并退出循环 + echo "Error: '$cmd' failed in $project_dir" + popd >/dev/null + exit 1 + fi + # 返回原始目录 + popd >/dev/null +done From d3058baeca54fa132acdf5db6de410b5dad11be7 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 12:59:29 +0800 Subject: [PATCH 03/20] test: remove redundant batch.sh --- tests/CI_leak/batch.sh | 35 ----------------------------------- tests/CI_uaf/batch.sh | 35 ----------------------------------- 2 files changed, 70 deletions(-) delete mode 100755 tests/CI_leak/batch.sh delete mode 100755 tests/CI_uaf/batch.sh diff --git a/tests/CI_leak/batch.sh b/tests/CI_leak/batch.sh deleted file mode 100755 index 73dee7f..0000000 --- a/tests/CI_leak/batch.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -#该脚本在目录下为每个Cargo项目执行相同的命令直到报错 - -if [ $# -eq 0 ]; then - #脚本无参数时执行cargo clean - #Example: batch.sh - cmd="cargo clean" -else - #脚本有参数时按照给定参数执行cargo命令 - #Example: batch.sh -uaf - cmd="cargo rap $@" -fi - -# 查找并编译当前目录下的所有 Rust 项目 -find . -type f -name "Cargo.toml" | while read -r cargo_file; do - # 获取 Cargo.toml 文件所在的目录 - project_dir=$(dirname "$cargo_file") - - echo "Processing project in: $project_dir" - - # 切换到项目目录 - pushd "$project_dir" > /dev/null - - $cmd - if [ $? -ne 0 ]; then - # 如果命令失败,打印错误信息并退出循环 - echo "Error: '$cmd' failed in $project_dir" - popd > /dev/null - exit 1 - fi - - # 返回原始目录 - popd > /dev/null -done - diff --git a/tests/CI_uaf/batch.sh b/tests/CI_uaf/batch.sh deleted file mode 100755 index 73dee7f..0000000 --- a/tests/CI_uaf/batch.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -#该脚本在目录下为每个Cargo项目执行相同的命令直到报错 - -if [ $# -eq 0 ]; then - #脚本无参数时执行cargo clean - #Example: batch.sh - cmd="cargo clean" -else - #脚本有参数时按照给定参数执行cargo命令 - #Example: batch.sh -uaf - cmd="cargo rap $@" -fi - -# 查找并编译当前目录下的所有 Rust 项目 -find . -type f -name "Cargo.toml" | while read -r cargo_file; do - # 获取 Cargo.toml 文件所在的目录 - project_dir=$(dirname "$cargo_file") - - echo "Processing project in: $project_dir" - - # 切换到项目目录 - pushd "$project_dir" > /dev/null - - $cmd - if [ $? -ne 0 ]; then - # 如果命令失败,打印错误信息并退出循环 - echo "Error: '$cmd' failed in $project_dir" - popd > /dev/null - exit 1 - fi - - # 返回原始目录 - popd > /dev/null -done - From 75112226aa600c07a422ffcd53886b3c260edb69 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 13:01:54 +0800 Subject: [PATCH 04/20] ci: run tests with batch.sh --- .github/workflows/release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a1431d6..bb6cff0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,7 +36,5 @@ jobs: ./install.sh - name: Check test cases - run: cd tests && cargo +nightly-2024-10-12 rap -F -M + run: cd tests && ./batch.sh -F -M - - name: Check rap - run: cd rap && cargo +nightly-2024-10-12 rap -F -M From 3739fec223000787235c7600ec4853af10b34270 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 13:03:54 +0800 Subject: [PATCH 05/20] test: mv df_min to todo --- tests/{CI_uaf => todo}/df_min/Cargo.toml | 0 tests/{CI_uaf => todo}/df_min/src/main.rs | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/{CI_uaf => todo}/df_min/Cargo.toml (100%) rename tests/{CI_uaf => todo}/df_min/src/main.rs (100%) diff --git a/tests/CI_uaf/df_min/Cargo.toml b/tests/todo/df_min/Cargo.toml similarity index 100% rename from tests/CI_uaf/df_min/Cargo.toml rename to tests/todo/df_min/Cargo.toml diff --git a/tests/CI_uaf/df_min/src/main.rs b/tests/todo/df_min/src/main.rs similarity index 100% rename from tests/CI_uaf/df_min/src/main.rs rename to tests/todo/df_min/src/main.rs From 8ed41ec082ca345b4180b39e459fe12dd4fe6a8b Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 13:07:51 +0800 Subject: [PATCH 06/20] test: mv CI_leak and CI_uaf to support folder --- tests/batch.sh | 2 +- tests/{CI_leak => support/leak}/leak_min/Cargo.toml | 0 tests/{CI_leak => support/leak}/leak_min/src/main.rs | 0 tests/{CI_leak => support/leak}/leak_proxy/Cargo.toml | 0 tests/{CI_leak => support/leak}/leak_proxy/src/main.rs | 0 tests/{CI_uaf => support/uaf}/dangling_min/Cargo.toml | 0 tests/{CI_uaf => support/uaf}/dangling_min/src/main.rs | 0 tests/{CI_uaf => support/uaf}/uaf_drop/Cargo.toml | 0 tests/{CI_uaf => support/uaf}/uaf_drop/src/main.rs | 0 tests/{CI_uaf => support/uaf}/uaf_drop2/Cargo.toml | 0 tests/{CI_uaf => support/uaf}/uaf_drop2/src/main.rs | 0 tests/{CI_uaf => support/uaf}/uaf_drop_in_palce/Cargo.toml | 0 tests/{CI_uaf => support/uaf}/uaf_drop_in_palce/src/main.rs | 0 tests/{CI_uaf => support/uaf}/uaf_lifetime/Cargo.toml | 0 tests/{CI_uaf => support/uaf}/uaf_lifetime/src/main.rs | 0 tests/{CI_uaf => support/uaf}/uaf_small/Cargo.toml | 0 tests/{CI_uaf => support/uaf}/uaf_small/src/main.rs | 0 17 files changed, 1 insertion(+), 1 deletion(-) rename tests/{CI_leak => support/leak}/leak_min/Cargo.toml (100%) rename tests/{CI_leak => support/leak}/leak_min/src/main.rs (100%) rename tests/{CI_leak => support/leak}/leak_proxy/Cargo.toml (100%) rename tests/{CI_leak => support/leak}/leak_proxy/src/main.rs (100%) rename tests/{CI_uaf => support/uaf}/dangling_min/Cargo.toml (100%) rename tests/{CI_uaf => support/uaf}/dangling_min/src/main.rs (100%) rename tests/{CI_uaf => support/uaf}/uaf_drop/Cargo.toml (100%) rename tests/{CI_uaf => support/uaf}/uaf_drop/src/main.rs (100%) rename tests/{CI_uaf => support/uaf}/uaf_drop2/Cargo.toml (100%) rename tests/{CI_uaf => support/uaf}/uaf_drop2/src/main.rs (100%) rename tests/{CI_uaf => support/uaf}/uaf_drop_in_palce/Cargo.toml (100%) rename tests/{CI_uaf => support/uaf}/uaf_drop_in_palce/src/main.rs (100%) rename tests/{CI_uaf => support/uaf}/uaf_lifetime/Cargo.toml (100%) rename tests/{CI_uaf => support/uaf}/uaf_lifetime/src/main.rs (100%) rename tests/{CI_uaf => support/uaf}/uaf_small/Cargo.toml (100%) rename tests/{CI_uaf => support/uaf}/uaf_small/src/main.rs (100%) diff --git a/tests/batch.sh b/tests/batch.sh index 4ff509b..321fda8 100755 --- a/tests/batch.sh +++ b/tests/batch.sh @@ -2,7 +2,7 @@ #该脚本在目录下为每个Cargo项目执行相同的命令直到报错 # 查找并编译当前目录下的所有 Rust 项目 -find CI_* -type f -name "Cargo.toml" | while read -r cargo_file; do +find support -type f -name "Cargo.toml" | while read -r cargo_file; do # 获取 Cargo.toml 文件所在的目录 project_dir=$(dirname "$cargo_file") diff --git a/tests/CI_leak/leak_min/Cargo.toml b/tests/support/leak/leak_min/Cargo.toml similarity index 100% rename from tests/CI_leak/leak_min/Cargo.toml rename to tests/support/leak/leak_min/Cargo.toml diff --git a/tests/CI_leak/leak_min/src/main.rs b/tests/support/leak/leak_min/src/main.rs similarity index 100% rename from tests/CI_leak/leak_min/src/main.rs rename to tests/support/leak/leak_min/src/main.rs diff --git a/tests/CI_leak/leak_proxy/Cargo.toml b/tests/support/leak/leak_proxy/Cargo.toml similarity index 100% rename from tests/CI_leak/leak_proxy/Cargo.toml rename to tests/support/leak/leak_proxy/Cargo.toml diff --git a/tests/CI_leak/leak_proxy/src/main.rs b/tests/support/leak/leak_proxy/src/main.rs similarity index 100% rename from tests/CI_leak/leak_proxy/src/main.rs rename to tests/support/leak/leak_proxy/src/main.rs diff --git a/tests/CI_uaf/dangling_min/Cargo.toml b/tests/support/uaf/dangling_min/Cargo.toml similarity index 100% rename from tests/CI_uaf/dangling_min/Cargo.toml rename to tests/support/uaf/dangling_min/Cargo.toml diff --git a/tests/CI_uaf/dangling_min/src/main.rs b/tests/support/uaf/dangling_min/src/main.rs similarity index 100% rename from tests/CI_uaf/dangling_min/src/main.rs rename to tests/support/uaf/dangling_min/src/main.rs diff --git a/tests/CI_uaf/uaf_drop/Cargo.toml b/tests/support/uaf/uaf_drop/Cargo.toml similarity index 100% rename from tests/CI_uaf/uaf_drop/Cargo.toml rename to tests/support/uaf/uaf_drop/Cargo.toml diff --git a/tests/CI_uaf/uaf_drop/src/main.rs b/tests/support/uaf/uaf_drop/src/main.rs similarity index 100% rename from tests/CI_uaf/uaf_drop/src/main.rs rename to tests/support/uaf/uaf_drop/src/main.rs diff --git a/tests/CI_uaf/uaf_drop2/Cargo.toml b/tests/support/uaf/uaf_drop2/Cargo.toml similarity index 100% rename from tests/CI_uaf/uaf_drop2/Cargo.toml rename to tests/support/uaf/uaf_drop2/Cargo.toml diff --git a/tests/CI_uaf/uaf_drop2/src/main.rs b/tests/support/uaf/uaf_drop2/src/main.rs similarity index 100% rename from tests/CI_uaf/uaf_drop2/src/main.rs rename to tests/support/uaf/uaf_drop2/src/main.rs diff --git a/tests/CI_uaf/uaf_drop_in_palce/Cargo.toml b/tests/support/uaf/uaf_drop_in_palce/Cargo.toml similarity index 100% rename from tests/CI_uaf/uaf_drop_in_palce/Cargo.toml rename to tests/support/uaf/uaf_drop_in_palce/Cargo.toml diff --git a/tests/CI_uaf/uaf_drop_in_palce/src/main.rs b/tests/support/uaf/uaf_drop_in_palce/src/main.rs similarity index 100% rename from tests/CI_uaf/uaf_drop_in_palce/src/main.rs rename to tests/support/uaf/uaf_drop_in_palce/src/main.rs diff --git a/tests/CI_uaf/uaf_lifetime/Cargo.toml b/tests/support/uaf/uaf_lifetime/Cargo.toml similarity index 100% rename from tests/CI_uaf/uaf_lifetime/Cargo.toml rename to tests/support/uaf/uaf_lifetime/Cargo.toml diff --git a/tests/CI_uaf/uaf_lifetime/src/main.rs b/tests/support/uaf/uaf_lifetime/src/main.rs similarity index 100% rename from tests/CI_uaf/uaf_lifetime/src/main.rs rename to tests/support/uaf/uaf_lifetime/src/main.rs diff --git a/tests/CI_uaf/uaf_small/Cargo.toml b/tests/support/uaf/uaf_small/Cargo.toml similarity index 100% rename from tests/CI_uaf/uaf_small/Cargo.toml rename to tests/support/uaf/uaf_small/Cargo.toml diff --git a/tests/CI_uaf/uaf_small/src/main.rs b/tests/support/uaf/uaf_small/src/main.rs similarity index 100% rename from tests/CI_uaf/uaf_small/src/main.rs rename to tests/support/uaf/uaf_small/src/main.rs From 095cd6a983f7d739273434659fc5ffe2cd8b9318 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 13:09:53 +0800 Subject: [PATCH 07/20] ci: trigger whenever on push or pull_request --- .github/workflows/release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bb6cff0..e0d00a4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,9 +2,7 @@ name: Rap-booting and testing on: push: - branches: [ "main" ] pull_request: - branches: [ "main" ] env: CARGO_TERM_COLOR: always From cfd55c0233c04d118d02d825d4c61f91348cbaf2 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 13:20:25 +0800 Subject: [PATCH 08/20] chore: slim install.sh --- install.sh | 85 +----------------------------------------------------- 1 file changed, 1 insertion(+), 84 deletions(-) diff --git a/install.sh b/install.sh index 0fc6360..4eecd72 100755 --- a/install.sh +++ b/install.sh @@ -2,87 +2,4 @@ set -e -# Define color variables -BLUE='\033[0;34m' -GREEN='\033[0;32m' -NC='\033[0m' # No Color - -cd rap && cargo clean - -case "$SHELL" in - *zsh) - printf "Detecting shell context success: running on %bZsh%b.\n" "${BLUE}" "${NC}" - export SHELL_CONFIG=~/.zshrc - ;; - *bash) - printf "Detecting shell context success: running on %bBash%b.\n" "${BLUE}" "${NC}" - export SHELL_CONFIG=~/.bashrc - ;; - *) - printf "%bDetecting shell context failed.%b\n" "${RED}" "${NC}" - exit 1 - ;; -esac - -# Set the library path to be added -#LIBRARY_PATH="$HOME/.rustup/toolchains/nightly-2023-10-05-x86_64-unknown-linux-gnu/lib" -toolchain_date="nightly-2024-10-12" -toolchain_file="rust-toolchain.toml" -if [ ! -f "$toolchain_file" ]; then - printf "%bError: %s does not exist.%b\n" "${RED}" "$toolchain_file" "${NC}" - exit 1 -fi - -if ! rustup toolchain install "$toolchain_date" --profile minimal --component rustc-dev,rust-src,llvm-tools-preview; then - printf "%bError: Failed to install toolchain %s.%b\n" "${RED}" "$toolchain_date" "${NC}" - exit 1 -fi - -os_type=$(uname -s) -arch_type=$(uname -m) - -if [ "$os_type" = "Linux" ]; then - # Update the channel field in rust-toolchain.toml - toolchain="$toolchain_date-x86_64-unknown-linux-gnu" - toolchain_lib="$HOME/.rustup/toolchains/$toolchain/lib" - printf "%bDetected OS: Linux. Setting toolchain to %s%b\n" "${BLUE}" "$toolchain" "${NC}" - sed -i.bak "s/^channel = \".*\"/channel = \"$toolchain\"/" "$toolchain_file" - - if ! grep -q "LD_LIBRARY_PATH.*$toolchain_lib" "$SHELL_CONFIG"; then - if grep -q "LD_LIBRARY_PATH" "$SHELL_CONFIG"; then - export LD_LIBRARY_PATH="$toolchain_lib:$LD_LIBRARY_PATH" - sed -i '/LD_LIBRARY_PATH/d' "$SHELL_CONFIG" - printf "%bOld LD_LIBRARY_PATH definition has been removed from %s.%b\n" "${GREEN}" "$SHELL_CONFIG" "${NC}" - else - export LD_LIBRARY_PATH="$toolchain_lib" - fi - echo "export LD_LIBRARY_PATH=\"${LD_LIBRARY_PATH}\"" >> "$SHELL_CONFIG" - printf "%bEnvironment variables have been successfully written to %s.%b\n" "${GREEN}" "$SHELL_CONFIG" "${NC}" - fi -elif [ "$os_type" = "Darwin" ]; then - if [ "$arch_type" = "x86_64" ]; then - toolchain="$toolchain_date-x86_64-apple-darwin" - toolchain_lib="$HOME/.rustup/toolchain/$toolchain/lib" - else - toolchain="$toolchain_date-aarch64-apple-darwin" - toolchain_lib="$HOME/.rustup/toolchain/$toolchain/lib" - fi - printf "%bDetected OS: macOS. Setting toolchain to %s%b\n" "${BLUE}" "$toolchain" "${NC}" - sed -i.bak "s/^channel = \".*\"/channel = \"$toolchain\"/" "$toolchain_file" - - if ! grep -q "DYLD_LIBRARY_PATH.*$toolchain_lib" "$SHELL_CONFIG"; then - if grep -q "DYLD_LIBRARY_PATH" "$SHELL_CONFIG"; then - export DYLD_LIBRARY_PATH="$toolchain_lib:$DYLD_LIBRARY_PATH" - sed -i '/DYLD_LIBRARY_PATH/d' "$SHELL_CONFIG" - printf "%bOld DYLD_LIBRARY_PATH definition has been removed from %s.%b\n" "${GREEN}" "$SHELL_CONFIG" "${NC}" - else - export DYLD_LIBRARY_PATH="$toolchain_lib" - fi - echo "export DYLD_LIBRARY_PATH=\"${DYLD_LIBRARY_PATH}\"" >> "$SHELL_CONFIG" - printf "%bEnvironment variables have been successfully written to %s.%b\n" "${GREEN}" "$SHELL_CONFIG" "${NC}" - fi -fi - -cargo install --path . - -printf "%bTo apply the changes, you may need to run: %bsource %s%b\n" "${GREEN}" "${BLUE}" "$SHELL_CONFIG" "${NC}" +cargo install --path rap From a1fd76633021e8d177ed4740f8a4aba62376469d Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 13:22:52 +0800 Subject: [PATCH 09/20] ci: simplify --- .github/workflows/release.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e0d00a4..f231ab5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,13 +25,10 @@ jobs: python-version: '3.x' - name: Install ninja - run: | - pip install ninja + run: pip install ninja - name: Build RAP - run: | - chmod +x ./install.sh - ./install.sh + run: ./install.sh - name: Check test cases run: cd tests && ./batch.sh -F -M From 1a24dc0823fc8e7102b4f2fd1dfead160a91d8f1 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 13:31:57 +0800 Subject: [PATCH 10/20] test: save output to rap.txt and display it if error --- .gitignore | 1 + tests/batch.sh | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 18823b8..87d2dde 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .vscode/ target/ Cargo.lock +rap.txt diff --git a/tests/batch.sh b/tests/batch.sh index 321fda8..4fcaad1 100755 --- a/tests/batch.sh +++ b/tests/batch.sh @@ -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 文件所在的目录 @@ -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 From e4321d9bd6a411289ce20656442479a466d83fad Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 13:40:44 +0800 Subject: [PATCH 11/20] ci: no grep --- tests/batch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/batch.sh b/tests/batch.sh index 4fcaad1..61e3d10 100755 --- a/tests/batch.sh +++ b/tests/batch.sh @@ -22,7 +22,7 @@ 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 | tee $cur/rap.txt | grep 'RAP|WARN|' + $cmd 2>&1 | tee $cur/rap.txt # | grep 'RAP|WARN|' fi if [ $? -ne 0 ]; then From 2999affc16cd97eb9430c81ec50af5ab6d8f0fda Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 13:44:10 +0800 Subject: [PATCH 12/20] test: set -e for batch.sh --- tests/batch.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/batch.sh b/tests/batch.sh index 61e3d10..e1c6392 100755 --- a/tests/batch.sh +++ b/tests/batch.sh @@ -1,6 +1,8 @@ #!/bin/bash #该脚本在目录下为每个Cargo项目执行相同的命令直到报错 +set -e + cur=$(pwd) # 查找并编译当前目录下的所有 Rust 项目 @@ -22,7 +24,7 @@ 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 | tee $cur/rap.txt # | grep 'RAP|WARN|' + $cmd 2>&1 | tee $cur/rap.txt | grep 'RAP|WARN|' fi if [ $? -ne 0 ]; then From a754e2cd63e93b2efc9ccf9ca8cdb7db24957f53 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 13:46:47 +0800 Subject: [PATCH 13/20] install.sh: cargo rap -help --- install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install.sh b/install.sh index 4eecd72..65ee1bb 100755 --- a/install.sh +++ b/install.sh @@ -3,3 +3,5 @@ set -e cargo install --path rap + +cargo rap -help From 43a6256e4270d78ce10e97418b3277df875fa115 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 13:49:54 +0800 Subject: [PATCH 14/20] test: don't set -e since it's handled manually --- tests/batch.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/batch.sh b/tests/batch.sh index e1c6392..4fcaad1 100755 --- a/tests/batch.sh +++ b/tests/batch.sh @@ -1,8 +1,6 @@ #!/bin/bash #该脚本在目录下为每个Cargo项目执行相同的命令直到报错 -set -e - cur=$(pwd) # 查找并编译当前目录下的所有 Rust 项目 From 70a741437b49a9c56f9e54651ff47a32bbe04398 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 13:58:50 +0800 Subject: [PATCH 15/20] test: print pass if grep WARN succeeds --- tests/batch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/batch.sh b/tests/batch.sh index 4fcaad1..fcf3fca 100755 --- a/tests/batch.sh +++ b/tests/batch.sh @@ -22,7 +22,7 @@ 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 | tee $cur/rap.txt | grep 'RAP|WARN|' + $cmd 2>&1 | tee $cur/rap.txt | grep 'RAP|WARN|' && echo -e "\033[32m$project_dir pass\033[0m" fi if [ $? -ne 0 ]; then From e9b64332ce4a87ef686542653ec85f96e9773d33 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 14:03:44 +0800 Subject: [PATCH 16/20] ci: remove python and ninja installation --- .github/workflows/release.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f231ab5..1a4fcb7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,13 +19,6 @@ jobs: - name: Code Formatting Check run: cd rap && cargo fmt --check - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - - name: Install ninja - run: pip install ninja - name: Build RAP run: ./install.sh From 97aab7f69b459d94ce8cd1accce18abaf329b3de Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 14:03:51 +0800 Subject: [PATCH 17/20] test: ansi2txt before grep --- .github/workflows/release.yml | 1 + tests/batch.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a4fcb7..fd19142 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,7 @@ jobs: - name: Code Formatting Check run: cd rap && cargo fmt --check + - run: apt install colorized-logs -y - name: Build RAP run: ./install.sh diff --git a/tests/batch.sh b/tests/batch.sh index fcf3fca..2ed96dd 100755 --- a/tests/batch.sh +++ b/tests/batch.sh @@ -22,7 +22,7 @@ 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 | tee $cur/rap.txt | grep 'RAP|WARN|' && echo -e "\033[32m$project_dir pass\033[0m" + $cmd 2>&1 | tee $cur/rap.txt | ansi2txt | grep 'RAP|WARN|' && echo -e "\033[32m$project_dir pass\033[0m" fi if [ $? -ne 0 ]; then From 41532a6ff4a2eea776293a3439c92ac90a4749e1 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 14:04:59 +0800 Subject: [PATCH 18/20] ci: sudo apt --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fd19142..83fd9d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: - name: Code Formatting Check run: cd rap && cargo fmt --check - - run: apt install colorized-logs -y + - run: sudo apt install colorized-logs -y - name: Build RAP run: ./install.sh From c190156d7c71ea3ad722e753fbe61ecafd167d94 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 14:08:07 +0800 Subject: [PATCH 19/20] test: move colorized-logs installation to batch.sh --- .github/workflows/release.yml | 2 -- tests/batch.sh | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 83fd9d8..1c1f07b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,8 +18,6 @@ jobs: - name: Code Formatting Check run: cd rap && cargo fmt --check - - - run: sudo apt install colorized-logs -y - name: Build RAP run: ./install.sh diff --git a/tests/batch.sh b/tests/batch.sh index 2ed96dd..3be6a7a 100755 --- a/tests/batch.sh +++ b/tests/batch.sh @@ -1,6 +1,11 @@ #!/bin/bash #该脚本在目录下为每个Cargo项目执行相同的命令直到报错 +# All arguments passed to this script are forwarded to cargo rap + +# Insall ansi2txt +sudo apt install colorized-logs -y + cur=$(pwd) # 查找并编译当前目录下的所有 Rust 项目 From 6858a4b7e408da9aa48459176c1b9a607a1e3757 Mon Sep 17 00:00:00 2001 From: zjp Date: Thu, 26 Dec 2024 14:10:49 +0800 Subject: [PATCH 20/20] ci: apt install output is too verbose, move it out to yml --- .github/workflows/release.yml | 4 +++- tests/batch.sh | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1c1f07b..ea061a6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,10 +18,12 @@ jobs: - name: Code Formatting Check run: cd rap && cargo fmt --check - + - name: Build RAP run: ./install.sh + - run: sudo apt install colorized-logs -y # Insall ansi2txt + - name: Check test cases run: cd tests && ./batch.sh -F -M diff --git a/tests/batch.sh b/tests/batch.sh index 3be6a7a..eb6ba99 100755 --- a/tests/batch.sh +++ b/tests/batch.sh @@ -3,9 +3,6 @@ # All arguments passed to this script are forwarded to cargo rap -# Insall ansi2txt -sudo apt install colorized-logs -y - cur=$(pwd) # 查找并编译当前目录下的所有 Rust 项目