Ejemplo n.º 1
0
 def test_opt_show_all(self, dependency1, depfile_name):
     output = StringIO()
     task = Task("tt", ["cat %(dependencies)s"],
                 file_dep=['tests/data/dependency1'])
     cmd = Strace(outstream=output)
     cmd._loader.load_tasks = mock.Mock(return_value=([task], {}))
     params = DefaultUpdate(dep_file=depfile_name, show_all=True,
                            keep_trace=False, backend='dbm')
     result = cmd.execute(params, ['tt'])
     assert 0 == result
     got = output.getvalue().split("\n")
     assert "cat" in got[0]
Ejemplo n.º 2
0
 def test_ignore_python_actions(self, dependency1, depfile_name):
     output = StringIO()
     def py_open():
         with open(dependency1) as ignore:
             ignore
     task = Task("tt", [py_open])
     cmd = Strace(outstream=output)
     cmd._loader.load_tasks = mock.Mock(return_value=([task], {}))
     params = DefaultUpdate(dep_file=depfile_name, show_all=False,
                            keep_trace=False, backend='dbm')
     result = cmd.execute(params, ['tt'])
     assert 0 == result
Ejemplo n.º 3
0
 def test_target(self, dependency1, depfile_name):
     output = StringIO()
     task = Task("tt", ["touch %(targets)s"],
                 targets=['tests/data/dependency1'])
     cmd = Strace(outstream=output)
     cmd._loader.load_tasks = mock.Mock(return_value=([task], {}))
     params = DefaultUpdate(dep_file=depfile_name, show_all=False,
                            keep_trace=False, backend='dbm')
     result = cmd.execute(params, ['tt'])
     assert 0 == result
     got = output.getvalue().split("\n")
     tgt_path = os.path.abspath("tests/data/dependency1")
     assert "W %s" % tgt_path in got[0]
Ejemplo n.º 4
0
 def test_opt_show_all(self, dependency1, depfile_name):
     output = StringIO()
     task = Task("tt", ["cat %(dependencies)s"],
                 file_dep=['tests/data/dependency1'])
     cmd = Strace(outstream=output)
     cmd._loader.load_tasks = mock.Mock(return_value=([task], {}))
     params = DefaultUpdate(dep_file=depfile_name,
                            show_all=True,
                            keep_trace=False,
                            backend='dbm')
     result = cmd.execute(params, ['tt'])
     assert 0 == result
     got = output.getvalue().split("\n")
     assert "cat" in got[0]
Ejemplo n.º 5
0
 def test_target(self, dependency1, depfile_name):
     output = StringIO()
     task = Task("tt", ["touch %(targets)s"],
                 targets=['tests/data/dependency1'])
     cmd = Strace(outstream=output)
     cmd._loader.load_tasks = mock.Mock(return_value=([task], {}))
     params = DefaultUpdate(dep_file=depfile_name,
                            show_all=False,
                            keep_trace=False,
                            backend='dbm')
     result = cmd.execute(params, ['tt'])
     assert 0 == result
     got = output.getvalue().split("\n")
     tgt_path = os.path.abspath("tests/data/dependency1")
     assert "W %s" % tgt_path in got[0]
Ejemplo n.º 6
0
    def test_ignore_python_actions(self, dependency1, depfile_name):
        output = StringIO()

        def py_open():
            with open(dependency1) as ignore:
                ignore

        task = Task("tt", [py_open])
        cmd = Strace(outstream=output)
        cmd._loader.load_tasks = mock.Mock(return_value=([task], {}))
        params = DefaultUpdate(dep_file=depfile_name,
                               show_all=False,
                               keep_trace=False,
                               backend='dbm')
        result = cmd.execute(params, ['tt'])
        assert 0 == result
Ejemplo n.º 7
0
 def test_invalid_command_args(self):
     output = StringIO()
     cmd = Strace(outstream=output)
     # fails if number of args != 1
     pytest.raises(InvalidCommand, cmd.execute, {}, [])
     pytest.raises(InvalidCommand, cmd.execute, {}, ['t1', 't2'])