Revision: 2ffcba80c436
Branch: default
Author: Tatu Kairi <[email protected]>
Date: Tue Apr 29 08:01:31 2014 UTC
Log: Fixed bug in newline stripping in `Grep File`
Update issue 1665
Implementation and tests updated based on review.
Windows newlines should be now correctly stripped.
http://code.google.com/p/robotframework/source/detail?r=2ffcba80c436
Added:
/atest/testdata/standard_libraries/operating_system/files/utf-8_windows_line_endings.txt
Modified:
/atest/robot/standard_libraries/operating_system/get_file.txt
/atest/testdata/standard_libraries/operating_system/get_file.txt
/src/robot/libraries/OperatingSystem.py
=======================================
--- /dev/null
+++
/atest/testdata/standard_libraries/operating_system/files/utf-8_windows_line_endings.txt
Tue Apr 29 08:01:31 2014 UTC
@@ -0,0 +1,5 @@
+foo
+bar
+foo bar
+
+A Foo
=======================================
--- /atest/robot/standard_libraries/operating_system/get_file.txt Fri Apr
25 13:57:09 2014 UTC
+++ /atest/robot/standard_libraries/operating_system/get_file.txt Tue Apr
29 08:01:31 2014 UTC
@@ -79,3 +79,7 @@
${tc}= Check testcase ${TESTNAME}
Check Log Message ${tc.kws[0].kws[0].msgs[1]} 1 out of 5 lines
matched
Check Log Message ${tc.kws[1].kws[0].msgs[1]} 1 out of 5 lines
matched
+
+Grep File With Windows line endings
+ ${tc}= Check testcase ${TESTNAME}
+ Check Log Message ${tc.kws[0].kws[0].msgs[1]} 1 out of 5 lines
matched
=======================================
--- /atest/testdata/standard_libraries/operating_system/get_file.txt Fri
Apr 25 13:57:09 2014 UTC
+++ /atest/testdata/standard_libraries/operating_system/get_file.txt Tue
Apr 29 08:01:31 2014 UTC
@@ -14,6 +14,7 @@
${utf-16 BE file} ${CURDIR}${/}files${/}utf-16BE.txt #
Big Endian
${utf-16 LE with BOM file} ${CURDIR}${/}files${/}utf-16LEBOM.txt #
Little Endian with Byte Order Marker
${utf-16 BE with BOM file} ${CURDIR}${/}files${/}utf-16BEBOM.txt #
Big Endian with BOM
+${utf-8 with windows line endings}
${CURDIR}${/}files${/}utf-8_windows_line_endings.txt
*** Test Cases ***
Get File
@@ -111,6 +112,9 @@
[Template] Verify Grep File with error handler
ignore f bar
replace f\ufffd\ufffd bar
+
+Grep File With Windows line endings
+ Grep And Check File f*a foo bar ${utf-8 with windows line
endings}
*** Keywords ***
=======================================
--- /src/robot/libraries/OperatingSystem.py Fri Apr 25 13:57:09 2014 UTC
+++ /src/robot/libraries/OperatingSystem.py Tue Apr 29 08:01:31 2014 UTC
@@ -379,7 +379,7 @@
with codecs.open(path, encoding=encoding, errors=encoding_errors)
as f:
for line in f.readlines():
total_lines += 1
- line = line.strip('\r').rstrip('\n')
+ line = line.rstrip('\r\n')
if fnmatch.fnmatchcase(line, pattern):
lines.append(line)
self._info('%d out of %d lines matched' % (len(lines),
total_lines))
--
---
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/d/optout.