5 new revisions:
Revision: 49b597c02fea
Author: Pekka Klärck
Date: Wed Aug 29 03:17:56 2012
Log: parsing: renamed method and attribute
http://code.google.com/p/robotframework/source/detail?r=49b597c02fea
Revision: 9454792df053
Author: Pekka Klärck
Date: Wed Aug 29 03:25:41 2012
Log: slightly better tests for parsing comments in variable table
http://code.google.com/p/robotframework/source/detail?r=9454792df053
Revision: 09a7752d255a
Author: Pekka Klärck
Date: Wed Aug 29 04:09:07 2012
Log: tidy atests: cleanup
http://code.google.com/p/robotframework/source/detail?r=09a7752d255a
Revision: 02cb486c9ce6
Author: Pekka Klärck
Date: Wed Aug 29 04:28:21 2012
Log: even better tests for parsing comments in variable table
http://code.google.com/p/robotframework/source/detail?r=02cb486c9ce6
Revision: 978a6ed18f88
Author: Pekka Klärck
Date: Wed Aug 29 04:32:24 2012
Log: writer/tidy: Write standalone comments in variable table starting
from...
http://code.google.com/p/robotframework/source/detail?r=978a6ed18f88
==============================================================================
Revision: 49b597c02fea
Author: Pekka Klärck
Date: Wed Aug 29 03:17:56 2012
Log: parsing: renamed method and attribute
http://code.google.com/p/robotframework/source/detail?r=49b597c02fea
Modified:
/src/robot/parsing/comments.py
/src/robot/parsing/tablepopulators.py
=======================================
--- /src/robot/parsing/comments.py Tue Aug 28 13:41:31 2012
+++ /src/robot/parsing/comments.py Wed Aug 29 03:17:56 2012
@@ -21,7 +21,7 @@
def add(self, comment):
self._comments.append(comment)
- def consume(self, function):
+ def consume_with(self, function):
map(function, self._comments)
self.__init__()
=======================================
--- /src/robot/parsing/tablepopulators.py Wed Aug 29 02:05:15 2012
+++ /src/robot/parsing/tablepopulators.py Wed Aug 29 03:17:56 2012
@@ -72,7 +72,7 @@
raise NotImplementedError
def _consume_comments(self):
- self._comment_cache.consume(self._populator.add)
+ self._comment_cache.consume_with(self._populator.add)
def _consume_standalone_comments(self):
self._consume_comments()
@@ -102,7 +102,7 @@
return VariablePopulator(self._table.add, row.head)
def _consume_standalone_comments(self):
- self._comment_cache.consume(self._populate_standalone_comment)
+ self._comment_cache.consume_with(self._populate_standalone_comment)
def _populate_standalone_comment(self, comment):
populator = self._get_populator(comment)
@@ -173,11 +173,11 @@
self._test_or_uk_creator = test_or_uk_creator
self._test_or_uk = None
self._populator = NullPopulator()
- self._comments = CommentCache()
+ self._comment_cache = CommentCache()
def add(self, row):
if row.is_commented():
- self._comments.add(row)
+ self._comment_cache.add(row)
return
if not self._test_or_uk:
self._test_or_uk = self._test_or_uk_creator(row.head)
@@ -189,9 +189,9 @@
if not self._continues(row):
self._populator.populate()
self._populator = self._get_populator(row)
- self._comments.consume(self._populate_comment_row)
+ self._comment_cache.consume_with(self._populate_comment_row)
else:
- self._comments.consume(self._populator.add)
+ self._comment_cache.consume_with(self._populator.add)
self._populator.add(row)
def _populate_comment_row(self, crow):
@@ -201,7 +201,7 @@
def populate(self):
self._populator.populate()
- self._comments.consume(self._populate_comment_row)
+ self._comment_cache.consume_with(self._populate_comment_row)
def _get_populator(self, row):
if row.starts_test_or_user_keyword_setting():
==============================================================================
Revision: 9454792df053
Author: Pekka Klärck
Date: Wed Aug 29 03:25:41 2012
Log: slightly better tests for parsing comments in variable table
http://code.google.com/p/robotframework/source/detail?r=9454792df053
Modified:
/utest/parsing/test_populator.py
=======================================
--- /utest/parsing/test_populator.py Wed Aug 29 02:05:15 2012
+++ /utest/parsing/test_populator.py Wed Aug 29 03:25:41 2012
@@ -537,16 +537,24 @@
['${name}', '# no value'],
['#label', 'A', 'B', 'C'],
['@{items}', '1', '2', '3'],
- ['${X}', '##end comment'],
- ['', '', '#comment'],
- ['...', 'VAL'],
+ ['# s1'],
+ ['', '# s2', ''],
+ ['', '', '# s3'],
+ ['@{X}', '# c1'],
+ ['', '', '# c2'],
+ ['...', 'V1', '# c3'],
+ ['# c4'],
+ ['...', 'V2', '# c5'],
['#EOT']])
self._assert_variable(0, '${varname}', ['varvalue'], ['# has
comment'])
self._assert_variable(1, '${name}', [''], ['# no value'])
self._assert_variable(2, '', [], ['# label', 'A', 'B', 'C'])
self._assert_variable(3, '@{items}', ['1', '2', '3'])
- self._assert_variable(4, '${X}', ['VAL'], ['#end
comment', 'comment'])
- self._assert_variable(5, '', [], ['# EOT'])
+ self._assert_variable(4, '', [], ['# s1'])
+ self._assert_variable(5, '', [], ['# s2'])
+ self._assert_variable(6, '', [], ['# s3'])
+ self._assert_variable(7, '@{X}', ['V1', 'V2'], ['#
c1', 'c2', 'c3', 'c4', 'c5'])
+ self._assert_variable(8, '', [], ['# EOT'])
def test_test_case_table(self):
self._create_table('test cases', [['#start of table comment'],
==============================================================================
Revision: 09a7752d255a
Author: Pekka Klärck
Date: Wed Aug 29 04:09:07 2012
Log: tidy atests: cleanup
http://code.google.com/p/robotframework/source/detail?r=09a7752d255a
Modified:
/atest/robot/tidy/TidyLib.py
/atest/robot/tidy/empty_tables.txt
/atest/robot/tidy/tidy.txt
/atest/robot/tidy/tidy_resource.txt
=======================================
--- /atest/robot/tidy/TidyLib.py Thu Jun 14 06:08:25 2012
+++ /atest/robot/tidy/TidyLib.py Wed Aug 29 04:09:07 2012
@@ -7,7 +7,9 @@
from robot.utils.asserts import assert_equals
+
ROBOT_SRC = join(dirname(abspath(__file__)), '..', '..', '..', 'src')
+DATA_DIR = join(dirname(abspath(__file__)), '..', '..', 'testdata', 'tidy')
class TidyLib(object):
@@ -19,8 +21,9 @@
def run_tidy(self, options, input, command=None):
"""Runs tidy in the operating system and returns output."""
options = options.split(' ') if options else []
+ command = command or self._cmd
with tempfile.TemporaryFile() as output:
- rc = call(self._cmd + options + [self._path(input)],
stdout=output,
+ rc = call(command + options + [self._path(input)],
stdout=output,
stderr=STDOUT, cwd=ROBOT_SRC, shell=os.sep=='\\')
output.seek(0)
content = output.read()
@@ -42,8 +45,7 @@
def compare_tidy_results(self, result, expected):
if os.path.isfile(result):
result = self._read(result)
- if os.path.isfile(expected):
- expected = self._read(expected)
+ 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))
@@ -52,7 +54,7 @@
assert_equals(repr(unicode(line1)), repr(unicode(line2)), msg)
def _path(self, path):
- return path.replace('/', os.sep)
+ return join(DATA_DIR, path.replace('/', os.sep))
def _read(self, path):
with open(self._path(path)) as f:
=======================================
--- /atest/robot/tidy/empty_tables.txt Thu Jun 14 06:08:25 2012
+++ /atest/robot/tidy/empty_tables.txt Wed Aug 29 04:09:07 2012
@@ -1,13 +1,13 @@
*** Settings ***
Force Tags pybot jybot regression
Resource tidy_resource.txt
-Suite Setup Create Directory ${TIDYDIR}
-Suite Teardown Remove Directory ${TIDYDIR} recursive=True
+Suite Setup Create Directory ${TEMP}
+Suite Teardown Remove Directory ${TEMP} recursive=True
*** Test cases ***
Empty test case file
- Run tidy and check result ${EMPTY}
${DATADIR}/testsuite_with_empty_tables.txt
+ Run tidy and check result ${EMPTY}
testsuite_with_empty_tables.txt
Empty resource file
- Run tidy and check result ${EMPTY}
${DATADIR}/resource_with_empty_tables.txt
+ Run tidy and check result ${EMPTY} resource_with_empty_tables.txt
=======================================
--- /atest/robot/tidy/tidy.txt Thu Jun 14 06:08:25 2012
+++ /atest/robot/tidy/tidy.txt Wed Aug 29 04:09:07 2012
@@ -2,72 +2,72 @@
Force Tags pybot jybot regression
Library OperatingSystem
Resource tidy_resource.txt
-Suite Setup Create Directory ${TIDYDIR}
-Suite Teardown Remove Directory ${TIDYDIR} recursive=True
+Suite Setup Create Directory ${TEMP}
+Suite Teardown Remove Directory ${TEMP} recursive=True
*** Test cases ***
Tidying single test case file
[Documentation] Test tidying to different formats
[Template] Run tidy with golden file and check result
- ${EMPTY} ${DATADIR}/golden.txt
- --usepipes ${DATADIR}/golden_pipes.txt
- --format tsv ${DATADIR}/golden.tsv
- --format html ${DATADIR}/golden.html
- --spacecount 2 ${DATADIR}/golden_two_spaces.txt
+ ${EMPTY} golden.txt
+ --usepipes golden_pipes.txt
+ --format tsv golden.tsv
+ --format html golden.html
+ --spacecount 2 golden_two_spaces.txt
Tidying single resource file
[Template] Run tidy with golden resource file and check result
- ${EMPTY} ${DATADIR}/golden_resource.txt
- -p ${DATADIR}/golden_pipes_resource.txt
- -f tsv ${DATADIR}/golden_resource.tsv
- --FORMAT html ${DATADIR}/golden_resource.html
+ ${EMPTY} golden_resource.txt
+ -p golden_pipes_resource.txt
+ -f tsv golden_resource.tsv
+ --FORMAT html golden_resource.html
Tidying single init file
- Run tidy and check result ${EMPTY} ${DATADIR}/__init__.txt
${DATADIR}/__init__.txt
+ Run tidy and check result ${EMPTY} __init__.txt
Tidying single file in place
- [Setup] Copy File ${DATADIR}/golden.txt ${TIDYDIR}/golden.txt
- Run tidy --inplace --usepipes ${TIDYDIR}/golden.txt
- Compare tidy results ${TIDYDIR}/golden.txt
${DATADIR}/golden_pipes.txt
- Check file count ${TIDYDIR} *.txt 1
- [Teardown] Empty Directory ${TIDYDIR}
+ [Setup] Copy File ${DATA}/golden.txt ${TEMP}/golden.txt
+ Run tidy --inplace --usepipes ${TEMP}/golden.txt
+ Compare tidy results ${TEMP}/golden.txt ${DATA}/golden_pipes.txt
+ Check file count ${TEMP} *.txt 1
+ [Teardown] Empty Directory ${TEMP}
Tidying single file in place and change format
- [Setup] Copy File ${DATADIR}/golden.txt ${TIDYDIR}/golden.txt
- Run tidy -i -f html ${TIDYDIR}/golden.txt
${DATADIR}/golden.html
- Compare tidy results ${TIDYDIR}/golden.html
${DATADIR}/golden.html
- Check file count ${TIDYDIR} *.html 1
- Check file count ${TIDYDIR} *.txt 0
- [Teardown] Empty Directory ${TIDYDIR}
+ [Setup] Copy File ${DATA}/golden.txt ${TEMP}/golden.txt
+ Run tidy -i -f html ${TEMP}/golden.txt
+ Compare tidy results ${TEMP}/golden.html ${DATA}/golden.html
+ Check file count ${TEMP} *.html 1
+ Check file count ${TEMP} *.txt 0
+ [Teardown] Empty Directory ${TEMP}
Tidying many files in place
[Setup] Copy Golden Files
- List Directory ${TIDYDIR}
- Run tidy --InPlace --ForMat html ${TIDYDIR}/golden*
- List Directory ${TIDYDIR}
- Check file count ${TIDYDIR} *.html 2
- Check file count ${TIDYDIR} *.txt 0
- Check file count ${TIDYDIR} *.tsv 0
- [Teardown] Empty Directory ${TIDYDIR}
+ List Directory ${TEMP}
+ Run tidy --InPlace --ForMat html ${TEMP}/golden*
+ List Directory ${TEMP}
+ Check file count ${TEMP} *.html 2
+ Check file count ${TEMP} *.txt 0
+ Check file count ${TEMP} *.tsv 0
+ [Teardown] Empty Directory ${TEMP}
Tidying directory
- [Setup] Copy Directory ${DATADIR}/tests ${TEMPDIR}/tests
- ${output_before}= Run Robot Directly ${DATADIR}/tests
- Run Tidy --recursive --format tsv ${TEMPDIR}/tests
- Check file count ${TEMPDIR}/tests *.tsv 2
- Check file count ${TEMPDIR}/tests *.txt 0
- ${output_after}= Run Robot Directly ${TEMPDIR}/tests
+ [Setup] Copy Directory ${DATA}/tests ${TEMP}/tests
+ ${output_before}= Run Robot Directly ${DATA}/tests
+ Run Tidy --recursive --format tsv ${TEMP}/tests
+ Check file count ${TEMP}/tests *.tsv 2
+ Check file count ${TEMP}/tests *.txt 0
+ ${output_after}= Run Robot Directly ${TEMP}/tests
Should Be Equal ${output_before} ${output_after}
- [Teardown] Remove Directory ${TEMPDIR}/tests recursive=True
+ [Teardown] Remove Directory ${TEMP}/tests recursive=True
Custom headers are preserved and tables aligned accordingly
- Run tidy and check result ${EMPTY}
${DATADIR}/golden_with_headers.txt
+ Run tidy and check result ${EMPTY} golden_with_headers.txt
Running Tidy as a script
- Run tidy as a script and check result ${EMPTY}
${DATADIR}/golden.txt
+ Run tidy as a script and check result ${EMPTY} golden.txt
*** Keywords ***
Copy Golden Files
- Copy File ${DATADIR}/golden_pipes.txt ${TIDYDIR}/
- Copy File ${DATADIR}/golden.tsv ${TIDYDIR}/
+ Copy File ${DATA}/golden_pipes.txt ${TEMP}/
+ Copy File ${DATA}/golden.tsv ${TEMP}/
=======================================
--- /atest/robot/tidy/tidy_resource.txt Wed Jun 13 00:59:40 2012
+++ /atest/robot/tidy/tidy_resource.txt Wed Aug 29 04:09:07 2012
@@ -3,17 +3,17 @@
Resource atest_resource.txt
*** Variables ***
-${DATADIR} ${CURDIR}/../../testdata/tidy
-${TIDYDIR} ${TEMPDIR}/tidy-test
+${DATA} ${CURDIR}/../../testdata/tidy
+${TEMP} ${TEMPDIR}/tidy-test
*** Keywords ***
Run tidy with golden file and check result
[Arguments] ${options} ${expected_result_file}
- Run tidy and check result ${options} ${DATADIR}/golden.txt
${expected_result_file}
+ Run tidy and check result ${options} ${DATA}/golden.txt
${expected_result_file}
Run tidy with golden resource file and check result
[Arguments] ${options} ${expected_result_file}
- Run tidy and check result ${options}
${DATADIR}/golden_resource.txt ${expected_result_file}
+ Run tidy and check result ${options}
${DATA}/golden_resource.txt ${expected_result_file}
Check file count
[Arguments] ${directory} ${pattern} ${expected count}
==============================================================================
Revision: 02cb486c9ce6
Author: Pekka Klärck
Date: Wed Aug 29 04:28:21 2012
Log: even better tests for parsing comments in variable table
http://code.google.com/p/robotframework/source/detail?r=02cb486c9ce6
Modified:
/utest/parsing/test_populator.py
=======================================
--- /utest/parsing/test_populator.py Wed Aug 29 03:25:41 2012
+++ /utest/parsing/test_populator.py Wed Aug 29 04:28:21 2012
@@ -533,9 +533,10 @@
self._assert_meta(0, 'metaname', 'metavalue', ['# last line is
commented'])
def test_variable_table(self):
- self._create_table('variables', [['${varname}', 'varvalue', '#has
comment'],
+ self._create_table('variables', [['# before'],
+ ['${varname}', 'varvalue', '#has
comment'],
['${name}', '# no value'],
- ['#label', 'A', 'B', 'C'],
+ ['#middle', 'A', 'B', 'C'],
['@{items}', '1', '2', '3'],
['# s1'],
['', '# s2', ''],
@@ -546,15 +547,17 @@
['# c4'],
['...', 'V2', '# c5'],
['#EOT']])
- self._assert_variable(0, '${varname}', ['varvalue'], ['# has
comment'])
- self._assert_variable(1, '${name}', [''], ['# no value'])
- self._assert_variable(2, '', [], ['# label', 'A', 'B', 'C'])
- self._assert_variable(3, '@{items}', ['1', '2', '3'])
- self._assert_variable(4, '', [], ['# s1'])
- self._assert_variable(5, '', [], ['# s2'])
- self._assert_variable(6, '', [], ['# s3'])
- self._assert_variable(7, '@{X}', ['V1', 'V2'], ['#
c1', 'c2', 'c3', 'c4', 'c5'])
- self._assert_variable(8, '', [], ['# EOT'])
+ self._assert_no_parsing_errors()
+ self._assert_variable(0, '', [], ['# before'])
+ self._assert_variable(1, '${varname}', ['varvalue'], ['# has
comment'])
+ self._assert_variable(2, '${name}', [''], ['# no value'])
+ self._assert_variable(3, '', [], ['# middle', 'A', 'B', 'C'])
+ self._assert_variable(4, '@{items}', ['1', '2', '3'])
+ self._assert_variable(5, '', [], ['# s1'])
+ self._assert_variable(6, '', [], ['# s2'])
+ self._assert_variable(7, '', [], ['# s3'])
+ self._assert_variable(8, '@{X}', ['V1', 'V2'], ['#
c1', 'c2', 'c3', 'c4', 'c5'])
+ self._assert_variable(9, '', [], ['# EOT'])
def test_test_case_table(self):
self._create_table('test cases', [['#start of table comment'],
==============================================================================
Revision: 978a6ed18f88
Author: Pekka Klärck
Date: Wed Aug 29 04:32:24 2012
Log: writer/tidy: Write standalone comments in variable table starting
from first cell.
Update issue 1210
Status: Review
Cc: mikko.korpela
Now standalone comments are also written correctly. New functionality is
ready for testing with RIDE.
http://code.google.com/p/robotframework/source/detail?r=978a6ed18f88
Modified:
/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
/src/robot/parsing/model.py
/utest/writer/test_extractor.py
=======================================
--- /atest/testdata/tidy/golden.html Thu Jun 14 06:08:25 2012
+++ /atest/testdata/tidy/golden.html Wed Aug 29 04:32:24 2012
@@ -115,6 +115,13 @@
<th class="name" colspan="5">Variables</th>
</tr>
<tr>
+<td class="name"># standalone</td>
+<td>comment</td>
+<td></td>
+<td></td>
+<td></td>
+</tr>
+<tr>
<td class="name">MyVar</td>
<td>val1</td>
<td>val2</td>
@@ -124,18 +131,25 @@
<tr>
<td class="name">...</td>
<td>val5</td>
-<td>val6</td>
<td>val6</td>
<td>val7</td>
+<td>val8</td>
</tr>
<tr>
<td class="name">...</td>
-<td>val8</td>
<td>val9</td>
+<td>val10</td>
<td># var comment</td>
<td></td>
</tr>
<tr>
+<td class="name"># standalone</td>
+<td></td>
+<td></td>
+<td></td>
+<td></td>
+</tr>
+<tr>
<td class="name"></td>
<td></td>
<td></td>
=======================================
--- /atest/testdata/tidy/golden.tsv Thu Jun 14 06:08:25 2012
+++ /atest/testdata/tidy/golden.tsv Wed Aug 29 04:32:24 2012
@@ -5,8 +5,10 @@
Resource MyResource args that are part of the name
*Variables*
-MyVar val1 val2 val3 val4 val5 val6 val6
-... val7 val8 val9 # var comment
+# standalone comment
+MyVar val1 val2 val3 val4 val5 val6 val7
+... val8 val9 val10 # var comment
+# standalone
*Test Cases*
My Test Case [Documentation] This is a long comment that spans several
columns
=======================================
--- /atest/testdata/tidy/golden.txt Tue Jan 17 05:08:05 2012
+++ /atest/testdata/tidy/golden.txt Wed Aug 29 04:32:24 2012
@@ -5,8 +5,10 @@
Resource MyResource args that are part of the name
*** Variables ***
-MyVar val1 val2 val3 val4 val5 val6 val6
-... val7 val8 val9 # var comment
+# standalone comment
+MyVar val1 val2 val3 val4 val5 val6 val7
+... val8 val9 val10 # var comment
+# standalone
*** Test Cases ***
My Test Case
=======================================
--- /atest/testdata/tidy/golden_pipes.txt Tue Jan 17 05:08:05 2012
+++ /atest/testdata/tidy/golden_pipes.txt Wed Aug 29 04:32:24 2012
@@ -5,8 +5,10 @@
| Resource | MyResource args that are part of the name |
| *** Variables *** |
-| MyVar | val1 | val2 | val3 | val4 | val5 | val6 | val6 |
-| ... | val7 | val8 | val9 | # var comment |
+| # standalone | comment |
+| MyVar | val1 | val2 | val3 | val4 | val5 | val6 | val7 |
+| ... | val8 | val9 | val10 | # var comment |
+| # standalone |
| *** Test Cases *** |
| My Test Case |
=======================================
--- /atest/testdata/tidy/golden_two_spaces.txt Thu Jun 14 03:37:02 2012
+++ /atest/testdata/tidy/golden_two_spaces.txt Wed Aug 29 04:32:24 2012
@@ -5,8 +5,10 @@
Resource MyResource args that are part of the name
*** Variables ***
-MyVar val1 val2 val3 val4 val5 val6 val6
-... val7 val8 val9 # var comment
+# standalone comment
+MyVar val1 val2 val3 val4 val5 val6 val7
+... val8 val9 val10 # var comment
+# standalone
*** Test Cases ***
My Test Case
=======================================
--- /src/robot/parsing/model.py Wed Aug 29 02:05:15 2012
+++ /src/robot/parsing/model.py Wed Aug 29 04:32:24 2012
@@ -464,7 +464,9 @@
self.comment = Comment(comment)
def as_list(self):
- return [self.name] + self.value + self.comment.as_list()
+ if self:
+ return [self.name] + self.value + self.comment.as_list()
+ return self.comment.as_list()
def is_set(self):
return True
=======================================
--- /utest/writer/test_extractor.py Thu Jun 14 06:07:47 2012
+++ /utest/writer/test_extractor.py Wed Aug 29 04:32:24 2012
@@ -6,9 +6,11 @@
var_table = VariableTable(None)
var_table.add('${A scalar}', 'value', 'var comment')
+var_table.add('', '', 'standalone comment')
var_table.add('@{A list}', ['v', 'a', 'lue'])
var_table_rows = [['${A scalar}', 'value', '# var comment'],
+ ['# standalone comment'],
['@{A list}', 'v', 'a', 'lue']]
test_table = TestCaseTable(None)
@@ -47,3 +49,7 @@
extractor = DataExtractor(lambda t,n: True)
assert_equals(list(extractor._rows_from_indented_table(table)),
[['Test', 'No op']])
+
+
+if __name__ == '__main__':
+ unittest.main()