]> mj.ucw.cz Git - moe.git/commitdiff
Adapted test-pipeline runner in dummy tasktype to use "with parse"
authorTomas Gavenciak <gavento@ucw.cz>
Wed, 22 Sep 2010 22:09:06 +0000 (00:09 +0200)
committerTomas Gavenciak <gavento@ucw.cz>
Wed, 22 Sep 2010 22:09:06 +0000 (00:09 +0200)
Creating the text to be parsed is not really safe - testname must not
include ', otherwise the parsing may fail

Hmm ...
Maybe another way?

t/moe/tasktypes/dummy.py

index 7f06418e2bde57b8aa50c3cc93ae813f7e3b498f..72293c35b1acd5143b3acb620232fb157537475a 100644 (file)
@@ -19,15 +19,17 @@ def init(e):
        e.log.info('Here we run test pipeline')
        tests = e['TESTS'].split()
        for t in tests:
-            e.log.info('Running test %s' % t)
-            e.log.user.info('TEST %s ...' % t)
-
-            op = moe.config.Operation('SET', None, moe.config.ConfigExpression([t]), level=70, source='<dummy tasktype>')
-            testvar = e.config.lookup('TEST')
-            # Add and remove operation setting 'TEST="..."'
-            testvar.add_operation(op)
-            e.test_pipe.run(e=e)
-            testvar.remove_operation(op)
+           e.log.info('Running test %s' % t)
+           e.log.user.info('TEST %s ...' % t)
+           with e.config.parse("TEST='"+t+"'", level=70, source='<dummy tasktype>'): 
+             e.test_pipe.run(e=e)
+           ## The old (but proper, as the above is vulnerable to injections by including "'" !) way was:
+           #op = moe.config.Operation('SET', None, moe.config.ConfigExpression([t]), level=70, source='<dummy tasktype>')
+           #testvar = e.config.lookup('TEST')
+           ## Add and remove operation setting 'TEST="..."'
+           #testvar.add_operation(op)
+           #e.test_pipe.run(e=e)
+           #testvar.remove_operation(op)
     
     e.main_pipe.insert(60, 'dummy tasktype hook_m_60', hook_m_60)