3 new revisions:
Revision: faee96109016
Branch: default
Author: Mika Hänninen <[email protected]>
Date: Fri May 3 03:41:38 2013
Log: process: review changes to keywords
http://code.google.com/p/robotframework/source/detail?r=faee96109016
Revision: 49a7a9313164
Branch: default
Author: Mika Hänninen <[email protected]>
Date: Mon May 6 00:29:42 2013
Log: process: precondition checks for tests
http://code.google.com/p/robotframework/source/detail?r=49a7a9313164
Revision: 45b8c7766dc7
Branch: default
Author: Mika Hänninen <[email protected]>
Date: Mon May 6 01:24:35 2013
Log: merge committi
http://code.google.com/p/robotframework/source/detail?r=45b8c7766dc7
==============================================================================
Revision: faee96109016
Branch: default
Author: Mika Hänninen <[email protected]>
Date: Fri May 3 03:41:38 2013
Log: process: review changes to keywords
http://code.google.com/p/robotframework/source/detail?r=faee96109016
Modified:
/atest/testdata/standard_libraries/process/is_process_alive.txt
/atest/testdata/standard_libraries/process/resource.txt
/atest/testdata/standard_libraries/process/test_process_library.txt
/src/robot/libraries/Process.py
=======================================
--- /atest/testdata/standard_libraries/process/is_process_alive.txt Mon Apr
29 22:50:09 2013
+++ /atest/testdata/standard_libraries/process/is_process_alive.txt Fri
May 3 03:41:38 2013
@@ -4,18 +4,18 @@
*** Test Cases ***
No Process Should Fail
- Run Keyword And Expect Error No open connection Process Is Alive
+ Run Keyword And Expect Error No open connection Process Is
Running
Test Process Should Be Alive
${handle}= Some process
- Process Should Be Alive ${handle}
+ Process Should Be Running ${handle}
Stop some process
Wait For Process ${handle}
- Run Keyword And Expect Error Process is not alive Process Should
Be Alive ${handle}
+ Run Keyword And Expect Error Process is not running Process
Should Be Running ${handle}
Test Process Should Be Dead
${handle}= Some process
- Run Keyword And Expect Error Process is alive Process Should Be
Dead ${handle}
+ Run Keyword And Expect Error Process is running Process Should
Be Stopped ${handle}
Stop some process
Wait For Process ${handle}
- Process Should Be Dead ${handle}
+ Process Should Be Stopped ${handle}
=======================================
--- /atest/testdata/standard_libraries/process/resource.txt Mon Apr 29
22:50:09 2013
+++ /atest/testdata/standard_libraries/process/resource.txt Fri May 3
03:41:38 2013
@@ -6,7 +6,8 @@
Stop some process
[Arguments] ${alias}=${null}
- Input To Process stop ${alias}
+ ${process}= Get Process Object ${alias}
+ Log ${process.communicate("stop\n")}
Result should equal
[Arguments] ${result} ${stdout}= ${stderr}= ${exit_code}=0
=======================================
--- /atest/testdata/standard_libraries/process/test_process_library.txt Mon
Apr 29 23:10:33 2013
+++ /atest/testdata/standard_libraries/process/test_process_library.txt Fri
May 3 03:41:38 2013
@@ -8,7 +8,7 @@
*** Test Cases ***
Library Namespace should be global
- Process Should Be Alive suite_process
+ Process Should Be Running suite_process
Running a process
${result}= Run Python Process print 'hello'
@@ -20,20 +20,20 @@
Start And Wait Process
${handle}= Start Python Process import time;time.sleep(0.1)
- ${is_alive}= Process Is Alive ${handle}
+ ${is_alive}= Process Is Running ${handle}
Should Be True ${is_alive}
Wait For Process ${handle}
- Process Should Be Dead ${handle}
+ Process Should Be Stopped ${handle}
Switching active process
${process_one}= Some process one
Stop Some Process one
${process_two}= Some process two
- Process Should Be Alive ${process_two}
+ Process Should Be Running ${process_two}
Switch Active Process one
- Process Should Be Dead
+ Process Should Be Stopped
Switch Active Process two
- Process Should Be Alive
+ Process Should Be Running
Stop Some Process
Run process does not change active process
@@ -45,17 +45,17 @@
Killing process
${handle}= Some process
- ${is_alive}= Process Is Alive ${handle}
+ ${is_alive}= Process Is Running ${handle}
Should Be True ${is_alive}
Terminate Process ${handle} kill=${True}
Wait For Process ${handle}
- Process Should Be Dead ${handle}
+ Process Should Be Stopped ${handle}
Terminating process
${handle}= Some process
Terminate Process ${handle}
Wait For Process ${handle}
- Process Should Be Dead ${handle}
+ Process Should Be Stopped ${handle}
Pid
${handle}= Some process
@@ -63,7 +63,7 @@
Should Not Be Equal ${pid} ${None}
Evaluate os.kill(int(${pid}),signal.SIGTERM) os,signal
Wait For Process ${handle}
- Process Should Be Dead ${handle}
+ Process Should Be Stopped ${handle}
Starting many processes and killing all
${handle1}= Some process
@@ -72,18 +72,18 @@
${handle4}= Some process
${handle5}= Some process
Sleep 0.1
- Process Should be alive ${handle1}
- Process Should be alive ${handle2}
- Process Should be alive ${handle3}
- Process Should be alive ${handle4}
- Process Should be alive ${handle5}
- Kill all processes
+ Process Should Be Running ${handle1}
+ Process Should Be Running ${handle2}
+ Process Should Be Running ${handle3}
+ Process Should Be Running ${handle4}
+ Process Should Be Running ${handle5}
+ Terminate All Processes
Sleep 0.1
- Process Should Be Dead ${handle1}
- Process Should Be Dead ${handle2}
- Process Should Be Dead ${handle3}
- Process Should Be Dead ${handle4}
- Process Should Be Dead ${handle5}
+ Process Should Be Stopped ${handle1}
+ Process Should Be Stopped ${handle2}
+ Process Should Be Stopped ${handle3}
+ Process Should Be Stopped ${handle4}
+ Process Should Be Stopped ${handle5}
Kill Process Which Does Not Exist
${handle}= Some process
@@ -125,7 +125,8 @@
Input things to process
Start New Process python -c "print 'inp %s' % raw_input()"
shell=True
- Input To Process some input
+ ${process}= Get Process Object
+ Log ${process.communicate("some input\n")}
${result}= Wait For Process
Should Match ${result.stdout} *inp some input*
@@ -179,5 +180,5 @@
*** Keywords ***
Restart Suite Process If Needed
- ${alive}= Process Is Alive suite_process
+ ${alive}= Process Is Running suite_process
Run Keyword If not ${alive} Some process suite_process
=======================================
--- /src/robot/libraries/Process.py Thu May 2 06:48:06 2013
+++ /src/robot/libraries/Process.py Fri May 3 03:41:38 2013
@@ -34,11 +34,11 @@
- Starting a processes, and managing their handles, stdouts and stderrs
(e.g. `Run Process` and `Start New Process` keywords).
- - Stopping processes started by this library (e.g. `Kill All
Processes` and
+ - Stopping processes started by this library (e.g. `Terminate All
Processes` and
`Terminate Process` keywords). See `Stopping processes` for more
information.
- Switching between processes (e.g. `Switch Active Process` keyword).
- - Checking process status (e.g. `Process Should Be Alive` and
- `Process Should Be Dead` keywords).
+ - Checking process status (e.g. `Process Should Be Running` and
+ `Process Should Be Stopped` keywords).
== Table of contents ==
@@ -106,11 +106,11 @@
self._logs = dict()
self._tempdir = tempfile.mkdtemp(suffix="processlib")
- def run_process(self, command, *args, **conf):
+ def run_process(self, command, *arguments, **configuration):
"""This keyword runs a process and waits for it to terminate.
The `command` is a child program which is started in a new process,
- `args` are arguments for the `command` and `conf` are arguments
for the
+ `arguments` are arguments for the `command` and `configuration`
are arguments for the
[http://docs.python.org/2.7/library/subprocess.html|subprocess]
module's
[http://docs.python.org/2.7/library/subprocess.html#subprocess.Popen|Popen]
class (see `Configurations`).
@@ -119,16 +119,16 @@
"""
active_process_index = self._started_processes.current_index
try:
- p = self.start_new_process(command, *args, **conf)
+ p = self.start_new_process(command, *arguments,
**configuration)
return self.wait_for_process(p)
finally:
self._started_processes.switch(active_process_index)
- def start_new_process(self, command, *args, **conf):
+ def start_new_process(self, command, *arguments, **configuration):
"""This keyword starts a new process.
The `command` is a child program which is started in a new process,
- `args` are arguments for the `command` and `conf` are arguments
for the
+ `arguments` are arguments for the `command` and `configuration`
are arguments for the
[http://docs.python.org/2.7/library/subprocess.html|subprocess]
module's
[http://docs.python.org/2.7/library/subprocess.html#subprocess.Popen|Popen]
class (see `Configurations`).
@@ -142,8 +142,8 @@
| $handle1}= | `Start New Process` | /bin/script.sh | |
| $handle2}= | `Start New Process` | totals | |
"""
- config = NewProcessConfig(self._tempdir, **conf)
- p = subprocess.Popen(self._cmd(args, command, config.shell),
+ config = NewProcessConfig(self._tempdir, **configuration)
+ p = subprocess.Popen(self._cmd(arguments, command, config.shell),
stdout=config.stdout_stream,
stderr=config.stderr_stream,
stdin=subprocess.PIPE,
@@ -161,37 +161,37 @@
cmd = command
return cmd
- def process_is_alive(self, handle=None):
- """This keyword checks if process with `handle` is alive or not.
+ def process_is_running(self, handle=None):
+ """This keyword checks if process with `handle` is running or not.
Argument `handle` is optional, if `None` then the active process
is used.
- Return value is either `True` (process is alive) or `False`
- (process has terminated).
+ Return value is either `True` (process is running) or `False`
+ (process has stopped).
"""
return self._process(handle).poll() is None
- def process_should_be_alive(self, handle=None):
- """Assertion keyword, which expects that process with `handle` is
alive.
+ def process_should_be_running(self, handle=None):
+ """Assertion keyword, which expects that process with `handle` is
running.
Argument `handle` is optional, if `None` then the active process
is used.
- Check is done using `Process Is Alive` keyword.
+ Check is done using `Process Is Running` keyword.
- Raises an error if process is dead.
+ Raises an error if process is stopped.
"""
- if not self.process_is_alive(handle):
- raise AssertionError('Process is not alive')
+ if not self.process_is_running(handle):
+ raise AssertionError('Process is not running')
- def process_should_be_dead(self, handle=None):
- """Assertion keyword, which expects that process with `handle` is
dead.
+ def process_should_be_stopped(self, handle=None):
+ """Assertion keyword, which expects that process with `handle` is
stopped.
Argument `handle` is optional, if `None` then the active process
is used.
- Check is done using `Process Is Alive` keyword.
+ Check is done using `Process Is Running` keyword.
- Raises an error if process is alive.
+ Raises an error if process is running.
"""
- if self.process_is_alive(handle):
- raise AssertionError('Process is alive')
+ if self.process_is_running(handle):
+ raise AssertionError('Process is running')
def wait_for_process(self, handle=None):
"""This waits for process with `handle` to terminate.
@@ -253,12 +253,12 @@
else:
raise AssertionError('None Pid - can not kill process!')
- def kill_all_processes(self):
+ def terminate_all_processes(self, kill=True):
"""This keyword terminates all processes started by the library.
"""
for handle in range(len(self._started_processes._connections)):
- if self.process_is_alive(handle):
- self.terminate_process(handle, kill=True)
+ if self.process_is_running(handle):
+ self.terminate_process(handle, kill=kill)
def get_process_id(self, handle=None):
"""Returns a process ID of process with `handle`.
@@ -277,17 +277,12 @@
"""
return self._process(handle).pid
- def input_to_process(self, msg, handle=None):
- """This keyword can be used to communicate with the process with
`handle`.
+ def get_process_object(self, handle=None):
+ """Return the process object with `handle`.
Argument `handle` is optional, if `None` then the active process
is used.
-
- Examples:
-
- | `Wait For Process` | ${handle3} | |
- | `Input To Process` | ${PASSWORD} | ${handle3} |
"""
- self._process(handle).communicate(msg+'\n')
+ return self._process(handle)
def switch_active_process(self, handle):
"""This keyword switches active process into process with `handle`.
@@ -312,22 +307,22 @@
_stdout = _stderr = None
- def __init__(self, stdout_name, stderr_name, exit_code=None):
- self._stdout_name = stdout_name
- self._stderr_name = stderr_name
+ def __init__(self, stdout_path, stderr_path, exit_code=None):
+ self.stdout_path = stdout_path
+ self.stderr_path = stderr_path
self.exit_code = exit_code
@property
def stdout(self):
if self._stdout is None:
- with open(self._stdout_name,'r') as f:
+ with open(self.stdout_path,'r') as f:
self._stdout = f.read()
return self._stdout
@property
def stderr(self):
if self._stderr is None:
- with open(self._stderr_name,'r') as f:
+ with open(self.stderr_path,'r') as f:
self._stderr = f.read()
return self._stderr
@@ -335,7 +330,7 @@
return """\
stdout_name : %s
stderr_name : %s
-exit_code : %d""" % (self._stdout_name, self._stderr_name,
self.exit_code)
+exit_code : %d""" % (self.stdout_path, self.stderr_path, self.exit_code)
class NewProcessConfig(object):
==============================================================================
Revision: 49a7a9313164
Branch: default
Author: Mika Hänninen <[email protected]>
Date: Mon May 6 00:29:42 2013
Log: process: precondition checks for tests
http://code.google.com/p/robotframework/source/detail?r=49a7a9313164
Modified:
/atest/robot/standard_libraries/process/is_process_alive.txt
/atest/robot/standard_libraries/process/test_process_library.txt
/atest/testdata/standard_libraries/process/is_process_alive.txt
/atest/testdata/standard_libraries/process/test_process_library.txt
=======================================
--- /atest/robot/standard_libraries/process/is_process_alive.txt Thu Apr 25
03:54:00 2013
+++ /atest/robot/standard_libraries/process/is_process_alive.txt Mon May 6
00:29:42 2013
@@ -1,5 +1,6 @@
*** Settings ***
Suite Setup Run Tests ${EMPTY}
standard_libraries/process/is_process_alive.txt
+Test Setup Check Preconditions
Force Tags regression pybot jybot
Resource atest_resource.txt
@@ -12,3 +13,7 @@
Test Process Should Be Dead
Check Test Case ${TESTNAME}
+
+*** Keywords ***
+Check Preconditions
+ Run Keyword If '${SUITE.metadata.get('info')}'
== 'precondition_fail' Fail precondition fail -regression
=======================================
--- /atest/robot/standard_libraries/process/test_process_library.txt Thu
Apr 25 03:54:00 2013
+++ /atest/robot/standard_libraries/process/test_process_library.txt Mon
May 6 00:29:42 2013
@@ -1,5 +1,6 @@
*** Settings ***
Suite Setup Run Tests ${EMPTY}
standard_libraries/process/test_process_library.txt
+Test Setup Check Preconditions
Force Tags regression pybot jybot
Resource atest_resource.txt
@@ -75,3 +76,7 @@
Current working directory should not be used with stdout and stderr when
absolute path in use
Check Test Case ${TESTNAME}
+
+*** Keywords ***
+Check Preconditions
+ Run Keyword If '${SUITE.metadata.get('info')}'
== 'precondition_fail' Fail precondition fail -regression
=======================================
--- /atest/testdata/standard_libraries/process/is_process_alive.txt Fri
May 3 03:41:38 2013
+++ /atest/testdata/standard_libraries/process/is_process_alive.txt Mon
May 6 00:29:42 2013
@@ -1,4 +1,5 @@
*** Settings ***
+Suite Setup Check Preconditions
Library Process
Resource resource.txt
@@ -19,3 +20,9 @@
Stop some process
Wait For Process ${handle}
Process Should Be Stopped ${handle}
+
+*** Keywords ***
+Check Preconditions
+ ${is_ok}= Evaluate sys.version_info >= (2,6) sys
+ Run Keyword If not ${is_ok} Set Suite Metadata info
precondition_fail
+ Run Keyword If not ${is_ok} Fail
=======================================
--- /atest/testdata/standard_libraries/process/test_process_library.txt Fri
May 3 03:41:38 2013
+++ /atest/testdata/standard_libraries/process/test_process_library.txt Mon
May 6 00:29:42 2013
@@ -1,5 +1,5 @@
*** Settings ***
-Suite Setup Some process suite_process
+Suite Setup Check Preconditions And Start suite_process
Suite Teardown Stop some process suite_process
Test Teardown Restart Suite Process If Needed
Library Process.py
@@ -182,3 +182,12 @@
Restart Suite Process If Needed
${alive}= Process Is Running suite_process
Run Keyword If not ${alive} Some process suite_process
+
+Check Preconditions
+ ${is_ok}= Evaluate sys.version_info >= (2,6) sys
+ Run Keyword If not ${is_ok} Set Suite Metadata info
precondition_fail
+ Run Keyword If not ${is_ok} Fail
+
+Check Preconditions And Start suite_process
+ Some process suite_process
+ Check Preconditions
==============================================================================
Revision: 45b8c7766dc7
Branch: default
Author: Mika Hänninen <[email protected]>
Date: Mon May 6 01:24:35 2013
Log: merge committi
http://code.google.com/p/robotframework/source/detail?r=45b8c7766dc7
Modified:
/atest/robot/standard_libraries/process/test_process_library.txt
=======================================
--- /atest/robot/standard_libraries/process/test_process_library.txt Fri
May 3 05:21:34 2013
+++ /atest/robot/standard_libraries/process/test_process_library.txt Mon
May 6 01:24:35 2013
@@ -1,6 +1,7 @@
*** Settings ***
Suite Setup Run Tests ${EMPTY}
standard_libraries/process/test_process_library.txt
-Force Tags regression pybot #FIXME: MAKE THESE TESTS RUN ON
JYTHON
+Test Setup Check Preconditions
+Force Tags regression pybot jybot
Resource atest_resource.txt
*** Test Cases ***
@@ -75,3 +76,7 @@
Current working directory should not be used with stdout and stderr when
absolute path in use
Check Test Case ${TESTNAME}
+
+*** Keywords ***
+Check Preconditions
+ Run Keyword If '${SUITE.metadata.get('info')}'
== 'precondition_fail' Fail precondition fail -regression
--
---
You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.