Revision: a40163a865b2
Branch:   default
Author:   Anssi Syrjäsalo
Date:     Wed May 29 02:23:46 2013
Log:      Implemented --randomize in favor of --runmode RANDOM:x

Update issue 1445

Implemented --randomize.
http://code.google.com/p/robotframework/source/detail?r=a40163a865b2

Added:
 /atest/robot/cli/runner/random_order_deprecated.txt
Modified:
 /atest/robot/cli/runner/random_order.txt
 /src/robot/conf/settings.py
 /src/robot/run.py

=======================================
--- /dev/null
+++ /atest/robot/cli/runner/random_order_deprecated.txt Wed May 29 02:23:46 2013
@@ -0,0 +1,37 @@
+*** Settings ***
+Suite Setup     Check That Default Orders Are Correct
+Force Tags      pybot  jybot  regression
+Resource        atest_resource.txt
+
+*** Variables ***
+${DEFAULT SUITE ORDER} [Suite First, Sub.Suite.1, Suite3, Suite4, Suite5, Suite10, Suite 6, SUite7, suiTe 8, Suite 9 Name] +${DEFAULT TEST ORDER} [test1, test2, test3, test4, test5, test6, test7, test8, test9, test10, test11, test12]
+
+*** Test Cases ***
+Randomizing Tests
+ [Setup] Run Tests --runmode random:test misc/multiple_suites/01__suite_first.html
+    Should Not Be Equal As Strings  ${SUITE.tests}  ${DEFAULT TEST ORDER}
+
+Randomizing Suites
+    [Setup]  Run Tests  --runmode RANDOM:SuitE  misc/multiple_suites
+    Should Not Be Equal As Strings  ${SUITE.suites}  ${DEFAULT SUITE ORDER}
+    ${tests} =  Get Tests
+    Should Be Equal As Strings  ${tests}  ${DEFAULT TEST ORDER}
+
+Randomizing Suites And Tests
+    [Setup]  Run Tests  --runmode random:all  misc/multiple_suites
+    Should Not Be Equal As Strings  ${SUITE.suites}  ${DEFAULT SUITE ORDER}
+    ${tests} =  Get Tests
+    Should Not Be Equal As Strings  ${tests}  ${DEFAULT TEST ORDER}
+
+*** Keywords ***
+Check That Default Orders Are Correct
+    Run Tests  ${EMPTY}  misc/multiple_suites
+    Should Be Equal As Strings  ${SUITE.suites}  ${DEFAULT SUITE ORDER}
+ Should Be Equal As Strings ${SUITE.suites[0].tests} ${DEFAULT TEST ORDER}
+
+Get Tests
+ Comment This keyword is needed as there is also one directory suite, which does not contain tests. + ${tests} = Set Variable If '${SUITE.suites[0].name}' == 'Sub.Suite.1' ${SUITE.suites[0].suites[0].tests} ${SUITE.suites[0].tests}
+    [Return]  ${tests}
+
=======================================
--- /atest/robot/cli/runner/random_order.txt    Mon Oct 31 23:00:37 2011
+++ /atest/robot/cli/runner/random_order.txt    Wed May 29 02:23:46 2013
@@ -9,20 +9,21 @@

 *** Test Cases ***
 Randomizing Tests
- [Setup] Run Tests --runmode random:test misc/multiple_suites/01__suite_first.html + [Setup] Run Tests --randomize test misc/multiple_suites/01__suite_first.html
     Should Not Be Equal As Strings  ${SUITE.tests}  ${DEFAULT TEST ORDER}

 Randomizing Suites
-    [Setup]  Run Tests  --runmode RANDOM:SuitE  misc/multiple_suites
+    [Setup]  Run Tests  --randomize Suites  misc/multiple_suites
     Should Not Be Equal As Strings  ${SUITE.suites}  ${DEFAULT SUITE ORDER}
     ${tests} =  Get Tests
     Should Be Equal As Strings  ${tests}  ${DEFAULT TEST ORDER}

 Randomizing Suites And Tests
-    [Setup]  Run Tests  --runmode random:all  misc/multiple_suites
+    [Setup]  Run Tests  --randomize all  misc/multiple_suites
     Should Not Be Equal As Strings  ${SUITE.suites}  ${DEFAULT SUITE ORDER}
     ${tests} =  Get Tests
     Should Not Be Equal As Strings  ${tests}  ${DEFAULT TEST ORDER}
+

 *** Keywords ***
 Check That Default Orders Are Correct
=======================================
--- /src/robot/conf/settings.py Tue May 28 07:13:30 2013
+++ /src/robot/conf/settings.py Wed May 29 02:23:46 2013
@@ -108,6 +108,8 @@
             return [self._process_tag_stat_combine(v) for v in value]
         if name == 'TagStatLink':
return [v for v in [self._process_tag_stat_link(v) for v in value] if v]
+        if name == 'Randomize':
+            return self._process_randomize_target(value)
         if name in ['RemoveKeywords', 'RunMode']:
             return [v.upper() for v in value]
         return value
@@ -134,6 +136,14 @@
             raise DataError("Default visible log level '%s' is lower than "
                             "log level '%s'" % (default, log_level))

+    def _process_randomize_target(self, original_value):
+        formatted_value = original_value.lower()
+        if formatted_value in ('test', 'suite'):
+            formatted_value += 's'
+        if formatted_value not in ('tests', 'suites', 'none', 'all'):
+ raise DataError("Don't know how to randomize '%s'" % original_value)
+        return formatted_value
+
     def __getitem__(self, name):
         if name not in self._opts:
             raise KeyError("Non-existing setting '%s'" % name)
@@ -285,6 +295,7 @@
                        'DryRun'             : ('dryrun', False),
                        'ExitOnFailure'      : ('exitonfailure', False),
'SkipTearDownOnExit' : ('skipteardownonexit', False),
+                       'Randomize'          : ('randomize', 'None'),
                        'RunMode'            : ('runmode', []),
                        'RunEmptySuite'      : ('runemptysuite', False),
'WarnOnSkipped' : ('warnonskippedfiles', False),
@@ -337,19 +348,23 @@

     @property
     def randomize_suites(self):
- return any(mode in ('RANDOM:SUITE', 'RANDOM:ALL') for mode in self['RunMode'])
+        return (self['Randomize'] in ('suites', 'all') or
+ any(mode in ('RANDOM:SUITE', 'RANDOM:ALL') for mode in self['RunMode']))

     @property
     def randomize_tests(self):
- return any(mode in ('RANDOM:TEST', 'RANDOM:ALL') for mode in self['RunMode'])
+        return (self['Randomize'] in ('tests', 'all') or
+ any(mode in ('RANDOM:TEST', 'RANDOM:ALL') for mode in self['RunMode']))

     @property
     def dry_run(self):
- return self['DryRun'] or any(mode == 'DRYRUN' for mode in self['RunMode'])
+        return (self['DryRun'] or
+                any(mode == 'DRYRUN' for mode in self['RunMode']))

     @property
     def exit_on_failure(self):
- return self['ExitOnFailure'] or any(mode == 'EXITONFAILURE' for mode in self['RunMode'])
+        return (self['ExitOnFailure'] or
+                any(mode == 'EXITONFAILURE' for mode in self['RunMode']))


 class RebotSettings(_BaseSettings):
=======================================
--- /src/robot/run.py   Tue May 28 07:13:30 2013
+++ /src/robot/run.py   Wed May 29 02:23:46 2013
@@ -234,7 +234,10 @@
     --exitonfailure       Stops test execution if a critical test fails.
--skipteardownonexit Causes teardowns to be skipped if test execution is
                           stopped prematurely.
- --runmode mode * Possible values are `Random:Test`, `Random:Suite`,
+    --randomize none|tests|suites|all  Change the execution order of tests,
+ suites or both. None overrides the previous setting. + --runmode mode * (DEPRECATED in 2.8, please use the respective flags) + Possible values are `Random:Test`, `Random:Suite`, `Random:All`, `ExitOnFailure`, `SkipTeardownOnExit`, and `DryRun` (case-insensitive). First three change
                           the execution order of tests, suites, or both.

--

--- 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/groups/opt_out.


Reply via email to