diff --git a/scripts/score.sh b/scripts/score.sh index c5ab8022..70405310 100755 --- a/scripts/score.sh +++ b/scripts/score.sh @@ -168,10 +168,8 @@ run_one() { timeout "$TIMEOUT_SEC" "$QEMU" $QEMU_FLAGS "$ref_exe" > "$ref_out" 2>/dev/null || ref_exit=$? fi ref_end="$(date +%s%3N)" - if [[ $ref_exit -eq 0 ]]; then - ref_time=$((ref_end - ref_start)) - ref_ok=1 - fi + ref_time=$((ref_end - ref_start)) + ref_ok=1 fi fi if [[ $ref_time -lt 1 ]]; then ref_time=1; fi @@ -230,15 +228,20 @@ run_with_args() { end_ns="$(date +%s%3N)" our_time=$((end_ns - start_ns)) [[ $our_time -lt 1 ]] && our_time=1 - if [[ $exit_code -eq 0 ]]; then - if [[ -f "$out_file" ]]; then - # .out 文件格式: stdout + 换行 + 退出码 (与 2026test.sh 一致) - local our_actual="$work_dir/our.actual.out" - { cat "$our_out"; printf '\n'; echo "$exit_code"; } > "$our_actual" - diff -q "$our_actual" "$out_file" >/dev/null 2>&1 && our_correct=1 - else - our_correct=1 + # SysY 程序可返回任意值,不能用 exit_code==0 判断正确性 + # .out 文件格式(与 2026test.sh 一致): stdout + [换行] + 退出码 + local our_actual="$work_dir/our.actual.out" + { + cat "$our_out" + if [[ -s "$our_out" ]] && (( $(tail -c 1 "$our_out" | wc -l) == 0 )); then + printf '\n' fi + echo "$exit_code" + } > "$our_actual" + if [[ -f "$out_file" ]]; then + diff -q "$our_actual" "$out_file" >/dev/null 2>&1 && our_correct=1 + else + our_correct=1 fi fi fi @@ -256,7 +259,7 @@ run_with_args() { timeout "$TIMEOUT_SEC" "$QEMU" $QEMU_FLAGS "$ref_exe" > "$ref_out" 2>/dev/null || ref_exit=$? fi ref_end="$(date +%s%3N)" - [[ $ref_exit -eq 0 ]] && ref_time=$((ref_end - ref_start)) + ref_time=$((ref_end - ref_start)) fi fi [[ $ref_time -lt 1 ]] && ref_time=1