Prechádzať zdrojové kódy

Detect failing tests in parallel shard runner

The previous logic considered a shard "passed" if its log contained any
[  PASSED  ] line, missing the case where some tests pass and some fail
(both [  PASSED  ] N tests. and [  FAILED  ] M tests, listed below:
appear in the gtest summary). Exit codes from the test binaries were
also ignored.

Now require both: an [  PASSED  ] line, no [  FAILED  ] line, and a
zero exit code. Track each shard's PID so wait can surface non-zero
exits.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
yhirose 5 mesiacov pred
rodič
commit
b0866cff8f
2 zmenil súbory, kde vykonal 18 pridanie a 10 odobranie
  1. 5 2
      .github/workflows/test.yaml
  2. 13 8
      test/Makefile

+ 5 - 2
.github/workflows/test.yaml

@@ -322,11 +322,14 @@ jobs:
         $failed = $false
         for ($i = 0; $i -lt $shards; $i++) {
           $log = "shard_${i}.log"
-          if (Select-String -Path $log -Pattern "\[  PASSED  \]" -Quiet) {
+          $proc = $procs[$i]
+          $hasPassed = Select-String -Path $log -Pattern "\[  PASSED  \]" -Quiet
+          $hasFailed = Select-String -Path $log -Pattern "\[  FAILED  \]" -Quiet
+          if ($hasPassed -and -not $hasFailed -and $proc.ExitCode -eq 0) {
             $passed = (Select-String -Path $log -Pattern "\[  PASSED  \]").Line
             Write-Host "Shard ${i}: $passed"
           } else {
-            Write-Host "=== Shard $i FAILED ==="
+            Write-Host "=== Shard $i FAILED (exit=$($proc.ExitCode)) ==="
             Get-Content $log
             if (Test-Path "${log}.err") { Get-Content "${log}.err" }
             $failed = $true

+ 13 - 8
test/Makefile

@@ -67,24 +67,29 @@ SHARDS ?= 4
 
 define run_parallel
 	@echo "Running $(1) with $(SHARDS) shards in parallel..."
-	@fail=0; \
+	@fail=0; pids=""; \
 	for i in $$(seq 0 $$(($(SHARDS) - 1))); do \
 	  GTEST_TOTAL_SHARDS=$(SHARDS) GTEST_SHARD_INDEX=$$i \
 	  LSAN_OPTIONS=suppressions=lsan_suppressions.txt \
 	  $(SETARCH) ./$(1) --gtest_color=yes > $(1)_shard_$$i.log 2>&1 & \
+	  pids="$$pids $$!"; \
+	done; \
+	rc=0; \
+	for pid in $$pids; do \
+	  if ! wait $$pid; then rc=1; fi; \
 	done; \
-	wait; \
 	for i in $$(seq 0 $$(($(SHARDS) - 1))); do \
-	  if ! grep -q "\[  PASSED  \]" $(1)_shard_$$i.log; then \
+	  log=$(1)_shard_$$i.log; \
+	  if grep -q "\[  PASSED  \]" $$log && ! grep -q "\[  FAILED  \]" $$log; then \
+	    passed=$$(grep "\[  PASSED  \]" $$log); \
+	    echo "Shard $$i: $$passed"; \
+	  else \
 	    echo "=== Shard $$i FAILED ==="; \
-	    cat $(1)_shard_$$i.log; \
+	    cat $$log; \
 	    fail=1; \
-	  else \
-	    passed=$$(grep "\[  PASSED  \]" $(1)_shard_$$i.log); \
-	    echo "Shard $$i: $$passed"; \
 	  fi; \
 	done; \
-	if [ $$fail -ne 0 ]; then exit 1; fi; \
+	if [ $$fail -ne 0 ] || [ $$rc -ne 0 ]; then exit 1; fi; \
 	echo "All shards passed."
 endef