Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zrr1999 committed Jul 6, 2023
1 parent 73e9991 commit 51c55ef
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
6 changes: 3 additions & 3 deletions examples/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ for file in ./*.py; do
# 检查文件是否为 Python 文件
if [ -f "$file" ]; then
if [[ -n "$GITHUB_ACTIONS" ]]; then
echo ::group::example Running: LOG_LEVEL=3 PYTHONPATH=$PYTHONPATH " STRICT_MODE=1 python " $file
echo ::group::example Running: LOG_LEVEL=3 PYTHONPATH=$PYTHONPATH " STRICT_MODE=1 python " $file
else
echo Running: LOG_LEVEL=3 PYTHONPATH=$PYTHONPATH " STRICT_MODE=1 python " $file
echo Running: LOG_LEVEL=3 PYTHONPATH=$PYTHONPATH " STRICT_MODE=1 python " $file
fi
# 执行文件
python "$file"
Expand All @@ -17,7 +17,7 @@ for file in ./*.py; do
exit 1
fi
if [[ -n "$GITHUB_ACTIONS" ]]; then
echo "::endgroup::"
echo "::endgroup::"
fi
fi
done
14 changes: 14 additions & 0 deletions tests/extract_errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import re
import sys

error_msg = sys.stdin.read()

pattern = r'File "?(.*?)"?, line (\d+),.*\n(.*?)\n(.*?)$'
match = re.search(pattern, error_msg, re.MULTILINE)
if match:
file = match.group(1)
line = match.group(2)
error_info = match.group(4)
# error_info = match.group(3) + '\n' + match.group(4)
output = f"::error file={file},line={line}::{error_info}"
print(output)
15 changes: 10 additions & 5 deletions tests/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ for file in ./test_*.py; do
# 检查文件是否为 Python 文件
if [ -f "$file" ]; then
if [[ -n "$GITHUB_ACTIONS" ]]; then
echo ::group::Running: PYTHONPATH=$PYTHONPATH " STRICT_MODE=1 python " $file
echo ::group::Running: PYTHONPATH=$PYTHONPATH " STRICT_MODE=1 python " $file
else
echo Running: PYTHONPATH=$PYTHONPATH " STRICT_MODE=1 python " $file
echo Running: PYTHONPATH=$PYTHONPATH " STRICT_MODE=1 python " $file
fi
# 执行文件
python "$file" 2> >(grep "File <$file>, line")
python_output=$(python $file 2>&1)

if [ $? -ne 0 ]; then
echo "run $file failed"
failed_tests+=("$file")
if [[ -n "$GITHUB_ACTIONS" ]]; then
echo $python_output | python ./tests/extract_errors.py
fi
echo $python_output
fi
if [[ -n "$GITHUB_ACTIONS" ]]; then
echo "::endgroup::"
echo "::endgroup::"
fi
fi
done
Expand All @@ -28,6 +33,6 @@ if [ ${#failed_tests[@]} -ne 0 ]; then
echo "failed tests file:"
for failed_test in "${failed_tests[@]}"; do
echo "$failed_test"
echo "::error file=$failed_test,line=1,col=5,endColumn=7::Missing semicolon"
done
exit 1
fi

0 comments on commit 51c55ef

Please sign in to comment.