diff options
Diffstat (limited to 'share/python')
-rw-r--r-- | share/python/lib/daemon.yaml | 69 | ||||
-rw-r--r-- | share/python/lib/runcmd.py | 1 | ||||
-rw-r--r-- | share/python/template/scenarios.py | 10 |
3 files changed, 76 insertions, 4 deletions
diff --git a/share/python/lib/daemon.yaml b/share/python/lib/daemon.yaml index acca151..e385880 100644 --- a/share/python/lib/daemon.yaml +++ b/share/python/lib/daemon.yaml @@ -2,6 +2,8 @@ impl: python: function: daemon_no_such_process + doc: | + Ensure a given process is not running. - given: a daemon helper shell script {filename} impl: @@ -9,88 +11,155 @@ function: _daemon_shell_script types: filename: file + doc: | + Install a helper script from an embedded file. - when: I start "{path}{args:text}" as a background process as {name}, on port {port} impl: python: function: daemon_start_on_port + doc: | + Start a process in the background (as a daemon) and wait until it + listens on its assigned port. - when: I start "(?P<path>[^ "]+)(?P<args>[^"]*)" as a background process as (?P<name>[^,]+), on port (?P<port>\d+), with environment (?P<env>.*) regex: true + types: + args: text + path: path + name: text + port: uint + env: text impl: python: function: daemon_start_on_port + doc: | + Start a process in the background (as a daemon) and wait until it + listens on its assigned port. Remember the process under the given + name. - when: I try to start "{path}{args:text}" as {name}, on port {port} impl: python: function: _daemon_start_soonish cleanup: _daemon_stop_soonish + doc: | + Try to start a background process (as a daemon), but don't fail if + starting it fails. - when: I try to start "(?P<path>[^ "]+)(?P<args>[^"]*)" as (?P<name>[^,]+), on port (?P<port>\d+), with environment (?P<env>.*) regex: true + types: + path: path + args: text + name: text + port: uint + env: text impl: python: function: _daemon_start_soonish cleanup: _daemon_stop_soonish + doc: | + Start a process in the background (as a daemon) and wait until it + listens on its assigned port. Remember the process under the given + name. Don't fail if this fails. - when: I start "{path}{args:text}" as a background process as {name} impl: python: function: _daemon_start + doc: | + Start a process in the background (as a daemon). Remember the + process under the given name. Don't fail if this fails. - when: I start "(?P<path>[^ "]+)(?P<args>[^"]*)" as a background process as (?P<name>[^,]+), with environment (?P<env>.*) regex: true + types: + path: path + args: text + name: text + env: text impl: python: function: _daemon_start + doc: | + Start a process in the background (as a daemon), with specific + environment variables set. Remember the process under the given + name. Don't fail if this fails. - when: I stop background process {name} impl: python: function: daemon_stop + doc: | + Stop a background process that was started earlier with the given + name. - when: daemon {name} has produced output impl: python: function: daemon_has_produced_output + doc: | + Wait until the named daemon has produced output to its stdout or + stderr. - then: a process "{args:text}" is running impl: python: function: daemon_process_exists + doc: | + Check that a given process is running. - then: there is no "{args:text}" process impl: python: function: daemon_no_such_process + doc: | + Check that a given process is not running. - then: starting daemon fails with "{message:text}" impl: python: function: daemon_start_fails_with + doc: | + Check that starting a daemon previously failed, and the error + message contains the given text. - then: starting the daemon succeeds impl: python: function: daemon_start_succeeds + doc: | + Check that staring a daemon previous succeeded. - then: daemon {name} stdout is "{text:text}" impl: python: function: daemon_stdout_is + doc: | + Check that the named daemon has written exactly the given text to + its stdout. - then: daemon {name} stdout contains "{text:text}" impl: python: function: daemon_stdout_contains + doc: | + Check that the named daemon has written the given text to its + stdout, possibly among other text. - then: daemon {name} stdout doesn't contain "{text:text}" impl: python: function: daemon_stdout_doesnt_contain + doc: | + Check that the named daemon has not written the given text to its + stdout. - then: daemon {name} stderr is "{text:text}" impl: python: function: daemon_stderr_is + doc: | + Check that the named daemon has written exactly the given text to + its stderr. diff --git a/share/python/lib/runcmd.py b/share/python/lib/runcmd.py index c4a6a12..6a4965f 100644 --- a/share/python/lib/runcmd.py +++ b/share/python/lib/runcmd.py @@ -70,7 +70,6 @@ def runcmd_run(ctx, argv, **kwargs): logging.debug("runcmd_run: running command") log_value("argv", 1, dict(enumerate(argv))) - log_value("env", 1, env) log_value("kwargs:", 1, kwargs) p = subprocess.Popen(argv, env=env, **kwargs) diff --git a/share/python/template/scenarios.py b/share/python/template/scenarios.py index b215133..a6aa9f4 100644 --- a/share/python/template/scenarios.py +++ b/share/python/template/scenarios.py @@ -42,12 +42,14 @@ class Step: self._cleanup(ctx, **self._args) +_logged_env = False + + class Scenario: def __init__(self, ctx): self._title = None self._steps = [] self._ctx = ctx - self._logged_env = False def get_title(self): return self._title @@ -91,7 +93,9 @@ class Scenario: os.environ.update(overrides) os.environ.update(extra_env) - if not self._logged_env: - self._logged_env = True + global _logged_env + if not _logged_env: + _logged_env = True log_value("extra_env", 0, dict(extra_env)) + log_value("overrides", 0, dict(overrides)) log_value("os.environ", 0, dict(os.environ)) |