diff options
author | Alexander Lussier-Cullen <alexander.lussier-cullen@savoirfairelinux.com> | 2023-12-12 11:38:50 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-12-15 14:37:28 +0000 |
commit | e9c2003bd0802dfd5221660eb808d4cde18d3a44 (patch) | |
tree | 474fb6cef78ceb8587eb7b275e3971d43247817a /bitbake/lib/toaster | |
parent | 47cc6288280bd38f42851d6423a5ffc95a46eea4 (diff) | |
download | poky-e9c2003bd0802dfd5221660eb808d4cde18d3a44.tar.gz |
bitbake: toaster/tests: Exit tests on chromedriver creation failure
When failing to create the web driver session for selenium tests,
a cascade of erroring tests will follow. To avoid processing these
unnecessarily, exit the tests completely in this case.
(Bitbake rev: 9327196102dd2671fcdb3200d9490e683f81d3a1)
Signed-off-by: Alexander Lussier-Cullen <alexander.lussier-cullen@savoirfairelinux.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster')
-rw-r--r-- | bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py index 46ced5a167..b32e89d7f3 100644 --- a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py +++ b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | |||
@@ -19,6 +19,7 @@ import os | |||
19 | import time | 19 | import time |
20 | import unittest | 20 | import unittest |
21 | 21 | ||
22 | import pytest | ||
22 | from selenium import webdriver | 23 | from selenium import webdriver |
23 | from selenium.webdriver.support.ui import WebDriverWait | 24 | from selenium.webdriver.support.ui import WebDriverWait |
24 | from selenium.webdriver.common.by import By | 25 | from selenium.webdriver.common.by import By |
@@ -43,22 +44,23 @@ def create_selenium_driver(cls,browser='chrome'): | |||
43 | try: | 44 | try: |
44 | return webdriver.Chrome(options=options) | 45 | return webdriver.Chrome(options=options) |
45 | except SessionNotCreatedException as e: | 46 | except SessionNotCreatedException as e: |
47 | exit_message = "Halting tests prematurely to avoid cascading errors." | ||
46 | # check if chrome / chromedriver exists | 48 | # check if chrome / chromedriver exists |
47 | chrome_path = os.popen("find ~/.cache/selenium/chrome/ -name 'chrome' -type f -print -quit").read().strip() | 49 | chrome_path = os.popen("find ~/.cache/selenium/chrome/ -name 'chrome' -type f -print -quit").read().strip() |
48 | if not chrome_path: | 50 | if not chrome_path: |
49 | raise SessionNotCreatedException("Failed to install/find chrome") | 51 | pytest.exit(f"Failed to install/find chrome.\n{exit_message}") |
50 | chromedriver_path = os.popen("find ~/.cache/selenium/chromedriver/ -name 'chromedriver' -type f -print -quit").read().strip() | 52 | chromedriver_path = os.popen("find ~/.cache/selenium/chromedriver/ -name 'chromedriver' -type f -print -quit").read().strip() |
51 | if not chromedriver_path: | 53 | if not chromedriver_path: |
52 | raise SessionNotCreatedException("Failed to install/find chromedriver") | 54 | pytest.exit(f"Failed to install/find chromedriver.\n{exit_message}") |
53 | # check if depends on each are fulfilled | 55 | # check if depends on each are fulfilled |
54 | depends_chrome = os.popen(f"ldd {chrome_path} | grep 'not found'").read().strip() | 56 | depends_chrome = os.popen(f"ldd {chrome_path} | grep 'not found'").read().strip() |
55 | if depends_chrome: | 57 | if depends_chrome: |
56 | raise SessionNotCreatedException(f"Missing chrome dependencies\n{depends_chrome}") | 58 | pytest.exit(f"Missing chrome dependencies.\n{depends_chrome}\n{exit_message}") |
57 | depends_chromedriver = os.popen(f"ldd {chromedriver_path} | grep 'not found'").read().strip() | 59 | depends_chromedriver = os.popen(f"ldd {chromedriver_path} | grep 'not found'").read().strip() |
58 | if depends_chromedriver: | 60 | if depends_chromedriver: |
59 | raise SessionNotCreatedException(f"Missing chrome dependencies\n{depends_chromedriver}") | 61 | pytest.exit(f"Missing chromedriver dependencies.\n{depends_chromedriver}\n{exit_message}") |
60 | # raise original error otherwise | 62 | # print original error otherwise |
61 | raise e | 63 | pytest.exit(f"Failed to start chromedriver.\n{e}\n{exit_message}") |
62 | elif browser == 'firefox': | 64 | elif browser == 'firefox': |
63 | return webdriver.Firefox() | 65 | return webdriver.Firefox() |
64 | elif browser == 'marionette': | 66 | elif browser == 'marionette': |