Revision: f159d7a6b892
Branch: default
Author: Pekka Klärck
Date: Wed Sep 19 15:28:44 2012
Log: Trying to make tidy console test pass on Windows.
Update issue 1239
Console output test still failed on Windows. New attempt.
http://code.google.com/p/robotframework/source/detail?r=f159d7a6b892
Modified:
/atest/robot/tidy/TidyLib.py
/atest/robot/tidy/tidy.txt
/atest/testdata/tidy/golden.html
/atest/testdata/tidy/golden.tsv
/atest/testdata/tidy/golden.txt
/atest/testdata/tidy/golden_pipes.txt
/atest/testdata/tidy/golden_two_spaces.txt
=======================================
--- /atest/robot/tidy/TidyLib.py Wed Sep 19 14:15:36 2012
+++ /atest/robot/tidy/TidyLib.py Wed Sep 19 15:28:44 2012
@@ -1,11 +1,12 @@
from __future__ import with_statement
import os
+import re
from os.path import abspath, dirname, join
from subprocess import call, STDOUT
import tempfile
-from robot.utils.asserts import assert_equals
+from robot.utils.asserts import assert_equals, assert_true
from robot.utils import decode_output
@@ -51,16 +52,28 @@
result = self.run_tidy(options, input, output, tidy)
self.compare_tidy_results(output or result, expected or input)
- def compare_tidy_results(self, result, expected):
+ def compare_tidy_results(self, result, expected, *filters):
if os.path.isfile(result):
result = self._read(result)
+ filters = [re.compile('^%s$' % f) for f in filters]
expected = self._read(expected)
result_lines = result.splitlines()
expected_lines = expected.splitlines()
- msg = "Actual:\n%s\n\nExpected:\n%s\n\n" % (repr(result),
repr(expected))
+ msg = "Actual:\n%r\n\nExpected:\n%r\n\n" % (result, expected)
assert_equals(len(result_lines), len(expected_lines), msg)
- for line1, line2 in zip(result_lines, expected_lines):
- assert_equals(repr(unicode(line1)), repr(unicode(line2)), msg)
+ for res, exp in zip(result_lines, expected_lines):
+ filter = self._filter_matches(filters, exp)
+ if not filter:
+ assert_equals(repr(unicode(res)), repr(unicode(exp)), msg)
+ else:
+ assert_true(filter.match(res),
+ '%s: %r does not match %r' % (msg, res,
filter.pattern))
+
+ def _filter_matches(self, filters, expected):
+ for filter in filters:
+ if filter.match(expected):
+ return filter
+ return None
def _path(self, path):
return abspath(join(DATA_DIR, path.replace('/', os.sep)))
=======================================
--- /atest/robot/tidy/tidy.txt Wed Sep 19 14:42:11 2012
+++ /atest/robot/tidy/tidy.txt Wed Sep 19 15:28:44 2012
@@ -27,7 +27,9 @@
File Should Exist ${TEMP FILE}
Tidying single file without output file prints output to console
- Run tidy and check result ${EMPTY} golden.txt output=
+ [Documentation] Depending on console encoding, non-ASCII characters
may not be shown correctly
+ ${stdout} = Run tidy ${EMPTY} golden.txt output=${NONE}
+ Compare tidy results ${stdout} golden.txt
\\s+Log\\s+Non-ASCII:.*
File Should Not Exist ${TEMP FILE}
Tidying single file in place
=======================================
--- /atest/testdata/tidy/golden.html Wed Aug 29 04:32:24 2012
+++ /atest/testdata/tidy/golden.html Wed Sep 19 15:28:44 2012
@@ -197,7 +197,7 @@
<tr>
<td class="name"><a name="test_Another Test">Another Test</a></td>
<td>Log</td>
-<td>ääöö§§</td>
+<td>Non-ASCII: ääöö§§</td>
<td></td>
<td></td>
</tr>
=======================================
--- /atest/testdata/tidy/golden.tsv Wed Aug 29 04:32:24 2012
+++ /atest/testdata/tidy/golden.tsv Wed Sep 19 15:28:44 2012
@@ -16,7 +16,7 @@
My TC Step 2 my step 2 arg second \ arg # step 2 comment
[Teardown] 1 minute args
-Another Test Log ääöö§§
+Another Test Log Non-ASCII: ääöö§§
*Keywords*
My Keyword [Documentation] Documentation # Comment for doc
=======================================
--- /atest/testdata/tidy/golden.txt Wed Aug 29 04:32:24 2012
+++ /atest/testdata/tidy/golden.txt Wed Sep 19 15:28:44 2012
@@ -18,7 +18,7 @@
[Teardown] 1 minute args
Another Test
- Log ääöö§§
+ Log Non-ASCII: ääöö§§
*** Keywords ***
My Keyword
=======================================
--- /atest/testdata/tidy/golden_pipes.txt Wed Aug 29 04:32:24 2012
+++ /atest/testdata/tidy/golden_pipes.txt Wed Sep 19 15:28:44 2012
@@ -18,7 +18,7 @@
| | [Teardown] | 1 minute | args |
| Another Test |
-| | Log | ääöö§§ |
+| | Log | Non-ASCII: ääöö§§ |
| *** Keywords *** |
| My Keyword |
=======================================
--- /atest/testdata/tidy/golden_two_spaces.txt Wed Aug 29 04:32:24 2012
+++ /atest/testdata/tidy/golden_two_spaces.txt Wed Sep 19 15:28:44 2012
@@ -18,7 +18,7 @@
[Teardown] 1 minute args
Another Test
- Log ääöö§§
+ Log Non-ASCII: ääöö§§
*** Keywords ***
My Keyword