コード例 #1
0
        def test():
            # We'll add no project file, so the only sources that should
            # be fond are VUnit's files
            it.assertIn('vunit', sys.modules)
            project_filename = p.join(TEST_CONFIG_PARSER_SUPPORT_PATH,
                                      'builder_only_project.prj')
            with mock.patch('hdlcc.builders.MSim.file_types',
                            new_callable=mock.PropertyMock,
                            return_value=('vhdl', 'systemverilog')):
                parser = ConfigParser(project_filename)
            sources = parser.getSources()

            _logger.info("Sources found:")
            for source in sources:
                _logger.info("- %s", source)

            vunit_files = 0
            for source in sources:
                if 'vunit' in source.filename.lower():
                    vunit_files += 1

            it.assertEqual(len(sources), vunit_files,
                           "We should only find VUnit files")

            for filetype in ('vhdl', 'systemverilog'):
                it.assertIn(filetype, [x.filetype for x in sources],
                            "We should find %s files" % filetype)
コード例 #2
0
ファイル: hdlcc_base.py プロジェクト: seadanda/hdlcc
    def _setupEnvIfNeeded(self):
        """
        Updates or creates the environment, which includes checking
        if the configuration file should be parsed and creating the
        appropriate builder objects
        """
        try:
            # If the configuration is undefined, try to extract the
            # target dir from the project file so we can have a hint of
            # where the cache file should be
            if self._config is None and self.project_file is not None:
                target_dir, _ = ConfigParser.simpleParse(self.project_file)
                self._recoverCache(target_dir)

            # No configuration defined means we failed to recover it
            # from the cache
            if self._config is None:
                self._config = ConfigParser(self.project_file)

            # If the builder is still undefined we failed to recover
            # from cache
            if self.builder is None:
                builder_name = self._config.getBuilder()
                builder_class = hdlcc.builders.getBuilderByName(builder_name)
                self.builder = builder_class(self._config.getTargetDir())

                self._logger.info("Selected builder is '%s'",
                                  self.builder.builder_name)
            assert self.builder is not None

        except hdlcc.exceptions.SanityCheckError as exc:
            self._handleUiError("Failed to create builder '%s'" % exc.builder)
            self.builder = hdlcc.builders.Fallback(self._config.getTargetDir())
コード例 #3
0
        def test():
            # We'll add no project file, so the only sources that should
            # be fond are VUnit's files
            project_filename = p.join(TEST_CONFIG_PARSER_SUPPORT_PATH,
                                      'builder_only_project.prj')
            parser = ConfigParser(project_filename)
            sources = parser.getSources()

            it.assertEquals(
                sources, [], "We shouldn't find any source but found %s" %
                ", ".join([x.filename for x in sources]))
コード例 #4
0
        def setup():
            it.project_filename = 'test.prj'
            it.lib_path = p.join(TEST_SUPPORT_PATH, 'vim-hdl-examples')
            it.sources = [('work', p.join('another_library', 'foo.vhd')),
                          ('work', p.join('basic_library',
                                          'clock_divider.vhd'))]

            writeListToFile(
                it.project_filename,
                ["vhdl %s %s" % (lib, path) for lib, path in it.sources])

            it.parser = ConfigParser(it.project_filename)
コード例 #5
0
        def setup():
            it.no_vunit = mock.patch('hdlcc.config_parser.foundVunit',
                                     lambda: False)
            it.no_vunit.start()

            project_filename = p.join(TEST_CONFIG_PARSER_SUPPORT_PATH,
                                      'standard_project_file.prj')
            it.parser = ConfigParser(project_filename)

            # Create empty files listed in the project file to avoid
            # crashing the config parser
            open(p.join(TEST_CONFIG_PARSER_SUPPORT_PATH, 'foo.v'), 'a')
            open(p.join(TEST_CONFIG_PARSER_SUPPORT_PATH, 'bar.sv'), 'a')
コード例 #6
0
 def test():
     parser = ConfigParser(
         p.join(TEST_CONFIG_PARSER_SUPPORT_PATH, 'project_no_target.prj'))
     it.assertEquals(
         parser.getTargetDir(),
         p.abspath(p.join(TEST_CONFIG_PARSER_SUPPORT_PATH, '.hdlcc')))
コード例 #7
0
 def test():
     with it.assertRaises(hdlcc.exceptions.UnknownParameterError):
         parser = ConfigParser(
             p.join(TEST_CONFIG_PARSER_SUPPORT_PATH,
                    'project_unknown_parm.prj'))
         parser.getSources()
コード例 #8
0
 def test():
     parser = ConfigParser(
         p.join(TEST_CONFIG_PARSER_SUPPORT_PATH,
                'project_wo_builder_wo_target_dir.prj'))
     it.assertEquals(parser.getBuilder(), 'fallback')
コード例 #9
0
 def test():
     it.parser = ConfigParser()
     it.assertIsNotNone(it.parser)
コード例 #10
0
            patches = [
                mock.patch('hdlcc.builders.%s.checkEnvironment' % builder,
                           lambda self: setattr(self, '_version', '<foo>')),
                mock.patch('hdlcc.builders.%s._subprocessRunner' % builder,
                           _subprocessMocker),
                mock.patch('hdlcc.builders.%s.isAvailable' % builder,
                           isAvailable)
            ]

            for patch in patches:
                patch.start()

            try:
                parser = ConfigParser(
                    p.join(TEST_CONFIG_PARSER_SUPPORT_PATH,
                           'project_wo_builder_wo_target_dir.prj'))
                for cmd in commands:
                    _logger.warning('>' + str(cmd))
                it.assertEquals(parser.getBuilder(), builder.lower())
            finally:
                for patch in patches:
                    patch.stop()

        @it.should("use fallback if no builder pass")
        def test():
            parser = ConfigParser(
                p.join(TEST_CONFIG_PARSER_SUPPORT_PATH,
                       'project_wo_builder_wo_target_dir.prj'))
            it.assertEquals(parser.getBuilder(), 'fallback')