Revision: d845a456ec8b
Branch:   default
Author:   Robot Framework Developers (robotframew...@gmail.com)
Date:     Tue Jun 11 05:45:43 2013
Log: Final Process feature: automatically convert / -> \ in conf options on Windows.
http://code.google.com/p/robotframework/source/detail?r=d845a456ec8b

Modified:
 /atest/testdata/standard_libraries/process/process_library.txt
 /atest/testdata/standard_libraries/process/terminate_and_pid.txt
 /src/robot/libraries/Process.py

=======================================
--- /atest/testdata/standard_libraries/process/process_library.txt Tue Jun 11 05:07:40 2013 +++ /atest/testdata/standard_libraries/process/process_library.txt Tue Jun 11 05:45:43 2013
@@ -42,18 +42,18 @@
     Should Not Be Equal    ${result.stdout}    ${result2.stdout}

 Setting Stdout
- ${result}= Run Process python -c "print 'hello'" shell=True stdout=%{TEMPDIR}${/}myfile_1.txt
-    ${output}=    Get File    %{TEMPDIR}${/}myfile_1.txt
+ ${result}= Run Process python -c "print 'hello'" shell=True stdout=%{TEMPDIR}/myfile_1.txt
+    ${output}=    Get File    %{TEMPDIR}/myfile_1.txt
     Should Not Be Empty    ${output}
     Should Match  ${output}   ${result.stdout}*
- [Teardown] Run Keyword And Ignore Error Remove File %{TEMPDIR}${/}myfile_1.txt + [Teardown] Run Keyword And Ignore Error Remove File %{TEMPDIR}/myfile_1.txt

 Setting Stderr
- ${result}= Run Process python -c "1/0" shell=True stderr=%{TEMPDIR}${/}myfile.txt
-    ${output}=    Get File    %{TEMPDIR}${/}myfile.txt
+ ${result}= Run Process python -c "1/0" shell=True stderr=%{TEMPDIR}/myfile.txt
+    ${output}=    Get File    %{TEMPDIR}/myfile.txt
     Should Not Be Empty    ${output}
     Should Match   ${output}   ${result.stderr}*
- [Teardown] Run Keyword And Ignore Error Remove File %{TEMPDIR}${/}myfile.txt + [Teardown] Run Keyword And Ignore Error Remove File %{TEMPDIR}/myfile.txt

 Without Env Configuration the Environment Should Be As It Was
     Set Environment Variable  normalvar  normal
@@ -135,19 +135,19 @@
     [Teardown]    Run Keyword And Ignore Error   Remove File    ${path}

 Current working directory should be used with stdout and stderr
-    Create Directory    %{TEMPDIR}${/}hc
- ${result}= Run Process python -c print 'moon kuu';1/0 cwd=%{TEMPDIR}${/}hc stdout=myout.txt
+    Create Directory    %{TEMPDIR}/hc
+ ${result}= Run Process python -c print 'moon kuu';1/0 cwd=%{TEMPDIR}/hc stdout=myout.txt
     ...    stderr=myerr.txt
-    ${output}=    Get File    %{TEMPDIR}${/}hc${/}myout.txt
-    ${output2}=    Get File    %{TEMPDIR}${/}hc${/}myerr.txt
+    ${output}=    Get File    %{TEMPDIR}/hc/myout.txt
+    ${output2}=    Get File    %{TEMPDIR}/hc/myerr.txt
     Should Match    ${output}    *moon kuu*
     Should Match    ${output2}    *ZeroDivisionError*
- [Teardown] Run Keyword And Ignore Error Remove Directory %{TEMPDIR}${/}hc recursive=True + [Teardown] Run Keyword And Ignore Error Remove Directory %{TEMPDIR}/hc recursive=True

Current working directory should not be used with stdout and stderr when absolute path in use
-    Create Directory    %{TEMPDIR}${/}hc
+    Create Directory    %{TEMPDIR}/hc
     ${stdout_path}=    Normalize Path    %{TEMPDIR}/stdout.txt
- ${result}= Run Process python -c print 'moon kuu';1/0 cwd=%{TEMPDIR}${/}hc stdout=${stdout_path} + ${result}= Run Process python -c print 'moon kuu';1/0 cwd=%{TEMPDIR}/hc stdout=${stdout_path}
     ...    stderr=stderr.txt
     ${stderr_path}=    Normalize Path    %{TEMPDIR}/hc/stderr.txt
     ${stdout}=    Get File    ${stdout_path}
@@ -156,7 +156,7 @@
     Should Match    ${stderr}    *ZeroDivisionError*
     Should Be Equal    ${result.stdout_path}    ${stdout_path}
     Should Be Equal    ${result.stderr_path}    ${stderr_path}
- [Teardown] Remove Directory and File %{TEMPDIR}${/}hc ${stdout_path}} + [Teardown] Remove Directory and File %{TEMPDIR}/hc ${stdout_path}}

 *** Keywords ***
 Restart Suite Process If Needed
=======================================
--- /atest/testdata/standard_libraries/process/terminate_and_pid.txt Tue Jun 11 05:07:40 2013 +++ /atest/testdata/standard_libraries/process/terminate_and_pid.txt Tue Jun 11 05:45:43 2013
@@ -66,7 +66,7 @@

 Lot of output
     [Tags]    performance
-    ${stdout}=    Normalize Path    %{TEMPDIR}${/}stdout.txt
+    ${stdout}=    Normalize Path    %{TEMPDIR}/stdout.txt
${handle}= Run Process python -c "for i in range(350000): \tprint 'a'*400" shell=True stdout=${stdout} stderr=STDOUT
     File Should Not Be Empty    ${stdout}
     [Teardown]    Run Keyword And Ignore Error    Remove File    ${stdout}
=======================================
--- /src/robot/libraries/Process.py     Tue Jun 11 05:39:44 2013
+++ /src/robot/libraries/Process.py     Tue Jun 11 05:45:43 2013
@@ -17,8 +17,8 @@
 import os
 import subprocess

-from robot.utils import (ConnectionCache, encode_to_system, decode_from_system,
-                         get_env_vars)
+from robot.utils import (ConnectionCache, abspath, encode_to_system,
+                         decode_from_system, get_env_vars)
 from robot.version import get_version
 from robot.api import logger

@@ -106,13 +106,15 @@
     By default the child process will be executed in the same directory
     as the parent process, the process running tests, is executed. This
can be changed by giving an alternative location using the `cwd` argument.
+    Forward slashes in the given path are automatically converted to
+    backslashes on Windows.

     `Standard output and error streams`, when redirected to files,
     are also relative to the current working directory possibly set using
     the `cwd` argument.

     Example:
-    | `Run Process` | prog.exe | cwd=c:\\\\temp | stdout=stdout.txt |
+ | `Run Process` | prog.exe | cwd=${ROOT}/directory | stdout=stdout.txt |

     == Environment variables ==

@@ -139,11 +141,10 @@
     and `stderr` arguments to specify files on the file system where to
     redirect the outputs. This can also be useful if other processes or
     other keywords need to read or manipulate the outputs somehow.
+
     Given `stdout` and `stderr` paths are relative to the `current working
-    directory`.
-
- *Note:* The created files are not automatically removed after the test run
-    and the user is responsible of removing the output files if needed.
+ directory`. Forward slashes in the given paths are automatically converted
+    to backslashes on Windows.

     As a special feature, it is possible to redirect the standard error to
     the standard output by using `stderr=STDOUT`.
@@ -157,6 +158,9 @@
     | ${result} = | `Run Process` | program | stderr=STDOUT |
     | `Log`       | all output: ${result.stdout} |

+    *Note:* The created output files are not automatically removed after
+    the test run. The user is responsible to remove them if needed.
+
     == Alias ==

     A custom name given to the process that can be used when selecting the
@@ -484,15 +488,21 @@

     def __init__(self, cwd=None, shell=False, stdout=None, stderr=None,
                  alias=None, env=None, **rest):
-        self.cwd = cwd or os.path.abspath(os.curdir)
+        self.cwd = self._get_cwd(cwd)
         self.stdout_stream = self._new_stream(stdout)
         self.stderr_stream = self._get_stderr(stderr, stdout)
         self.shell = bool(shell)
         self.alias = alias
         self.env = self._construct_env(env, rest)

+    def _get_cwd(self, cwd):
+        if cwd:
+            return cwd.replace('/', os.sep)
+        return abspath('.')
+
     def _new_stream(self, name):
         if name:
+            name = name.replace('/', os.sep)
             return open(os.path.join(self.cwd, name), 'w')
         return subprocess.PIPE

--

--- 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