aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-09-06 10:58:14 +0900
committernsfisis <nsfisis@gmail.com>2025-09-06 10:58:14 +0900
commit8373cfeead87b29e9be9a4d1d48f497c56260b21 (patch)
treedda3cde8f0decdf0c1499a3da51a0f84b1595749 /backend
parent6bb6ef63f0893f01ff30aa7d0544e667eb0ea675 (diff)
downloadiosdc-japan-2025-albatross-8373cfeead87b29e9be9a4d1d48f497c56260b21.tar.gz
iosdc-japan-2025-albatross-8373cfeead87b29e9be9a4d1d48f497c56260b21.tar.zst
iosdc-japan-2025-albatross-8373cfeead87b29e9be9a4d1d48f497c56260b21.zip
fix(backend): normalize line endings before comparing test results
Diffstat (limited to 'backend')
-rw-r--r--backend/game/hub.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/backend/game/hub.go b/backend/game/hub.go
index 436acf5..364e590 100644
--- a/backend/game/hub.go
+++ b/backend/game/hub.go
@@ -141,8 +141,13 @@ func (hub *Hub) processTaskResultRunTestcase(
return nil
}
+func normalizeTestcaseResultOutput(s string) string {
+ re := regexp.MustCompile(`\r\n|\r`)
+ return re.ReplaceAllString(strings.TrimSpace(s), "\n")
+}
+
func isTestcaseResultCorrect(expectedStdout, actualStdout string) bool {
- expectedStdout = strings.TrimSpace(expectedStdout)
- actualStdout = strings.TrimSpace(actualStdout)
+ expectedStdout = normalizeTestcaseResultOutput(expectedStdout)
+ actualStdout = normalizeTestcaseResultOutput(actualStdout)
return actualStdout == expectedStdout
}