Exemplo n.º 1
0
    def test_help(self):
        mystdout = StringIO()
        out = BiiOutputStream(stream=mystdout)
        toolcatalog = ToolCatalog(BiiCommand, tools=[CPPToolChain])
        toolcatalog.show_advanced = True

        argv = ["all"]
        #Must print all
        mystdout.truncate(0)
        toolcatalog.print_help(out, argv)
        self.assertIn("cmake --build.", str(mystdout.buflist))

        #Must NOT print all
        mystdout.truncate(0)
        argv = None
        toolcatalog.print_help(out, argv)
        self.assertNotIn("cmake --build.", str(mystdout.buflist))

        #Must NOT print all
        mystdout.truncate(0)
        argv = []
        toolcatalog.print_help(out, argv)
        self.assertNotIn("cmake --build.", str(mystdout.buflist))

        #Must print cpp group
        mystdout.truncate(0)
        argv = ["cpp"]
        toolcatalog.print_help(out, argv)
        self.assertIn("cmake --build.", str(mystdout.buflist))
Exemplo n.º 2
0
    def test_tool_executor(self):
        bii = Bii(UserIO(out=BiiOutputStream()), "dummy_current_folder", "dummy_user_folder")
        toolcatalog = ToolCatalog(BiiCommand, tools=[CPPToolChain])
        toolcatalog.print_help = Mock(return_value=True)
        tool = ToolExecutor(bii, toolcatalog)
        #Effective call
        tool._call_method = Mock(return_value=True)

        # --quiet
        argv = ["cpp:configure", "--quiet"]
        tool.execute(argv)
        self.assertEqual(bii.user_io.out.level, 2)

        # --verbose
        argv = ["cpp:configure", "--verbose"]
        tool.execute(argv)
        self.assertEqual(bii.user_io.out.level, 0)

        # --version
        argv = ["--version"]
        tool.execute(argv)
        self.assertIn("%s\n" % biicode.common.__version__, str(bii.user_io.out))

        # --help
        argv = ["--help"]
        tool.execute(argv)
        toolcatalog.print_help.assert_called_with(bii.user_io.out, [])

        # Bad command
        argv = ["paspas"]
        self.assertRaises(ClientException, tool.execute, argv)