-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[testing] Add option to keep browser open after running a test. #25374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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' | ||
cls.browser_procs[0].wait() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At least for chrome the browser will be killed when python exits. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Firefox browser windows stay open after python exits, both on Windows and Linux. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. Or to be able to run multiple tests, and to be able to fail on first failing one? Currently |
||
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.') | ||
|
@@ -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) | ||
|
||
|
@@ -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 | ||
|
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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.