Skip to content

Commit 3e481f6

Browse files
authored
Use a blocking queue.get() to get browser test results. NFC (#20848)
1 parent 20075c6 commit 3e481f6

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

test/common.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import time
2929
import webbrowser
3030
import unittest
31+
import queue
3132

3233
import clang_native
3334
import jsrun
@@ -1956,25 +1957,21 @@ def run_browser(self, html_file, expected=None, message=None, timeout=None, extr
19561957
'http://localhost:%s/%s' % (self.port, html_file),
19571958
self.get_dir()
19581959
))
1959-
received_output = False
1960-
output = '[no http server activity]'
1961-
start = time.time()
19621960
if timeout is None:
19631961
timeout = self.browser_timeout
1964-
while time.time() - start < timeout:
1965-
if not self.harness_out_queue.empty():
1966-
output = self.harness_out_queue.get()
1967-
received_output = True
1968-
break
1969-
time.sleep(0.1)
1970-
if not received_output:
1962+
try:
1963+
output = self.harness_out_queue.get(block=True, timeout=timeout)
1964+
except queue.Empty:
19711965
BrowserCore.unresponsive_tests += 1
19721966
print('[unresponsive tests: %d]' % BrowserCore.unresponsive_tests)
19731967
self.browser_restart()
1968+
# Rather than fail the test here, let fail on the `assertContained` so
1969+
# that the test can be retried via `extra_tries`
1970+
output = '[no http server activity]'
19741971
if output is None:
19751972
# the browser harness reported an error already, and sent a None to tell
19761973
# us to also fail the test
1977-
raise Exception('failing test due to browser harness error')
1974+
self.fail('browser harness error')
19781975
if output.startswith('/report_result?skipped:'):
19791976
self.skipTest(unquote(output[len('/report_result?skipped:'):]).strip())
19801977
else:

0 commit comments

Comments
 (0)