Exemplo n.º 1
0
 def testProcessRunFilter(self, depfile_name):
     output = StringIO()
     cmd_run = Run(backend='dbm', dep_file=depfile_name,
                   task_list=tasks_sample(), sel_tasks=["g1.a"])
     cmd_run._execute(output)
     got = output.getvalue().split("\n")[:-1]
     assert [".  g1.a"] == got
Exemplo n.º 2
0
 def testProcessRunEmptyFilter(self, depfile):
     output = StringIO.StringIO()
     cmd_run = Run(dep_file=depfile.name, task_list=tasks_sample(),
                   sel_tasks=[])
     cmd_run._execute(output)
     got = output.getvalue().split("\n")[:-1]
     assert [] == got
Exemplo n.º 3
0
 def testMP_not_available(self, depfile, monkeypatch):
     # make sure MRunner wont be used
     monkeypatch.setattr(runner.MRunner, "available",
                         Mock(return_value=False))
     monkeypatch.setattr(runner.MRunner, "__init__", 'not available')
     output = StringIO.StringIO()
     cmd_run = Run(dep_file=depfile.name, task_list=tasks_sample())
     cmd_run._execute(output, num_process=3)
Exemplo n.º 4
0
 def testProcessRunSingle(self, depfile_name):
     output = StringIO()
     cmd_run = Run(backend='dbm', dep_file=depfile_name,
                   task_list=tasks_sample(), sel_tasks=["t3"])
     cmd_run._execute(output, single=True)
     got = output.getvalue().split("\n")[:-1]
     # t1 is a depenendency of t3 but not included
     assert [".  t3"] == got
Exemplo n.º 5
0
 def testProcessRunEmptyFilter(self, depfile):
     output = StringIO.StringIO()
     cmd_run = Run(dep_file=depfile.name,
                   task_list=tasks_sample(),
                   sel_tasks=[])
     cmd_run._execute(output)
     got = output.getvalue().split("\n")[:-1]
     assert [] == got
Exemplo n.º 6
0
 def testMP_not_available(self, depfile, monkeypatch):
     # make sure MRunner wont be used
     monkeypatch.setattr(runner.MRunner, "available",
                         Mock(return_value=False))
     monkeypatch.setattr(runner.MRunner, "__init__", 'not available')
     output = StringIO.StringIO()
     cmd_run = Run(dep_file=depfile.name, task_list=tasks_sample())
     cmd_run._execute(output, num_process=3)
Exemplo n.º 7
0
 def testCustomReporter(self, depfile):
     output = StringIO.StringIO()
     class MyReporter(reporter.ConsoleReporter):
         def get_status(self, task):
             self.outstream.write('MyReporter.start %s\n' % task.name)
     cmd_run = Run(dep_file=depfile.name, task_list=[tasks_sample()[0]])
     cmd_run._execute(output, reporter=MyReporter)
     got = output.getvalue().split("\n")[:-1]
     assert 'MyReporter.start t1' == got[0]
Exemplo n.º 8
0
 def testProcessRunFilter(self, depfile_name):
     output = StringIO()
     cmd_run = Run(backend='dbm',
                   dep_file=depfile_name,
                   task_list=tasks_sample(),
                   sel_tasks=["g1.a"])
     cmd_run._execute(output)
     got = output.getvalue().split("\n")[:-1]
     assert [".  g1.a"] == got
Exemplo n.º 9
0
 def testSetVerbosity(self, depfile):
     output = StringIO.StringIO()
     t = Task('x', None)
     used_verbosity = []
     def my_execute(out, err, verbosity):
         used_verbosity.append(verbosity)
     t.execute = my_execute
     cmd_run = Run(dep_file=depfile.name, task_list=[t])
     cmd_run._execute(output, verbosity=2)
     assert 2 == used_verbosity[0], used_verbosity
Exemplo n.º 10
0
 def testProcessRunSingle(self, depfile_name):
     output = StringIO()
     cmd_run = Run(backend='dbm',
                   dep_file=depfile_name,
                   task_list=tasks_sample(),
                   sel_tasks=["t3"])
     cmd_run._execute(output, single=True)
     got = output.getvalue().split("\n")[:-1]
     # t1 is a depenendency of t3 but not included
     assert [".  t3"] == got
Exemplo n.º 11
0
 def testProcessRunSingleSubtasks(self, depfile_name):
     output = StringIO()
     task_list = tasks_sample()
     assert task_list[4].name == 'g1.b'
     task_list[4].task_dep = ['t3']
     cmd_run = Run(backend='dbm', dep_file=depfile_name,
                   task_list=task_list, sel_tasks=["g1"])
     cmd_run._execute(output, single=True)
     got = output.getvalue().split("\n")[:-1]
     # t3 is a depenendency of g1.b but not included
     assert [".  g1.a", ".  g1.b"] == got
Exemplo n.º 12
0
    def testCustomReporter(self, depfile):
        output = StringIO.StringIO()

        class MyReporter(reporter.ConsoleReporter):
            def get_status(self, task):
                self.outstream.write('MyReporter.start %s\n' % task.name)

        cmd_run = Run(dep_file=depfile.name, task_list=[tasks_sample()[0]])
        cmd_run._execute(output, reporter=MyReporter)
        got = output.getvalue().split("\n")[:-1]
        assert 'MyReporter.start t1' == got[0]
Exemplo n.º 13
0
    def testSetVerbosity(self, depfile_name):
        output = StringIO()
        t = Task('x', None)
        used_verbosity = []

        def my_execute(out, err, verbosity):
            used_verbosity.append(verbosity)

        t.execute = my_execute
        cmd_run = Run(backend='dbm', dep_file=depfile_name, task_list=[t])
        cmd_run._execute(output, verbosity=2)
        assert 2 == used_verbosity[0], used_verbosity
Exemplo n.º 14
0
 def test_outfile(self, depfile):
     cmd_run = Run(dep_file=depfile.name, task_list=tasks_sample(),
                   sel_tasks=["g1.a"])
     cmd_run._execute('test.out')
     try:
         outfile = open('test.out', 'r')
         got = outfile.read()
         outfile.close()
         assert ".  g1.a\n" == got, repr(got)
     finally:
         if os.path.exists('test.out'):
             os.remove('test.out')
Exemplo n.º 15
0
 def test_outfile(self, depfile):
     cmd_run = Run(dep_file=depfile.name,
                   task_list=tasks_sample(),
                   sel_tasks=["g1.a"])
     cmd_run._execute('test.out')
     try:
         outfile = open('test.out', 'r')
         got = outfile.read()
         outfile.close()
         assert ".  g1.a\n" == got, repr(got)
     finally:
         if os.path.exists('test.out'):
             os.remove('test.out')
Exemplo n.º 16
0
 def testProcessRunSingleSubtasks(self, depfile_name):
     output = StringIO()
     task_list = tasks_sample()
     assert task_list[4].name == 'g1.b'
     task_list[4].task_dep = ['t3']
     cmd_run = Run(backend='dbm',
                   dep_file=depfile_name,
                   task_list=task_list,
                   sel_tasks=["g1"])
     cmd_run._execute(output, single=True)
     got = output.getvalue().split("\n")[:-1]
     # t3 is a depenendency of g1.b but not included
     assert [".  g1.a", ".  g1.b"] == got
Exemplo n.º 17
0
 def testProcessRunMP(self, dependency1, depfile):
     output = StringIO.StringIO()
     cmd_run = Run(dep_file=depfile.name, task_list=tasks_sample())
     result = cmd_run._execute(output, num_process=1)
     assert 0 == result
     got = output.getvalue().split("\n")[:-1]
     assert [".  t1", ".  t2", ".  g1.a", ".  g1.b", ".  t3"] == got
Exemplo n.º 18
0
 def testProcessRunMP(self, dependency1, depfile):
     output = StringIO.StringIO()
     cmd_run = Run(dep_file=depfile.name, task_list=tasks_sample())
     result = cmd_run._execute(output, num_process=1)
     assert 0 == result
     got = output.getvalue().split("\n")[:-1]
     assert [".  t1", ".  t2", ".  g1.a", ".  g1.b", ".  t3"] == got
Exemplo n.º 19
0
 def testProcessRunMThread(self, dependency1, depfile_name):
     output = StringIO()
     cmd_run = Run(backend='dbm', dep_file=depfile_name,
                   task_list=tasks_sample())
     result = cmd_run._execute(output, num_process=1, par_type='thread')
     assert 0 == result
     got = output.getvalue().split("\n")[:-1]
     assert [".  t1", ".  t2", ".  g1.a", ".  g1.b", ".  t3"] == got
Exemplo n.º 20
0
 def testProcessRunMThread(self, dependency1, depfile_name):
     output = StringIO()
     cmd_run = Run(backend='dbm',
                   dep_file=depfile_name,
                   task_list=tasks_sample())
     result = cmd_run._execute(output, num_process=1, par_type='thread')
     assert 0 == result
     got = output.getvalue().split("\n")[:-1]
     assert [".  t1", ".  t2", ".  g1.a", ".  g1.b", ".  t3"] == got
Exemplo n.º 21
0
 def testMP_not_available(self, dependency1, depfile_name,
                          capsys, monkeypatch):
     # make sure MRunner wont be used
     monkeypatch.setattr(runner.MRunner, "available",
                         Mock(return_value=False))
     output = StringIO()
     cmd_run = Run(backend='dbm', dep_file=depfile_name,
                   task_list=tasks_sample())
     result = cmd_run._execute(output, num_process=1)
     assert 0 == result
     got = output.getvalue().split("\n")[:-1]
     assert [".  t1", ".  t2", ".  g1.a", ".  g1.b", ".  t3"] == got
     err = capsys.readouterr()[1]
     assert "WARNING:" in err
     assert "parallel using threads" in err
Exemplo n.º 22
0
 def testMP_not_available(self, dependency1, depfile_name, capsys,
                          monkeypatch):
     # make sure MRunner wont be used
     monkeypatch.setattr(runner.MRunner, "available",
                         Mock(return_value=False))
     output = StringIO()
     cmd_run = Run(backend='dbm',
                   dep_file=depfile_name,
                   task_list=tasks_sample())
     result = cmd_run._execute(output, num_process=1)
     assert 0 == result
     got = output.getvalue().split("\n")[:-1]
     assert [".  t1", ".  t2", ".  g1.a", ".  g1.b", ".  t3"] == got
     err = capsys.readouterr()[1]
     assert "WARNING:" in err
     assert "parallel using threads" in err