Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
EMTEST_BROWSER = None
EMTEST_BROWSER_AUTO_CONFIG = None
EMTEST_HEADLESS = None
EMTEST_KEEP_OPEN = None
EMTEST_DETECT_TEMPFILE_LEAKS = None
EMTEST_SAVE_DIR = None
# generally js engines are equivalent, testing 1 is enough. set this
Expand Down Expand Up @@ -2587,6 +2588,10 @@ def __init__(self, *args, **kwargs):

@classmethod
def browser_terminate(cls):
if EMTEST_KEEP_OPEN:
assert len(cls.browser_procs) == 1, '--keep-open only supports one browser process'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Windows on Firefox case, len(cls.browser_procs) > 1 even if there is only one test running.

Also, this failure seems like a configuration/setup failure, rather than an after-the fact failure?

I.e. if I run EMTEST_CORES=128 test/runner browser --keep-open, then this will still launch all the 128 browsers, and only when they are all being shut down at the very end of the test (or if one test fails), then that Worker will assert fail about this --keep-open not being compatible with multithreaded runs?

So maybe a better check might be to move this assert earlier when the test suite is starting, e.g. after the parallel_testsuite.NUM_CORES variable has been set, and verify that NUM_CORES==1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of a half baked feature. I really just use it for running one test and debugging. I can move the asserts around to be earlier and only support single tester mode.

cls.browser_procs[0].wait()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But will this not also keep the test running open ? Why not just exit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least for chrome the browser will be killed when python exits.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, maybe add a comment there, something like "# Keep the python process alive until the browser is closed. This also means that http server will keep runnning"

Alternatively we could exit the python process after orphaning the browser, but then I guess that server would also go down.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least for chrome the browser will be killed when python exits.

Firefox browser windows stay open after python exits, both on Windows and Linux.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about

for p in cls.browser_procs:
  p.wait()

?

return
for proc in cls.browser_procs:
try:
proc.terminate()
Expand Down
4 changes: 4 additions & 0 deletions test/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,8 @@ def parse_args():
help='Run browser tests in headless mode.', default=None)
parser.add_argument('--browser-auto-config', type=bool, default=True,
help='Use the default CI browser configuration.')
parser.add_argument('--keep-open', action='store_true',
help='Keep the browser open after tests have run.', default=None)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current form, this might not be accurate?

Is the idea to be able to run only a single fixed test with this?

I.e. test/runner browser.test_my_failing_test --keep-open ?

Or to be able to run multiple tests, and to be able to fail on first failing one?

Currently browser.terminate() will be called if a test times out in the suite? Is that intended to interact with this --keep-open?

parser.add_argument('tests', nargs='*')
parser.add_argument('--failfast', action='store_true')
parser.add_argument('--failing-and-slow-first', action='store_true', help='Run failing tests first, then sorted by slowest first. Combine with --failfast for fast fail-early CI runs.')
Expand Down Expand Up @@ -506,6 +508,7 @@ def configure():
common.EMTEST_LACKS_NATIVE_CLANG = int(os.getenv('EMTEST_LACKS_NATIVE_CLANG', '0'))
common.EMTEST_REBASELINE = int(os.getenv('EMTEST_REBASELINE', '0'))
common.EMTEST_VERBOSE = int(os.getenv('EMTEST_VERBOSE', '0')) or shared.DEBUG
common.EMTEST_KEEP_OPEN = int(os.getenv('EMTEST_KEEP_OPEN', '0'))
if common.EMTEST_VERBOSE:
logging.root.setLevel(logging.DEBUG)

Expand Down Expand Up @@ -546,6 +549,7 @@ def set_env(name, option_value):
set_env('EMTEST_BROWSER', options.browser)
set_env('EMTEST_BROWSER_AUTO_CONFIG', options.browser_auto_config)
set_env('EMTEST_HEADLESS', options.headless)
set_env('EMTEST_KEEP_OPEN', options.keep_open)
set_env('EMTEST_DETECT_TEMPFILE_LEAKS', options.detect_leaks)
if options.save_dir:
common.EMTEST_SAVE_DIR = 1
Expand Down