コード例 #1
0
ファイル: parse_test.py プロジェクト: zhengweina/conan
    def setUp(self):
        self.test_folder = temp_folder()
        self.layout_filepath = os.path.join(self.test_folder, "layout")
        self.editable_cpp_info = EditableLayout(self.layout_filepath)

        self.settings = Settings.loads(get_default_settings_yml())
        self.options = Options(PackageOptions({"shared": [True, False]}))
コード例 #2
0
ファイル: load_data_test.py プロジェクト: zhengweina/conan
class ParseTest(unittest.TestCase):
    def setUp(self):
        self.test_folder = temp_folder()
        self.layout_filepath = os.path.join(self.test_folder, "layout")
        self.editable_cpp_info = EditableLayout(self.layout_filepath)

    def tearDown(self):
        shutil.rmtree(self.test_folder)

    def test_field_error(self):
        content = textwrap.dedent("""
                            [includedrs]
                            something
                            """)
        save(self.layout_filepath, content)
        with six.assertRaisesRegex(
                self, ConanException,
                "Wrong cpp_info field 'includedrs' in layout"):
            _ = self.editable_cpp_info._load_data(ref=None,
                                                  settings=None,
                                                  options=None)
        content = textwrap.dedent("""
                            [*:includedrs]
                            something
                            """)
        save(self.layout_filepath, content)
        with six.assertRaisesRegex(
                self, ConanException,
                "Wrong cpp_info field 'includedrs' in layout"):
            _ = self.editable_cpp_info._load_data(ref=None,
                                                  settings=None,
                                                  options=None)

        content = textwrap.dedent("""
                            [*:includedirs]
                            something
                            """)
        save(self.layout_filepath, content)
        with six.assertRaisesRegex(
                self, ConanException,
                "Wrong package reference '\*' in layout file"):
            _ = self.editable_cpp_info._load_data(ref=None,
                                                  settings=None,
                                                  options=None)

        content = textwrap.dedent("""
                            [pkg/version@user/channel:revision:includedirs]
                            something
                            """)
        save(self.layout_filepath, content)
        with six.assertRaisesRegex(
                self, ConanException, "Wrong package reference "
                "'pkg/version@user/channel:revision' in layout file"):
            _ = self.editable_cpp_info._load_data(ref=None,
                                                  settings=None,
                                                  options=None)
コード例 #3
0
 def editable_cpp_info(self):
     if self._layout_file:
         if os.path.isfile(self._layout_file):
             return EditableLayout(self._layout_file)
         else:
             raise ConanException("Layout file not found: %s" %
                                  self._layout_file)
コード例 #4
0
ファイル: parse_test.py プロジェクト: zhengweina/conan
class ParseTest(unittest.TestCase):
    def setUp(self):
        self.test_folder = temp_folder()
        self.layout_filepath = os.path.join(self.test_folder, "layout")
        self.editable_cpp_info = EditableLayout(self.layout_filepath)

        self.settings = Settings.loads(get_default_settings_yml())
        self.options = Options(PackageOptions({"shared": [True, False]}))

    def tearDown(self):
        shutil.rmtree(self.test_folder)

    def test_render_basic(self):
        self.options.shared = True
        self.settings.build_type = "Debug"

        content = textwrap.dedent("""
            [includedirs]
            {% if options.shared %}
            path/to/shared/{{ settings.build_type }}
            {% else %}
            not/expected
            {% endif %}
            """)
        save(self.layout_filepath, content)

        data, folders = self.editable_cpp_info._load_data(ref=None, settings=self.settings,
                                                          options=self.options)
        self.assertEqual(data[None], {'includedirs': ["path/to/shared/Debug"]})

    def test_render_loop(self):
        self.settings.build_type = "Debug"

        content = textwrap.dedent("""
            [includedirs]
            {% for item in ["cmp1", "cmp2", "cmp3"] %}
            components\{{ item }}\include\{% if item != "cmp3" %}{{ settings.build_type }}{% endif %}
            {% endfor %}
            """)
        save(self.layout_filepath, content)

        data, folders = self.editable_cpp_info._load_data(ref=None, settings=self.settings,
                                                          options=self.options)
        self.assertEqual(data[None], {'includedirs': ["components/cmp1/include/Debug",
                                                      "components/cmp2/include/Debug",
                                                      "components/cmp3/include/"]})
コード例 #5
0
class ApplyEditableLayoutTest(unittest.TestCase):
    def setUp(self):
        self.test_folder = temp_folder()
        self.layout_filepath = os.path.join(self.test_folder, "layout")
        self.ref = ConanFileReference.loads("libA/0.1@user/channel")
        self.editable_cpp_info = EditableLayout(self.layout_filepath)

    def tearDown(self):
        shutil.rmtree(self.test_folder)

    def test_require_no_namespace(self):
        content = base_content.format(namespace="", path_prefix="")
        save(self.layout_filepath, content)
        cpp_info = CppInfo(self.ref.name, None)
        self.editable_cpp_info.apply_to(self.ref,
                                        cpp_info,
                                        settings=None,
                                        options=None)
        self.assertListEqual(cpp_info.includedirs, ['dirs/includedirs'])
        self.assertListEqual(cpp_info.libdirs, ['dirs/libdirs'])
        self.assertListEqual(cpp_info.resdirs, ['dirs/resdirs'])
        # The default defined by package_info() is respected
        self.assertListEqual(cpp_info.bindirs, ["bin"])

    def test_require_namespace(self):
        content = '\n\n'.join([
            base_content.format(namespace="", path_prefix=""),
            base_content.format(namespace="libA/0.1@user/channel:",
                                path_prefix="libA/")
        ])
        save(self.layout_filepath, content)
        cpp_info = CppInfo("", None)
        self.editable_cpp_info.apply_to(self.ref,
                                        cpp_info,
                                        settings=None,
                                        options=None)
        self.assertListEqual(cpp_info.includedirs, ['libA/dirs/includedirs'])
        self.assertListEqual(cpp_info.libdirs, ['libA/dirs/libdirs'])
        self.assertListEqual(cpp_info.resdirs, ['libA/dirs/resdirs'])
        # The default defined by package_info() is respected
        self.assertListEqual(cpp_info.bindirs, ['bin'])

        cpp_info = CppInfo("", None)
        other = ConanFileReference.loads("other/0.1@user/channel")
        self.editable_cpp_info.apply_to(other,
                                        cpp_info,
                                        settings=None,
                                        options=None)
        self.assertListEqual(cpp_info.includedirs, ['dirs/includedirs'])
        self.assertListEqual(cpp_info.libdirs, ['dirs/libdirs'])
        self.assertListEqual(cpp_info.resdirs, ['dirs/resdirs'])
        # The default defined by package_info() is respected
        self.assertListEqual(cpp_info.bindirs, ['bin'])
コード例 #6
0
 def setUp(self):
     self.test_folder = temp_folder()
     self.layout_filepath = os.path.join(self.test_folder, "layout")
     self.ref = ConanFileReference.loads("libA/0.1@user/channel")
     self.editable_cpp_info = EditableLayout(self.layout_filepath)
コード例 #7
0
ファイル: load_data_test.py プロジェクト: zhengweina/conan
 def setUp(self):
     self.test_folder = temp_folder()
     self.layout_filepath = os.path.join(self.test_folder, "layout")
     self.editable_cpp_info = EditableLayout(self.layout_filepath)