Skip to content

Commit

Permalink
Added a env var to enable or disable screenshot in drone
Browse files Browse the repository at this point in the history
  • Loading branch information
Talank committed Mar 15, 2022
1 parent 22d6930 commit 3a4b873
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

OC_TESTING_MIDDLEWARE = "owncloud/owncloud-test-middleware:1.4.0"
GUI_TEST_REPORT_DIR = "/drone/src/test/guiReportUpload"
SCREENSHOT = True

dir = {
"base": "/drone",
Expand Down
7 changes: 4 additions & 3 deletions test/gui/shared/scripts/bdd_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ def hook(context):

@OnScenarioEnd
def hook(context):
# capture screenshot if the scenario failed
if test.resultCount("errors") > 0:
# capture screenshot if the scenario failed and the SCREENSHOT env variable is True
if test.resultCount("errors") > 0 and os.environ["SCREENSHOT"] == "True":
import gi

gi.require_version('Gtk', '3.0')
from gi.repository import Gdk

Expand All @@ -106,7 +107,7 @@ def hook(context):
filename = context._data["title"].replace(" ", "_") + ".png"

# if environment variable GUI_TEST_REPORT_DIR is set, use GUI_TEST_REPORT_DIR/screenshots as the directory
# otherwise use the current directory
# otherwise use the current test case direcotry
if "GUI_TEST_REPORT_DIR" in os.environ:
directory = os.environ["GUI_TEST_REPORT_DIR"] + "/screenshots"
else:
Expand Down

0 comments on commit 3a4b873

Please sign in to comment.