Esempio n. 1
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)
Esempio n. 2
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))
Esempio n. 3
0
    def __init__(self, user_io, current_folder, biicode_folder):
        self.user_io = user_io
        self.current_folder = current_folder
        self.biicode_folder = biicode_folder

        toolcatalog = ToolCatalog(BiiCommand,
                                  tools=[SetupCommands, GuiArduinoToolChain])
        self.executor = ToolExecutor(self, toolcatalog)
        self._user_cache = None
        self._biiapi = None
Esempio n. 4
0
File: bii.py Progetto: toeb/client
 def __init__(self, user_io, current_folder, user_biicode_folder):
     self.user_io = user_io
     self.bii_paths = BiiPaths(current_folder, user_biicode_folder)
     self.user_cache = UserCache(self.bii_paths.user_bii_home)
     toolcatalog = ToolCatalog(BiiCommand,
                               tools=[
                                   CPPToolChain, RPiToolChain,
                                   SetupCommands, ArduinoToolChain,
                                   NodeToolChain
                               ])
     self.executor = ToolExecutor(self, toolcatalog)
     self._biiapi = None