3 new revisions:

Revision: 2c0d12e631c3
Branch:   default
Author:   Pekka Klärck
Date:     Mon Jun 16 23:13:16 2014 UTC
Log:      --flattenkeywords: Support for and foritem...
http://code.google.com/p/robotframework/source/detail?r=2c0d12e631c3

Revision: 932f4ec70d4a
Branch:   default
Author:   Pekka Klärck
Date:     Mon Jun 16 23:14:11 2014 UTC
Log:      --flattenkeywords: Documented for/foritem support...
http://code.google.com/p/robotframework/source/detail?r=932f4ec70d4a

Revision: 1e4587e89442
Branch:   default
Author:   Pekka Klärck
Date:     Mon Jun 16 23:14:29 2014 UTC
Log:      regen
http://code.google.com/p/robotframework/source/detail?r=1e4587e89442

==============================================================================
Revision: 2c0d12e631c3
Branch:   default
Author:   Pekka Klärck
Date:     Mon Jun 16 23:13:16 2014 UTC
Log:      --flattenkeywords: Support for and foritem

Update issue 1733
Status: Started
Owner: pekka.klarck
Implemented and tested.
http://code.google.com/p/robotframework/source/detail?r=2c0d12e631c3

Modified:
 /atest/robot/output/flatten_keyword.txt
 /atest/testdata/output/flatten_keywords.txt
 /src/robot/result/flattenkeywordmatcher.py
 /src/robot/result/resultbuilder.py

=======================================
--- /atest/robot/output/flatten_keyword.txt     Tue Nov  5 12:56:02 2013 UTC
+++ /atest/robot/output/flatten_keyword.txt     Mon Jun 16 23:13:16 2014 UTC
@@ -7,7 +7,7 @@
${FLATTEN} --FlattenKeywords NAME:Keyword3 --flat name:key*others --FLAT name:builtin.* --log log.html
 ${FLAT TEXT}    _*Keyword content flattened.*_
 ${FLAT HTML}    <p><i><b>Keyword content flattened.\\x3c/b>\\x3c/i>\\x3c/p>
-${ERROR} [ ERROR ] Invalid value for option '--flattenkeywords'. Expected pattern to start with 'NAME:' but got 'invalid'.${USAGE TIP}\n +${ERROR} [ ERROR ] Invalid value for option '--flattenkeywords'. Expected 'FOR', 'FORITEM', or 'NAME:<pattern>' but got 'invalid'.${USAGE TIP}\n

 *** Test Cases ***
 Non-matching keyword is not flattened
@@ -50,9 +50,43 @@
     Should Contain    ${LOG}    *<p>Doc of keyword 3\\x3c/p>\\n${FLAT HTML}
     Should Contain    ${LOG}    *${FLAT HTML}
Should Contain ${LOG} *<p>Logs the given message with the given level.\\x3c/p>\\n${FLAT HTML}
+
+Flatten for loops
+    Run Rebot    --flatten For    ${ORIG OUTFILE}
+    ${tc} =    Check Test Case    For loop
+    Should Be Equal    ${tc.kws[0].type}    for
+    Should Be Equal    ${tc.kws[0].doc}    ${FLAT TEXT}
+    Length Should Be    ${tc.kws[0].kws}    0
+    Length Should Be    ${tc.kws[0].msgs}    60
+    :FOR    ${index}    IN RANGE    10
+ \ Check Log Message ${tc.kws[0].msgs[${index * 6 + 0}]} index: ${index}
+    \    Check Log Message    ${tc.kws[0].msgs[${index * 6 + 1}]}    3
+    \    Check Log Message    ${tc.kws[0].msgs[${index * 6 + 2}]}    2
+    \    Check Log Message    ${tc.kws[0].msgs[${index * 6 + 3}]}    1
+    \    Check Log Message    ${tc.kws[0].msgs[${index * 6 + 4}]}    2
+    \    Check Log Message    ${tc.kws[0].msgs[${index * 6 + 5}]}    1
+
+Flatten for loop items
+    Run Rebot    --flatten ForItem    ${ORIG OUTFILE}
+    ${tc} =    Check Test Case    For loop
+    Should Be Equal    ${tc.kws[0].type}    for
+    Should Be Empty    ${tc.kws[0].doc}
+    Length Should Be    ${tc.kws[0].kws}    10
+    Should Be Empty    ${tc.kws[0].msgs}
+    :FOR    ${index}    IN RANGE    10
+    \    Should Be Equal      ${tc.kws[0].kws[${index}].type}    foritem
+ \ Should Be Equal ${tc.kws[0].kws[${index}].doc} ${FLAT TEXT}
+    \    Should Be Empty      ${tc.kws[0].kws[${index}].kws}
+    \    Length Should Be     ${tc.kws[0].kws[${index}].msgs}    6
+ \ Check Log Message ${tc.kws[0].kws[${index}].msgs[0]} index: ${index}
+    \    Check Log Message    ${tc.kws[0].kws[${index}].msgs[1]}    3
+    \    Check Log Message    ${tc.kws[0].kws[${index}].msgs[2]}    2
+    \    Check Log Message    ${tc.kws[0].kws[${index}].msgs[3]}    1
+    \    Check Log Message    ${tc.kws[0].kws[${index}].msgs[4]}    2
+    \    Check Log Message    ${tc.kws[0].kws[${index}].msgs[5]}    1

 Invalid usage
- Run Rebot Without Processing Output ${FLATTEN} --FlattenKeywords invalid ${OUTFILE} + Run Rebot Without Processing Output ${FLATTEN} --FlattenKeywords invalid ${ORIG OUTFILE}
     Stderr Should Be Equal To    ${ERROR}
Run Tests Without Processing Output ${FLATTEN} --FlattenKeywords invalid output/flatten_keywords.txt
     Stderr Should Be Equal To    ${ERROR}
@@ -62,6 +96,7 @@
Run Tests Without Processing Output ${FLATTEN} output/flatten_keywords.txt
     ${LOG} =    Get File    ${OUTDIR}/log.html
     Set Suite Variable    $LOG
+    Set Suite Variable    $ORIG OUTFILE    ${OUTFILE}
     Run Rebot    ${FLATTEN}    ${OUTFILE}
     ${TC} =    Check Test Case    Flatten stuff
     Set Suite Variable    $TC
=======================================
--- /atest/testdata/output/flatten_keywords.txt Tue Nov  5 12:36:31 2013 UTC
+++ /atest/testdata/output/flatten_keywords.txt Mon Jun 16 23:13:16 2014 UTC
@@ -5,6 +5,12 @@
     Keyword calling others
     Log    Flatten me too!!

+For loop
+    :FOR    ${i}    IN RANGE    10
+    \    Log   index: ${i}
+    \    Keyword 3
+    \    Keyword 2
+
 *** Keywords ***
 Keyword 3
     [Documentation]    Doc of keyword 3
=======================================
--- /src/robot/result/flattenkeywordmatcher.py  Thu Jan 23 14:00:53 2014 UTC
+++ /src/robot/result/flattenkeywordmatcher.py  Mon Jun 16 23:13:16 2014 UTC
@@ -19,13 +19,22 @@
 class FlattenKeywordMatcher(object):

     def __init__(self, flattened):
-        self.match = MultiMatcher(self._yield_patterns(flattened)).match
+        self._types = []
+        names = self._yield_names_and_set_types(flattened, self._types)
+        self._name_matcher = MultiMatcher(names)

-    def _yield_patterns(self, flattened):
+    def _yield_names_and_set_types(self, flattened, types):
         if isinstance(flattened, basestring):
             flattened = [flattened]
         for flat in flattened:
-            if not flat.upper().startswith('NAME:'):
-                raise DataError("Expected pattern to start with 'NAME:' "
-                                "but got '%s'." % flat)
-            yield flat[5:]
+            upper = flat.upper()
+            if upper in ('FOR', 'FORITEM'):
+                types.append(flat.lower())
+            elif upper.startswith('NAME:'):
+                yield flat[5:]
+            else:
+                raise DataError("Expected 'FOR', 'FORITEM', or "
+                                "'NAME:<pattern>' but got '%s'." % flat)
+
+    def match(self, name, type):
+        return self._name_matcher.match(name) or type in self._types
=======================================
--- /src/robot/result/resultbuilder.py  Thu Jan 30 08:20:41 2014 UTC
+++ /src/robot/result/resultbuilder.py  Mon Jun 16 23:13:16 2014 UTC
@@ -126,7 +126,7 @@
             if event == 'start' and tag == 'kw':
                 if started >= 0:
                     started += 1
-                elif match(elem.attrib['name']):
+                elif match(elem.get('name'), elem.get('type')):
                     started = 0
             if started == 0 and event == 'end' and tag == 'doc':
                 elem.text = ('%s\n\n_*Keyword content flattened.*_'

==============================================================================
Revision: 932f4ec70d4a
Branch:   default
Author:   Pekka Klärck
Date:     Mon Jun 16 23:14:11 2014 UTC
Log:      --flattenkeywords: Documented for/foritem support

Update issue 1733
Status: Done
Documented in --help and UG.
http://code.google.com/p/robotframework/source/detail?r=932f4ec70d4a

Modified:
 /doc/userguide/src/ExecutingTestCases/OutputFiles.rst
 /src/robot/rebot.py
 /src/robot/run.py

=======================================
--- /doc/userguide/src/ExecutingTestCases/OutputFiles.rst Sat Jan 25 22:23:45 2014 UTC +++ /doc/userguide/src/ExecutingTestCases/OutputFiles.rst Mon Jun 16 23:14:11 2014 UTC
@@ -474,6 +474,13 @@
    created using this option contain enough information to investigate
    possible failures.

+:opt:`FOR`
+   Remove all passed iterations from `for loops`_ except the last one.
+
+:opt:`WUKS`
+   Remove all failing keywords inside BuiltIn_ keyword
+   :name:`Wait Until Keyword Succeeds` except the last one.
+
 :opt:`NAME:<pattern>`
    Remove data from all keywords matching the given pattern regardless the
    keyword status. The pattern is
@@ -482,13 +489,6 @@
underscore insensitive, and it supports `simple patterns`_ with :code:`*`
    and :code:`?` as wildcards.

-:opt:`FOR`
-   Remove all passed iterations from `for loops`_ except the last one .
-
-:opt:`WUKS`
-   Remove all failing keywords inside BuiltIn_ keyword
-   :name:`Wait Until Keyword Succeeds` except the last one.
-
 Examples::

    rebot --removekeywords all output.xml
@@ -509,9 +509,15 @@
 '''''''''''''''''''

 The :opt:`--flattenkeywords` option flattens matching keywords. In practice
-this means that matching keywords get all messages from their child keywords, -recursively, and child keywords are discarded otherwise. It currently has only
-one mode, but more may be added in the future.
+this means that matching keywords get all log messages from their child
+keywords, recursively, and child keywords are discarded otherwise. Flattening
+supports the following modes:
+
+:opt:`FOR`
+   Flatten `for loops`_ fully.
+
+:opt:`FORITEM`
+   Flatten individual for loop iterations.

 :opt:`NAME:<pattern>`
    Flatten keywords matching the given pattern. Pattern matching rules are
@@ -520,12 +526,15 @@
 Examples::

pybot --flattenkeywords name:HugeKeyword --flattenkeywords name:resource.* tests.txt
+   rebot --flattenkeywords foritem tests.txt

 Flattening keywords is done already when the `output file`_ is parsed. This
 can save a significant amount of memory especially with deeply nested
 keyword structures.

-.. note:: Flattening keywords is a new feature in Robot Framework 2.8.2.
+.. note:: Flattening keywords is a new feature in Robot Framework 2.8.2, and
+          :opt:`FOR` and :opt:`FORITEM` modes were added in Robot Framework
+          2.8.5.

 Setting start and end time of execution
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=======================================
--- /src/robot/rebot.py Thu Jan 30 09:46:39 2014 UTC
+++ /src/robot/rebot.py Mon Jun 16 23:14:11 2014 UTC
@@ -184,12 +184,15 @@
                           automatically converted to spaces.
Examples: --tagstatlink mytag:http://my.domain:Link --tagstatlink bug-*:http://tracker/id=%1:Bug_Tracker - --removekeywords all|passed|name:<pattern>|for|wuks|none * Remove keyword - data from all generated outputs. Keywords containing + --removekeywords all|passed|for|wuks|name:<pattern> * Remove keyword data
+                          from all generated outputs. Keywords containing
                           warnings are not removed except in `all` mode.
                           all:     remove data from all keywords
                           passed:  remove data only from keywords in passed
                                    test cases and suites
+                          for:     remove passed iterations from for loops
+                          wuks:    remove all but the last failing keyword
+ inside `BuiltIn.Wait Until Keyword Succeeds` name:<pattern>: remove data from keywords that match the given pattern. The pattern is matched against the full name of the keyword (e.g.
@@ -198,13 +201,15 @@
and may contain `*` and `?` as wildcards. Examples: --removekeywords name:Lib.HugeKw --removekeywords name:myresource.*
-                          for:     remove passed iterations from for loops
-                          wuks:    remove all but the last failing keyword
- inside `BuiltIn.Wait Until Keyword Succeeds` - --flattenkeywords name:<pattern> * Flattens matching keywords. Matching - keywords get all messages from their child keywords - and children are discarded otherwise. Matching rules - are same as with `--removekeywords name:<pattern>`. + --flattenkeywords for|foritem|name:<pattern> * Flattens matching keywords + in all generated outputs. Matching keywords get all + log messages from their child keywords and children
+                          are discarded otherwise.
+                          for:     flatten for loops fully
+                          foritem: flatten individual for loop iterations
+ name:<pattern>: flatten matched keywords using same
+                                   matching rules as with
+                                   `--removekeywords name:<pattern>`
--starttime timestamp Set starting time of test execution when creating
                           reports. Timestamp must be given in format
`2007-10-01 15:12:42.268` where all separators are
=======================================
--- /src/robot/run.py   Wed Apr 23 16:11:13 2014 UTC
+++ /src/robot/run.py   Mon Jun 16 23:14:11 2014 UTC
@@ -219,12 +219,15 @@
                           automatically converted to spaces.
Examples: --tagstatlink mytag:http://my.domain:Link --tagstatlink bug-*:http://tracker/id=%1:Bug_Tracker - --removekeywords all|passed|name:<pattern>|for|wuks|none * Remove keyword - data from the generated log file. Keywords containing + --removekeywords all|passed|for|wuks|name:<pattern> * Remove keyword data
+                          from the generated log file. Keywords containing
                           warnings are not removed except in `all` mode.
                           all:     remove data from all keywords
                           passed:  remove data only from keywords in passed
                                    test cases and suites
+                          for:     remove passed iterations from for loops
+                          wuks:    remove all but the last failing keyword
+ inside `BuiltIn.Wait Until Keyword Succeeds` name:<pattern>: remove data from keywords that match the given pattern. The pattern is matched against the full name of the keyword (e.g.
@@ -233,14 +236,15 @@
and may contain `*` and `?` as wildcards. Examples: --removekeywords name:Lib.HugeKw --removekeywords name:myresource.*
-                          for:     remove passed iterations from for loops
-                          wuks:    remove all but the last failing keyword
- inside `BuiltIn.Wait Until Keyword Succeeds`
-    --flattenkeywords name:<pattern> *  Flattens matching keywords in the
-                          generated log file. Matching keywords get all
- messages from their child keywords and children are - discarded otherwise. Matching rules are same as with
-                          `--removekeywords name:<pattern>`.
+ --flattenkeywords for|foritem|name:<pattern> * Flattens matching keywords + in the generated log file. Matching keywords get all + log messages from their child keywords and children
+                          are discarded otherwise.
+                          for:     flatten for loops fully
+                          foritem: flatten individual for loop iterations
+ name:<pattern>: flatten matched keywords using same
+                                   matching rules as with
+                                   `--removekeywords name:<pattern>`
     --listener class *    A class for monitoring test execution. Gets
notifications e.g. when a test case starts and ends. Arguments to listener class can be given after class

==============================================================================
Revision: 1e4587e89442
Branch:   default
Author:   Pekka Klärck
Date:     Mon Jun 16 23:14:29 2014 UTC
Log:      regen
http://code.google.com/p/robotframework/source/detail?r=1e4587e89442

Modified:
 /doc/userguide/RobotFrameworkUserGuide.html

=======================================
--- /doc/userguide/RobotFrameworkUserGuide.html Sat Jun 14 22:13:18 2014 UTC
+++ /doc/userguide/RobotFrameworkUserGuide.html Mon Jun 16 23:14:29 2014 UTC
@@ -12169,6 +12169,11 @@
 <dd>Remove keyword data from passed test cases. In most cases, log files
 created using this option contain enough information to investigate
 possible failures.</dd>
+<dt><span class="opt">FOR</span></dt>
+<dd>Remove all passed iterations from <a class="reference internal" href="#for-loops">for loops</a> except the last one.</dd>
+<dt><span class="opt">WUKS</span></dt>
+<dd>Remove all failing keywords inside <a class="reference external" href="../libraries/BuiltIn.html">BuiltIn</a> keyword +<span class="name">Wait Until Keyword Succeeds</span> except the last one.</dd>
 <dt><span class="opt">NAME:&lt;pattern&gt;</span></dt>
 <dd>Remove data from all keywords matching the given pattern regardless the
 keyword status. The pattern is
@@ -12176,11 +12181,6 @@
 the possible library or resource file name. The pattern is case, space, and
underscore insensitive, and it supports <a class="reference internal" href="#simple-patterns">simple patterns</a> with <span class="code">*</span>
 and <span class="code">?</span> as wildcards.</dd>
-<dt><span class="opt">FOR</span></dt>
-<dd>Remove all passed iterations from <a class="reference internal" href="#for-loops">for loops</a> except the last one .</dd>
-<dt><span class="opt">WUKS</span></dt>
-<dd>Remove all failing keywords inside <a class="reference external" href="../libraries/BuiltIn.html">BuiltIn</a> keyword -<span class="name">Wait Until Keyword Succeeds</span> except the last one.</dd>
 </dl>
 <p>Examples:</p>
 <pre class="literal-block">
@@ -12205,10 +12205,14 @@
 <div class="section" id="flattening-keywords">
 <h4><a class="toc-backref" href="#id662">Flattening keywords</a></h4>
<p>The <span class="opt">--flattenkeywords</span> option flattens matching keywords. In practice -this means that matching keywords get all messages from their child keywords, -recursively, and child keywords are discarded otherwise. It currently has only
-one mode, but more may be added in the future.</p>
+this means that matching keywords get all log messages from their child
+keywords, recursively, and child keywords are discarded otherwise. Flattening
+supports the following modes:</p>
 <dl class="docutils">
+<dt><span class="opt">FOR</span></dt>
+<dd>Flatten <a class="reference internal" href="#for-loops">for loops</a> fully.</dd>
+<dt><span class="opt">FORITEM</span></dt>
+<dd>Flatten individual for loop iterations.</dd>
 <dt><span class="opt">NAME:&lt;pattern&gt;</span></dt>
 <dd>Flatten keywords matching the given pattern. Pattern matching rules are
same as when <a class="reference internal" href="#removing-keywords">removing keywords</a> using <span class="opt">NAME:&lt;pattern&gt;</span> mode.</dd>
@@ -12216,13 +12220,16 @@
 <p>Examples:</p>
 <pre class="literal-block">
pybot --flattenkeywords name:HugeKeyword --flattenkeywords name:resource.* tests.txt
+rebot --flattenkeywords foritem tests.txt
 </pre>
<p>Flattening keywords is done already when the <a class="reference internal" href="#output-file">output file</a> is parsed. This
 can save a significant amount of memory especially with deeply nested
 keyword structures.</p>
 <div class="note">
 <p class="first admonition-title">Note</p>
-<p class="last">Flattening keywords is a new feature in Robot Framework 2.8.2.</p> +<p class="last">Flattening keywords is a new feature in Robot Framework 2.8.2, and +<span class="opt">FOR</span> and <span class="opt">FORITEM</span> modes were added in Robot Framework
+2.8.5.</p>
 </div>
 </div>
 </div>
@@ -17975,7 +17982,7 @@
 <div class="footer">
 <hr class="footer" />
<p>Generated by <a class="reference external" href="http://docutils.sourceforge.net/rst.html";>reStructuredText</a>. Syntax highlighting by <a class="reference external" href="http://pygments.org/";>Pygments</a>.</p>
-<p>Generated on: 2014-06-14 22:09 UTC.
+<p>Generated on: 2014-06-16 23:14 UTC.
 </p>

 </div>

--

--- 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/d/optout.

Reply via email to