~verterok/ubuntuone-client/volumemanager_udfs-2

« back to all changes in this revision

Viewing changes to contrib/test

  • Committer: guillermo.gonzalez at canonical
  • Date: 2010-01-04 18:54:17 UTC
  • mfrom: (294.2.6 trunk)
  • Revision ID: guillermo.gonzalez@canonical.com-20100104185417-is0onxq4znx57u0j
merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
                        suite.addTests(module_suite)
67
67
        return suite
68
68
 
69
 
    def run(self, testpath, test_pattern=None):
 
69
    def run(self, testpath, test_pattern=None, loops=None):
70
70
        """run the tests. """
71
71
        # install the glib2reactor before any import of the reactor to avoid
72
72
        # using the default SelectReactor and be able to run the dbus tests
87
87
        # setup a custom XDG_CACHE_HOME and create the logs directory
88
88
        xdg_cache = os.path.join(os.getcwd(), "_trial_temp", "xdg_cache")
89
89
        os.environ["XDG_CACHE_HOME"] = xdg_cache
90
 
        # setup the ROOT_DIR env var
91
 
        os.environ['ROOT_DIR'] = os.getcwd()
 
90
        # setup the ROOTDIR env var
 
91
        os.environ['ROOTDIR'] = os.getcwd()
92
92
        if not os.path.exists(xdg_cache):
93
93
            os.makedirs(xdg_cache)
94
94
        success = 0
95
95
        try:
96
96
            suite = self._collect_tests(testpath, test_pattern)
 
97
            if loops:
 
98
                old_suite = suite
 
99
                suite = unittest.TestSuite()
 
100
                for x in xrange(loops):
 
101
                    suite.addTest(old_suite)
97
102
            result = runner.run(suite)
98
103
            success = result.wasSuccessful()
99
104
        finally:
110
115
    parser = OptionParser(usage=usage)
111
116
    parser.add_option("-t", "--test", dest="test",
112
117
                  help = "run specific tests, e.g: className.methodName")
 
118
    parser.add_option("-l", "--loop", dest="loops", type="int", default=1,
 
119
                      help = "loop selected tests LOOPS number of times", 
 
120
                      metavar="LOOPS")
113
121
 
114
122
    (options, args) = parser.parse_args()
115
123
    if args:
119
127
            sys.exit()
120
128
    else:
121
129
        testpath = None
122
 
    TestRunner().run(testpath, options.test) 
 
130
    TestRunner().run(testpath, options.test, options.loops)