Skip to content

Commit

Permalink
Merge pull request #520 from Alex-Weatherhead/fix/supportSharedLibrar…
Browse files Browse the repository at this point in the history
…yArguments-519

Support providing arguments to shared libraries
  • Loading branch information
mkorpela authored Mar 5, 2023
2 parents 9fd33d0 + bf7eaf0 commit 5bdbed4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/pabot/SharedLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SharedLibrary(object):

ROBOT_LIBRARY_SCOPE = "GLOBAL"

def __init__(self, name):
def __init__(self, name, args=None):
"""
Import a library so that the library instance is shared between executions.
[https://pabot.org/PabotLib.html?ref=log#import-shared-library|Open online docs.]
Expand All @@ -24,14 +24,14 @@ def __init__(self, name):
logger.debug(
"Not currently running pabot. Importing library for this process."
)
self._lib = RemoteLibraryFactory(TestLibrary(name).get_instance())
self._lib = RemoteLibraryFactory(TestLibrary(name, args=args).get_instance())
return
uri = BuiltIn().get_variable_value("${PABOTLIBURI}")
logger.debug("PabotLib URI %r" % uri)
remotelib = Remote(uri) if uri else None
if remotelib:
try:
port = remotelib.run_keyword("import_shared_library", [name], {})
port = remotelib.run_keyword("import_shared_library", [name], {"args": args})
except RuntimeError:
logger.error("No connection - is pabot called with --pabotlib option?")
raise
Expand Down
6 changes: 3 additions & 3 deletions src/pabot/pabotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import threading
import time
from typing import Any, Dict, List, Optional, Set, Tuple
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple

from robot.api import logger
from robot.libraries.BuiltIn import BuiltIn
Expand Down Expand Up @@ -154,10 +154,10 @@ def add_value_to_set(self, name, content):
content[self._TAGS_KEY] = []
self._values[name] = content

def import_shared_library(self, name): # type: (str) -> int
def import_shared_library(self, name, args=None): # type: (str, Iterable[Any]|None) -> int
if name in self._remote_libraries:
return self._remote_libraries[name][0]
imported = TestLibrary(name)
imported = TestLibrary(name, args=args)
server = RobotRemoteServer(
imported.get_instance(), port=0, serve=False, allow_stop=True
)
Expand Down

0 comments on commit 5bdbed4

Please sign in to comment.