Example #1
0
    def test_basic(self):
        pkg = self.make_package('foo', remote='foo/1.2.3@conan/stable')
        self.assertEqual(pkg.remote, 'foo/1.2.3@conan/stable')
        self.assertEqual(pkg.build, False)
        self.assertEqual(pkg.options, {})
        self.assertEqual(pkg.needs_dependencies, False)
        self.assertEqual(pkg.should_deploy, True)

        with mock_open_log(mock_open_write()) as mopen, \
             mock.patch('subprocess.run') as mcall:  # noqa
            ConanPackage.resolve_all(self.pkgdir, [pkg])

            self.assertEqual(
                mopen.mock_file.getvalue(),
                dedent("""\
                [requires]
                foo/1.2.3@conan/stable

                [options]

                [generators]
                pkg_config
            """))
            mcall.assert_called_with([
                'conan', 'install', '-if',
                os.path.join(self.pkgdir, 'conan'), '--', self.pkgdir
            ],
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.STDOUT,
                                     universal_newlines=True,
                                     check=True)

        self.check_usage(pkg)
Example #2
0
    def test_this_options_build_all(self):
        pkg = self.make_package('foo',
                                remote='foo/1.2.3@conan/stable',
                                this_options={'build': 'all'})
        self.assertEqual(pkg.remote, 'foo/1.2.3@conan/stable')
        self.assertEqual(pkg.build, False)
        self.assertEqual(pkg.options, {})
        self.assertEqual(pkg.should_deploy, True)

        with mock_open_log(mock_open_write()) as mopen, \
             mock.patch('subprocess.run') as mcall:  # noqa
            ConanPackage.resolve_all(self.pkgdir, [pkg])
            mcall.assert_called_with([
                'conan', 'install', '-if',
                os.path.join(self.pkgdir, 'conan'), '--build', '--',
                self.pkgdir
            ],
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.STDOUT,
                                     universal_newlines=True,
                                     check=True)

        self.check_usage(pkg)
Example #3
0
    def test_multiple(self):
        pkgs = [
            self.make_package('foo', remote='foo/1.2.3@conan/stable'),
            self.make_package('bar',
                              remote='bar/2.3.4@conan/stable',
                              options={'shared': True}),
        ]

        with mock_open_log(mock_open_write()) as mopen, \
             mock.patch('subprocess.run') as mcall:  # noqa
            ConanPackage.resolve_all(self.pkgdir, pkgs)

            self.assertEqual(
                mopen.mock_file.getvalue(),
                dedent("""\
                [requires]
                foo/1.2.3@conan/stable
                bar/2.3.4@conan/stable

                [options]
                bar:shared=True

                [generators]
                pkg_config
            """))
            mcall.assert_called_with([
                'conan', 'install', '-if',
                os.path.join(self.pkgdir, 'conan'), '--', self.pkgdir
            ],
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.STDOUT,
                                     universal_newlines=True,
                                     check=True)

        for pkg in pkgs:
            self.check_usage(pkg)