fix(scripts): score.sh 使用 canon_diff 忽略尾部空白——匹配 2026test.sh 行为

performance 60/60 AC, functional 100/100 AC, h_functional 40/40 AC。
lzk
lzkk 4 days ago
parent 8d4a34aa10
commit ea790dd05d

@ -23,6 +23,17 @@ BLUE='\033[0;34m'
BOLD='\033[1m'
NC='\033[0m'
# 规范比较:忽略尾部空格和尾部空行(与 2026test.sh 的 canon_compare 一致)
canon_diff() {
local f1="$1" f2="$2"
diff -q \
<(sed 's/\r$//; s/[[:space:]]*$//' "$f1" \
| awk '{lines[NR]=$0} END{last=NR; while(last>0&&lines[last]=="")last--; for(i=1;i<=last;i++)print lines[i]}') \
<(sed 's/\r$//; s/[[:space:]]*$//' "$f2" \
| awk '{lines[NR]=$0} END{last=NR; while(last>0&&lines[last]=="")last--; for(i=1;i<=last;i++)print lines[i]}') \
>/dev/null 2>&1
}
GCC="aarch64-linux-gnu-gcc"
GCC_COMPILE_FLAGS="-std=gnu89 -O2 -x c"
GCC_LINK_FLAGS="-static"
@ -239,7 +250,7 @@ run_with_args() {
echo "$exit_code"
} > "$our_actual"
if [[ -f "$out_file" ]]; then
diff -q "$our_actual" "$out_file" >/dev/null 2>&1 && our_correct=1
canon_diff "$our_actual" "$out_file" && our_correct=1
else
our_correct=1
fi

Loading…
Cancel
Save