Skip to content

Commit

Permalink
Fix test-webkitpy on Python 3.6
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=261115

Reviewed by Jonathan Bedard.

All of these failures are caused by the `sys.stderr.write` in
`webkitpy.__init__`. As such, when we run subprocesses in our tests, ignore
what's written to stderr.

* Tools/Scripts/webkitpy/common/system/executive_unittest.py:
(ExecutiveTest.test_run_command_with_unicode):
* Tools/Scripts/webkitpy/port/config_unittest.py:
(ConfigTest.test_default_configuration__standalone):

Canonical link: https://commits.webkit.org/267686@main
  • Loading branch information
gsnedders committed Sep 6, 2023
1 parent 375f0a1 commit 09fd886
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions Tools/Scripts/webkitpy/common/system/executive_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,25 +149,26 @@ def test_run_command_with_unicode(self):

executive = Executive()

output = executive.run_command(command_line('cat'), input=unicode_tor_input)
output = executive.run_command(command_line('cat'), input=unicode_tor_input, return_stderr=False)
self.assertEqual(output, unicode_tor_output)

output = executive.run_command(command_line('echo', unicode_tor_input))
output = executive.run_command(command_line('echo', unicode_tor_input), return_stderr=False)
self.assertEqual(output, unicode_tor_output)

output = executive.run_command(command_line('echo', unicode_tor_input), decode_output=False)
output = executive.run_command(command_line('echo', unicode_tor_input), decode_output=False, return_stderr=False)
self.assertEqual(output, encoded_tor)

# Make sure that str() input also works.
output = executive.run_command(command_line('cat'), input=encoded_tor, decode_output=False)
output = executive.run_command(command_line('cat'), input=encoded_tor, decode_output=False, return_stderr=False)
self.assertEqual(output, encoded_tor)

# FIXME: We should only have one run* method to test
# These use assertIn as run_and_throw_if_fail always redirects stderr to stdout
output = executive.run_and_throw_if_fail(command_line('echo', unicode_tor_input), quiet=True)
self.assertEqual(output, unicode_tor_output)
self.assertIn(unicode_tor_output, output)

output = executive.run_and_throw_if_fail(command_line('echo', unicode_tor_input), quiet=True, decode_output=False)
self.assertEqual(output, encoded_tor)
self.assertIn(encoded_tor, output)

def serial_test_kill_process(self):
executive = Executive()
Expand Down
2 changes: 1 addition & 1 deletion Tools/Scripts/webkitpy/port/config_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_default_configuration__standalone(self):
expected = 'Debug'

args = [sys.executable, script, '--mock', expected]
actual = e.run_command(args).rstrip()
actual = e.run_command(args, return_stderr=False).rstrip()
self.assertEqual(actual, expected)

def test_default_configuration__no_perl(self):
Expand Down

0 comments on commit 09fd886

Please sign in to comment.