2 new revisions:

Revision: c20f0f2d37c5
Branch:   default
Author:   Robot Framework Developers (robotframew...@gmail.com)
Date:     Tue Jan 28 09:20:00 2014 UTC
Log: Process tests: Cleaned up checking precondtion and made it test and no...
http://code.google.com/p/robotframework/source/detail?r=c20f0f2d37c5

Revision: cd6df16791f2
Branch:   default
Author:   Robot Framework Developers (robotframew...@gmail.com)
Date:     Tue Jan 28 09:50:32 2014 UTC
Log:      Process: timeout and on_timeout arguments for Run Process....
http://code.google.com/p/robotframework/source/detail?r=cd6df16791f2

==============================================================================
Revision: c20f0f2d37c5
Branch:   default
Author:   Robot Framework Developers (robotframew...@gmail.com)
Date:     Tue Jan 28 09:20:00 2014 UTC
Log: Process tests: Cleaned up checking precondtion and made it test and not suite specific
http://code.google.com/p/robotframework/source/detail?r=c20f0f2d37c5

Added:
 /atest/robot/standard_libraries/process/process_resource.txt
Modified:
 /atest/robot/standard_libraries/process/get_process_result.txt
 /atest/robot/standard_libraries/process/is_process_alive.txt
 /atest/robot/standard_libraries/process/newlines_and_encoding.txt
 /atest/robot/standard_libraries/process/no_active_process.txt
 /atest/robot/standard_libraries/process/process_library.txt
 /atest/robot/standard_libraries/process/sending_signal.txt
 /atest/robot/standard_libraries/process/start_process_preferences.txt
 /atest/robot/standard_libraries/process/terminate_and_pid.txt
 /atest/robot/standard_libraries/process/wait_for_process.txt
 /atest/testdata/standard_libraries/process/newlines_and_encoding.txt
 /atest/testdata/standard_libraries/process/resource.txt
 /atest/testdata/standard_libraries/process/sending_signal.txt
 /atest/testdata/standard_libraries/process/terminate_and_pid.txt
 /atest/testdata/standard_libraries/process/wait_for_process.txt

=======================================
--- /dev/null
+++ /atest/robot/standard_libraries/process/process_resource.txt Tue Jan 28 09:20:00 2014 UTC
@@ -0,0 +1,9 @@
+*** Settings ***
+Resource          atest_resource.txt
+
+*** Keywords ***
+Check Precondition
+    ${tc} =    Get Test Case    ${TEST NAME}
+    @{tags} =    Set Variable    ${tc.tags}
+    Run Keyword If   'precondition-fail' in ${tags}
+    ...    Fail    precondition fail    -regression
=======================================
--- /atest/robot/standard_libraries/process/get_process_result.txt Mon Oct 28 07:57:05 2013 UTC +++ /atest/robot/standard_libraries/process/get_process_result.txt Tue Jan 28 09:20:00 2014 UTC
@@ -1,7 +1,7 @@
 *** Settings ***
Suite Setup Run Tests ${EMPTY} standard_libraries/process/get_process_result.txt
 Force Tags       regression    pybot    jybot
-Resource         atest_resource.txt
+Resource         process_resource.txt

 *** Test Cases ***
 Get whole result object
=======================================
--- /atest/robot/standard_libraries/process/is_process_alive.txt Thu Jun 13 23:28:50 2013 UTC +++ /atest/robot/standard_libraries/process/is_process_alive.txt Tue Jan 28 09:20:00 2014 UTC
@@ -1,7 +1,7 @@
 *** Settings ***
Suite Setup Run Tests ${EMPTY} standard_libraries/process/is_process_alive.txt
 Force Tags       regression    pybot    jybot
-Resource         atest_resource.txt
+Resource         process_resource.txt

 *** Test Cases ***
 No Process Should Fail
=======================================
--- /atest/robot/standard_libraries/process/newlines_and_encoding.txt Tue Jun 11 07:49:42 2013 UTC +++ /atest/robot/standard_libraries/process/newlines_and_encoding.txt Tue Jan 28 09:20:00 2014 UTC
@@ -1,8 +1,8 @@
 *** Settings ***
-Suite Setup Run Tests ${EMPTY} standard_libraries/process/newlines_and_encoding.txt +Suite Setup Run Tests ${EMPTY} standard_libraries/process/newlines_and_encoding.txt
 Force Tags       regression    pybot    jybot
-Test Setup       Check Preconditions
-Resource         atest_resource.txt
+Resource         process_resource.txt
+Test Setup       Check Precondition

 *** Test Cases ***
 Non-ascii in the command using shell=True
@@ -25,8 +25,3 @@

 Newline test using shell=False
     Check Test Case    ${TESTNAME}
-
-*** Keywords ***
-Check Preconditions
- Run Keyword If '${SUITE.metadata.get('info')}' == 'precondition_fail' Fail precondition fail -regression
-    Set Environment Variable     GLOBAL_TEST_ENCODING_VAR    t EURO stvär
=======================================
--- /atest/robot/standard_libraries/process/no_active_process.txt Tue Jun 11 08:34:12 2013 UTC +++ /atest/robot/standard_libraries/process/no_active_process.txt Tue Jan 28 09:20:00 2014 UTC
@@ -1,7 +1,7 @@
 *** Settings ***
Suite Setup Run Tests ${EMPTY} standard_libraries/process/no_active_process.txt
 Force Tags       regression    pybot    jybot
-Resource         atest_resource.txt
+Resource         process_resource.txt

 *** Test Cases ***
 No active process
=======================================
--- /atest/robot/standard_libraries/process/process_library.txt Mon Nov 18 08:12:22 2013 UTC +++ /atest/robot/standard_libraries/process/process_library.txt Tue Jan 28 09:20:00 2014 UTC
@@ -1,7 +1,7 @@
 *** Settings ***
-Suite Setup Run Tests ${EMPTY} standard_libraries/process/process_library.txt +Suite Setup Run Tests ${EMPTY} standard_libraries/process/process_library.txt
 Force Tags       regression    pybot    jybot
-Resource         atest_resource.txt
+Resource         process_resource.txt

 *** Test Cases ***
 Library Namespace should be global
=======================================
--- /atest/robot/standard_libraries/process/sending_signal.txt Thu Oct 31 14:17:07 2013 UTC +++ /atest/robot/standard_libraries/process/sending_signal.txt Tue Jan 28 09:20:00 2014 UTC
@@ -1,8 +1,8 @@
 *** Settings ***
Suite Setup Run Tests ${EMPTY} standard_libraries/process/sending_signal.txt
 Force Tags       regression    pybot    jybot
-Test Setup       Check Preconditions
-Resource         atest_resource.txt
+Test Setup       Check Precondition
+Resource         process_resource.txt

 *** Test Cases ***
 Sending INT signal
@@ -28,7 +28,3 @@

 Sending signal to a process with a wrong handle
     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/start_process_preferences.txt Thu Jun 13 23:28:50 2013 UTC +++ /atest/robot/standard_libraries/process/start_process_preferences.txt Tue Jan 28 09:20:00 2014 UTC
@@ -1,7 +1,7 @@
 *** Settings ***
Suite Setup Run Tests ${EMPTY} standard_libraries/process/start_process_preferences.txt
 Force Tags       regression    pybot    jybot
-Resource         atest_resource.txt
+Resource         process_resource.txt

 *** Test Cases ***
 Explicitly run Operating System library keyword
=======================================
--- /atest/robot/standard_libraries/process/terminate_and_pid.txt Mon Nov 18 08:12:22 2013 UTC +++ /atest/robot/standard_libraries/process/terminate_and_pid.txt Tue Jan 28 09:20:00 2014 UTC
@@ -1,8 +1,8 @@
 *** Settings ***
Suite Setup Run Tests ${EMPTY} standard_libraries/process/terminate_and_pid.txt
-Test Setup       Check Preconditions
+Test Setup       Check Precondition
 Force Tags       regression    pybot    jybot
-Resource         atest_resource.txt
+Resource         process_resource.txt

 *** Test Cases ***
 Run process does not change active process
@@ -45,7 +45,3 @@

 Lot of output
     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/wait_for_process.txt Mon Oct 21 09:14:07 2013 UTC +++ /atest/robot/standard_libraries/process/wait_for_process.txt Tue Jan 28 09:20:00 2014 UTC
@@ -1,8 +1,8 @@
 *** Settings ***
Suite Setup Run Tests ${EMPTY} standard_libraries/process/wait_for_process.txt
-Test Setup       Check Preconditions
+Test Setup       Check Precondition
 Force Tags       regression    pybot    jybot
-Resource         atest_resource.txt
+Resource         process_resource.txt

 *** Test Cases ***
 Wait For Process
@@ -27,7 +27,3 @@
Check Log Message ${tc.kws[2].msgs[0]} Waiting for process to complete. Check Log Message ${tc.kws[2].msgs[1]} Process did not complete in 1 second. Check Log Message ${tc.kws[2].msgs[2]} Forcefully killing process.
-
-*** Keywords ***
-Check Preconditions
- Run Keyword If '${SUITE.metadata.get('info')}' == 'precondition_fail' Fail precondition fail -regression
=======================================
--- /atest/testdata/standard_libraries/process/newlines_and_encoding.txt Thu Jun 13 23:28:50 2013 UTC +++ /atest/testdata/standard_libraries/process/newlines_and_encoding.txt Tue Jan 28 09:20:00 2014 UTC
@@ -1,6 +1,6 @@
 *** Settings ***
-Suite Setup       Check Precondition    sys.version_info >= (2,6)
 Resource          resource.txt
+Test Setup        Check Precondition    sys.version_info >= (2,6)

 *** Test Cases ***
 Non-ascii in the command using shell=True
=======================================
--- /atest/testdata/standard_libraries/process/resource.txt Thu Oct 31 15:10:46 2013 UTC +++ /atest/testdata/standard_libraries/process/resource.txt Tue Jan 28 09:20:00 2014 UTC
@@ -52,6 +52,6 @@

 Check Precondition
     [Arguments]    ${precondition}
-    ${nok}=    Evaluate    not (${precondition})    modules=sys,os
-    Run Keyword If  ${nok}    Set Suite Metadata  info   precondition_fail
-    Run Keyword If  ${nok}    Fail    ${precondition} was not true
+    ${ok} =    Evaluate    ${precondition}    modules=sys,os
+    Run Keyword If    not ${ok}
+ ... Fail Precondition '${precondition}' was not true. precondition-fail
=======================================
--- /atest/testdata/standard_libraries/process/sending_signal.txt Tue Dec 3 06:23:13 2013 UTC +++ /atest/testdata/standard_libraries/process/sending_signal.txt Tue Jan 28 09:20:00 2014 UTC
@@ -1,5 +1,5 @@
 *** Settings ***
-Suite Setup Check Precondition os.sep == "/" and sys.version_info
= (2,6)
+Test Setup Check Precondition os.sep == "/" and sys.version_info
= (2,6)
 Suite Teardown    Terminate All Processes
 Resource          resource.txt

=======================================
--- /atest/testdata/standard_libraries/process/terminate_and_pid.txt Mon Nov 18 08:12:43 2013 UTC +++ /atest/testdata/standard_libraries/process/terminate_and_pid.txt Tue Jan 28 09:20:00 2014 UTC
@@ -1,5 +1,5 @@
 *** Settings ***
-Suite Setup       Check Precondition    sys.version_info >= (2,6)
+Test Setup        Check Precondition    sys.version_info >= (2,6)
 Test Teardown     Terminate All Processes    kill=True
 Library           Collections
 Resource          resource.txt
=======================================
--- /atest/testdata/standard_libraries/process/wait_for_process.txt Mon Oct 21 09:14:07 2013 UTC +++ /atest/testdata/standard_libraries/process/wait_for_process.txt Tue Jan 28 09:20:00 2014 UTC
@@ -1,5 +1,5 @@
 *** Settings ***
-Suite Setup       Check Precondition         sys.version_info >= (2,6)
+Test Setup        Check Precondition         sys.version_info >= (2,6)
 Test Teardown     Terminate All Processes    kill=True
 Library           Process
 Resource          resource.txt
@@ -12,21 +12,21 @@
     Should Be Equal As Integers    ${result.rc}    0

 Wait For Process Timeout
-    ${process} =    Start Python Process    while(True): pass
+    ${process} =    Start Python Process    while True: pass
     Process Should Be Running    ${process}
     ${result} =    Wait For Process    ${process}    timeout=1s
     Process Should Be Running    ${process}
     Should Be Equal    ${result}    ${NONE}

 Wait For Process Terminate On Timeout
-    ${process} =   Start Python Process    while(True): pass
+    ${process} =   Start Python Process    while True: pass
     Process Should Be Running    ${process}
${result} = Wait For Process ${process} timeout=1s on_timeout=terminate
     Process Should Be Stopped    ${process}
     Should Not Be Equal As Integers    ${result.rc}    0

 Wait For Process Kill On Timeout
-    ${process} =   Start Python Process    while(True): pass
+    ${process} =   Start Python Process    while True: pass
     Process Should Be Running    ${process}
${result} = Wait For Process ${process} timeout=1s on_timeout=kill
     Process Should Be Stopped    ${process}

==============================================================================
Revision: cd6df16791f2
Branch:   default
Author:   Robot Framework Developers (robotframew...@gmail.com)
Date:     Tue Jan 28 09:50:32 2014 UTC
Log:      Process: timeout and on_timeout arguments for Run Process.

New issue
Summary: Process: `timeout` and `on_timeout` arguments for `Run Process`
Owner: pekka.klarck
Status: Review
Labels: Target-2.8.4 Priority-Medium Type-Enhancement
It would be useful to be able to specify a timeout and an action what to do on timeout with Run Process. This can nowadays be achieved by using Start Process and Wait For Process keywords instead of Run Process. Because Run Process uses
these keywords internally, it's also easy to implement this enhancement.
http://code.google.com/p/robotframework/source/detail?r=cd6df16791f2

Added:
 /atest/robot/standard_libraries/process/run_process_with_timeout.txt
 /atest/testdata/standard_libraries/process/run_process_with_timeout.txt
Modified:
 /src/robot/libraries/Process.py

=======================================
--- /dev/null
+++ /atest/robot/standard_libraries/process/run_process_with_timeout.txt Tue Jan 28 09:50:32 2014 UTC
@@ -0,0 +1,29 @@
+*** Settings ***
+Suite Setup Run Tests ${EMPTY} standard_libraries/process/run_process_with_timeout.txt
+Force Tags       regression    pybot    jybot
+Test Setup       Check Precondition
+Resource         process_resource.txt
+
+*** Test Cases ***
+Finish before timeout
+    ${tc} =    Check Test Case    ${TESTNAME}
+ Check Log Message ${tc.kws[0].msgs[1]} Waiting for process to complete.
+    Check Log Message    ${tc.kws[0].msgs[2]}    Process completed.
+
+On timeout process is terminated by default
+    ${tc} =    Check Test Case    ${TESTNAME}
+ Check Log Message ${tc.kws[0].msgs[1]} Waiting for process to complete. + Check Log Message ${tc.kws[0].msgs[2]} Process did not complete in 3 milliseconds. + Check Log Message ${tc.kws[0].msgs[3]} Gracefully terminating process.
+
+On timeout process can be killed
+    ${tc} =    Check Test Case    ${TESTNAME}
+ Check Log Message ${tc.kws[0].msgs[1]} Waiting for process to complete. + Check Log Message ${tc.kws[0].msgs[2]} Process did not complete in 2 milliseconds. + Check Log Message ${tc.kws[0].msgs[3]} Forcefully killing process.
+
+On timeout process can be left running
+    ${tc} =    Check Test Case    ${TESTNAME}
+ Check Log Message ${tc.kws[0].msgs[1]} Waiting for process to complete. + Check Log Message ${tc.kws[0].msgs[2]} Process did not complete in 1 millisecond.
+    Check Log Message    ${tc.kws[0].msgs[3]}    Leaving process intact.
=======================================
--- /dev/null
+++ /atest/testdata/standard_libraries/process/run_process_with_timeout.txt Tue Jan 28 09:50:32 2014 UTC
@@ -0,0 +1,30 @@
+*** Settings ***
+Resource          resource.txt
+
+*** Test Cases ***
+Finish before timeout
+ ${result} = Run Process python -c print 'Hello, world!' timeout=10s
+    Should Be Equal    ${result.rc}    ${0}
+    Should Be Equal    ${result.stdout}    Hello, world!
+
+On timeout process is terminated by default
+    [Setup]    Check Precondition    sys.version_info >= (2,6)
+ ${result} = Run Process python -c import time; time.sleep(1); print 'done'
+    ...    timeout=3ms    stderr=STDOUT
+    Should Not Be Equal    ${result.rc}    ${0}
+    Should Be Equal    ${result.stdout}    ${EMPTY}
+
+On timeout process can be killed
+    [Setup]    Check Precondition    sys.version_info >= (2,6)
+ ${result} = Run Process python -c import time; time.sleep(1); print 'done'
+    ...    timeout=0.002s    on_timeout=kill    stderr=STDOUT
+    Should Not Be Equal    ${result.rc}    ${0}
+    Should Be Equal    ${result.stdout}    ${EMPTY}
+
+On timeout process can be left running
+ ${result} = Run Process python -c import time; time.sleep(0.1); print 'done'
+    ...    timeout=0.001    alias=exceed    on_timeout=CONTINUE
+    Should Be Equal    ${result}    ${None}
+    ${result} =    Wait For Process    handle=exceed
+    Should Be Equal    ${result.rc}    ${0}
+    Should Be Equal    ${result.stdout}    done
=======================================
--- /src/robot/libraries/Process.py     Thu Jan 23 14:00:53 2014 UTC
+++ /src/robot/libraries/Process.py     Tue Jan 28 09:50:32 2014 UTC
@@ -281,17 +281,34 @@
     def run_process(self, command, *arguments, **configuration):
         """Runs a process and waits for it to complete.

-        See `Specifying command and arguments` and `Process configuration`
-        for more information about the arguments.
+ `command` and `*arguments` specify the command to execute and arguments + passed to it. See `Specifying command and arguments` for more details.
+
+ `**configuration` contains additional configuration related to starting + processes and waiting for them to finish. See `Process configuration`
+        for more details about configuration related to starting processes.
+ Configuration related to waiting for processes consists of `timeout`
+        and `on_timeout` arguments that have same semantics as with `Wait
+ For Process` keyword. By default there is no timeout, and if timeout
+        is defined the default action on timeout is `terminate`.

Returns a `result object` containing information about the execution.

+        Examples:
+        | ${result} = | Run Process | python | -c | print 'Hello, world!' |
+        | Should Be Equal | ${result.stdout} | Hello, world! |
+ | ${result} = | Run Process | ${command} | stderr=STDOUT | timeout=10s | + | ${result} = | Run Process | ${command} | timeout=1min | on_timeout=continue |
+
         This command does not change the `active process`.
+ `timeout` and `on_timeout` arguments are new in Robot Framework 2.8.4.
         """
         current = self._processes.current
+        timeout = configuration.pop('timeout', None)
+        on_timeout = configuration.pop('on_timeout', 'terminate')
         try:
handle = self.start_process(command, *arguments, **configuration)
-            return self.wait_for_process(handle)
+            return self.wait_for_process(handle, timeout, on_timeout)
         finally:
             self._processes.current = current

--

--- 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 robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to