Exemplo n.º 1
0
 def test_implicit(self):
     env = make_env(platform='linux', clear_variables=True)
     with mock.patch('bfg9000.tools.pkg_config.which') as mwhich, \
          mock.patch('bfg9000.tools.pkg_config.check_which',
                     lambda names, env: ([first(names)], True)), \
          mock.patch('bfg9000.shell.which', return_value=['cc']), \
          mock.patch('bfg9000.shell.execute', mock_execute_cc):
         self.assertEqual(PkgConfig(env).command, ['pkg-config'])
         mwhich.assert_not_called()
Exemplo n.º 2
0
 def test_guess_sibling_nonexist(self):
     env = make_env(platform='linux',
                    clear_variables=True,
                    variables={'CC': 'i686-w64-mingw32-gcc-99'})
     with mock.patch('bfg9000.tools.pkg_config.which',
                     lambda names, env: [first(names)]), \
          mock.patch('bfg9000.tools.pkg_config.check_which') as mcwhich, \
          mock.patch('bfg9000.shell.which', side_effect=IOError()), \
          mock.patch('bfg9000.log.info'), \
          mock.patch('warnings.warn'):
         self.assertEqual(
             PkgConfig(env).command, ['i686-w64-mingw32-pkg-config'])
         mcwhich.assert_not_called()
Exemplo n.º 3
0
 def test_guess_sibling(self):
     env = make_env(platform='linux',
                    clear_variables=True,
                    variables={'CC': 'i686-w64-mingw32-gcc-99'})
     with mock.patch('bfg9000.tools.pkg_config.which',
                     lambda names, env: [first(names)]), \
          mock.patch('bfg9000.tools.pkg_config.check_which') as mcwhich, \
          mock.patch('bfg9000.shell.which',
                     return_value=['i686-w64-mingw32-gcc-99']), \
          mock.patch('bfg9000.shell.execute', mock_execute_cc), \
          mock.patch('bfg9000.log.info'):
         self.assertEqual(
             PkgConfig(env).command, ['i686-w64-mingw32-pkg-config'])
         mcwhich.assert_not_called()
Exemplo n.º 4
0
    def test_guess_sibling_error(self):
        def mock_check_which(*args, **kwargs):
            raise IOError('bad')

        env = make_env(platform='linux',
                       clear_variables=True,
                       variables={'CC': 'i686-w64-mingw32-gcc-99'})
        with mock.patch('bfg9000.tools.pkg_config.which',
                        mock_check_which), \
             mock.patch('bfg9000.tools.pkg_config.check_which',
                        return_value=(['pkgconf'], True)), \
             mock.patch('bfg9000.log.info'), \
             mock.patch('warnings.warn'):
            self.assertEqual(PkgConfig(env).command, ['pkgconf'])