Skip to content

test: restore Subprocess.signal for signal-terminated children - #5135

Open
Huang-404-Q wants to merge 1 commit into
google:mainfrom
Huang-404-Q:fix/subprocess-signal
Open

Huang-404-Q wants to merge 1 commit into
google:mainfrom
Huang-404-Q:fix/subprocess-signal

Conversation

@Huang-404-Q

Copy link
Copy Markdown

Subprocess.__init__ sets terminated_by_signal, but the signal attribute was removed while four XML/JSON output tests still read p.signal on the crash path:

  • googletest/test/gtest_xml_output_unittest.py:394
  • googletest/test/gtest_xml_output_unittest.py:464
  • googletest/test/googletest-json-output-unittest.py:821
  • googletest/test/googletest-json-output-unittest.py:870

When a tested binary is killed by a signal, those branches raise AttributeError instead of reporting was killed by signal N, masking the real failure.

Repro (Windows and POSIX both set the high bit):

import sys, gtest_test_utils
p = gtest_test_utils.Subprocess([sys.executable, '-c', 'import os; os.abort()'])
print(p.terminated_by_signal)  # True
print(p.signal)                # AttributeError

Restore the old computation ((~return_code & 0x7fffffff) + 1) and add gtest_test_utils_test.py, which asserts the attribute exists on a signal death. The test is registered in CMake and Bazel.

Verified locally: the new test fails with AttributeError without the fix and passes with it.

Subprocess.__init__ sets terminated_by_signal but no longer exposes the
signal number. Four XML/JSON output tests still read p.signal on the crash
path, so a signal death raises AttributeError instead of printing the
intended diagnostic.

Restore the attribute and add a unit test for the helper itself.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant