Exemplo n.º 1
0
 def testDependencies(self, depfile):
     my_task = Task("t2", [""], file_dep=['d2.txt'])
     output = StringIO()
     cmd_list = List(outstream=output,
                     dep_file=depfile.name,
                     task_list=[my_task])
     cmd_list._execute(list_deps=True)
     got = output.getvalue()
     assert "d2.txt" in got
Exemplo n.º 2
0
 def testFilterAll(self, depfile):
     output = StringIO()
     cmd_list = List(outstream=output,
                     dep_file=depfile.name,
                     task_list=tasks_sample())
     cmd_list._execute(subtasks=True, pos_args=['g1'])
     got = [line.strip() for line in output.getvalue().split('\n') if line]
     expected = ['g1', 'g1.a', 'g1.b']
     assert expected == got
Exemplo n.º 3
0
 def testSubTask(self, depfile):
     output = StringIO()
     tasks = tasks_sample()
     cmd_list = List(outstream=output,
                     dep_file=depfile.name,
                     task_list=tasks)
     cmd_list._execute(subtasks=True)
     got = [line.strip() for line in output.getvalue().split('\n') if line]
     expected = [t.name for t in sorted(tasks)]
     assert expected == got
Exemplo n.º 4
0
 def testCustomTemplate(self, depfile):
     output = StringIO()
     tasks = tasks_sample()
     cmd_list = List(outstream=output,
                     dep_file=depfile.name,
                     task_list=tasks)
     cmd_list._execute(template='xxx {name} xxx {doc}')
     got = [line.strip() for line in output.getvalue().split('\n') if line]
     assert 'xxx g1 xxx g1 doc string' == got[0]
     assert 'xxx t3 xxx t3 doc string' == got[3]
Exemplo n.º 5
0
 def testQuiet(self, depfile):
     output = StringIO()
     tasks = tasks_sample()
     cmd_list = List(outstream=output,
                     dep_file=depfile.name,
                     task_list=tasks)
     cmd_list._execute()
     got = [line.strip() for line in output.getvalue().split('\n') if line]
     expected = [t.name for t in tasks if not t.is_subtask]
     assert sorted(expected) == got
Exemplo n.º 6
0
 def testWithPrivate(self, depfile):
     task_list = list(tasks_sample())
     task_list.append(Task("_s3", [""]))
     output = StringIO()
     cmd_list = List(outstream=output,
                     dep_file=depfile.name,
                     task_list=task_list)
     cmd_list._execute(private=True, pos_args=['_s3'])
     got = [line.strip() for line in output.getvalue().split('\n') if line]
     expected = ['_s3']
     assert expected == got
Exemplo n.º 7
0
 def testDoc(self, depfile):
     output = StringIO()
     tasks = tasks_sample()
     cmd_list = List(outstream=output,
                     dep_file=depfile.name,
                     task_list=tasks)
     cmd_list._execute(quiet=False)
     got = [line for line in output.getvalue().split('\n') if line]
     expected = []
     for t in sorted(tasks):
         if not t.is_subtask:
             expected.append([t.name, t.doc])
     assert len(expected) == len(got)
     for exp1, got1 in zip(expected, got):
         assert exp1 == got1.split(None, 1)
Exemplo n.º 8
0
    def testStatus(self, dependency1, depfile):
        task_list = tasks_sample()
        depfile.ignore(task_list[0])  # t1
        depfile.save_success(task_list[1])  # t2
        depfile.close()

        output = StringIO()
        cmd_list = List(outstream=output,
                        dep_file=depfile.name,
                        backend='dbm',
                        task_list=task_list)
        cmd_list._execute(status=True)
        got = [line.strip() for line in output.getvalue().split('\n') if line]
        assert 'R g1' in got
        assert 'I t1' in got
        assert 'U t2' in got
Exemplo n.º 9
0
 def testListInvalidTask(self, depfile):
     output = StringIO()
     cmd_list = List(outstream=output,
                     dep_file=depfile.name,
                     task_list=tasks_sample())
     pytest.raises(InvalidCommand, cmd_list._execute, pos_args=['xxx'])