Beispiel #1
0
    def test_load_package(self):
        path = os.path.join(self.repo_root, 'groups', 'gr3', 'gr3p1')
        package = repoloadutil.load_package(
            path, repounits.PackageType.PACKAGE_NORMAL)

        opts_str = """*                   _   OPTS_FILE       = gr3p1.opts

*       _   COMPONENT_BDEBUILD_CFLAGS      = -DGR3P1_OPTS_C
*       _   COMPONENT_BDEBUILD_CXXFLAGS    = -DGR3P1_OPTS_CXX
*       _   COMPONENT_BDEBUILD_LDFLAGS     = -DGR3P1_OPTS_LD

*       _   TESTDRIVER_BDEBUILD_CFLAGS     = -DTEST_GR3P1_OPTS_C
*       _   TESTDRIVER_BDEBUILD_CXXFLAGS   = -DTEST_GR3P1_OPTS_CXX
*       _   TESTDRIVER_BDEBUILD_LDFLAGS    = -DTEST_GR3P1_OPTS_LD
"""
        cap_str = """ !! unix  _  CAPABILITY = ALWAYS
"""

        exp_package = repounits.Package(path,
                                        repounits.PackageType.PACKAGE_NORMAL)
        exp_package.mem = set(['gr3p1_comp1', 'gr3p1_comp2'])
        exp_package.dep = set(['gr3p2'])
        exp_package.opts = self._parse_opts_str(opts_str)
        exp_package.cap = self._parse_opts_str(cap_str)
        exp_package.has_dums = True
        exp_package.components = [
            repounits.Component("gr3p1_comp1"),
            repounits.Component("gr3p1_comp2")
        ]

        self.assertEqual(package, exp_package)
Beispiel #2
0
def load_component(name, package_path):
    """Load a component.

    Args:
        name (str): The name of the component.
        package_path (str): The path to the package containing the component.

    Returns:
        None
    """
    component = repounits.Component(name)
    base_path = os.path.join(package_path, component.name)
    header_path = base_path + '.h'
    cxx_path = base_path + '.cpp'
    c_path = base_path + '.c'

    if not os.path.isfile(header_path):
        raise blderror.MissingFileError('Missing header file "%s"' %
                                        header_path)

    if os.path.isfile(cxx_path):
        component.type_ = repounits.ComponentType.CXX
        test_path = base_path + '.t.cpp'
    elif os.path.isfile(c_path):
        component.type_ = repounits.ComponentType.C
        test_path = base_path + '.t.c'
    else:
        raise blderror.MissingFileError(
            'Missing source (cpp) file for header file "%s"' % header_path)

    component.has_test_driver = os.path.isfile(test_path)
    return component
Beispiel #3
0
    def test_load_component(self):
        path = os.path.join(self.repo_root, 'groups', 'gr3', 'gr3p1')
        component = repoloadutil.load_component('gr3p1_comp1', path)

        exp_component = repounits.Component('gr3p1_comp1',
                                            repounits.ComponentType.CXX, True)
        self.assertEqual(component, exp_component)