From f50bd311fb248b13242d2fed14a2912cc6a7dea7 Mon Sep 17 00:00:00 2001 From: yhirose Date: Wed, 29 Apr 2026 07:33:51 +0900 Subject: [PATCH] Fix MakeFileBody/MakeFileProvider tests on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These tests wrote to a hardcoded "/tmp/" path which does not exist on Windows, causing the file write to silently fail and the subsequent make_file_body / make_file_provider call to return zero-sized data. Use a relative path under the test working directory instead so the test runs identically on every platform. Also dump the shard log when a shard's process exits non-zero even when the gtest summary appears clean (e.g. sanitizer report after the suite, or assertion-based abort) — previously such failures were detected only via overall rc and showed no diagnostic output. Co-Authored-By: Claude Opus 4.7 (1M context) --- test/Makefile | 14 ++++++++------ test/test.cc | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/test/Makefile b/test/Makefile index 23c94e6..cd04acb 100644 --- a/test/Makefile +++ b/test/Makefile @@ -74,22 +74,24 @@ define run_parallel $(SETARCH) ./$(1) --gtest_color=yes > $(1)_shard_$$i.log 2>&1 & \ pids="$$pids $$!"; \ done; \ - rc=0; \ + exits=""; \ for pid in $$pids; do \ - if ! wait $$pid; then rc=1; fi; \ + wait $$pid; exits="$$exits $$?"; \ done; \ - for i in $$(seq 0 $$(($(SHARDS) - 1))); do \ + i=0; \ + for ec in $$exits; do \ log=$(1)_shard_$$i.log; \ - if grep -q "\[ PASSED \]" $$log && ! grep -q "\[ FAILED \]" $$log; then \ + if grep -q "\[ PASSED \]" $$log && ! grep -q "\[ FAILED \]" $$log && [ $$ec -eq 0 ]; then \ passed=$$(grep "\[ PASSED \]" $$log); \ echo "Shard $$i: $$passed"; \ else \ - echo "=== Shard $$i FAILED ==="; \ + echo "=== Shard $$i FAILED (exit=$$ec) ==="; \ cat $$log; \ fail=1; \ fi; \ + i=$$((i+1)); \ done; \ - if [ $$fail -ne 0 ] || [ $$rc -ne 0 ]; then exit 1; fi; \ + if [ $$fail -ne 0 ]; then exit 1; fi; \ echo "All shards passed." endef diff --git a/test/test.cc b/test/test.cc index 204c524..c708e79 100644 --- a/test/test.cc +++ b/test/test.cc @@ -12276,7 +12276,7 @@ TEST(MultipartFormDataTest, ManyItemsEndToEnd) { TEST(MultipartFormDataTest, MakeFileProvider) { // Verify make_file_provider sends a file's contents correctly. const std::string file_content(4096, 'Z'); - const std::string tmp_path = "/tmp/httplib_test_make_file_provider.bin"; + const std::string tmp_path = "./httplib_test_make_file_provider.bin"; { std::ofstream ofs(tmp_path, std::ios::binary); ofs.write(file_content.data(), @@ -12331,7 +12331,7 @@ TEST(MultipartFormDataTest, MakeFileProvider) { TEST(MakeFileBodyTest, Basic) { const std::string file_content(4096, 'Z'); - const std::string tmp_path = "/tmp/httplib_test_make_file_body.bin"; + const std::string tmp_path = "./httplib_test_make_file_body.bin"; { std::ofstream ofs(tmp_path, std::ios::binary); ofs.write(file_content.data(),