コード例 #1
0
ファイル: qtcreator.py プロジェクト: michaelbrockus/meson-ui
 def __init__(self, meson_api: MesonAPI):
     self.backend: str = '\'qtcreator\''
     self.projectinfo = ProjectInfo(meson_api=meson_api)
     self.mesoninfo = MesonInfo(meson_api=meson_api)
     self.buildsystem_files: list = meson_api.get_object(
         group='buildsystem-files', extract_method='loader')
     self.targetsinfo: list = meson_api.get_object(group='targets',
                                                   extract_method='loader')
コード例 #2
0
ファイル: codeblocks.py プロジェクト: michaelbrockus/meson-ui
 def __init__(self, meson_api: MesonAPI):
     self.backend: str = '\'codeblocks\''
     self.projectinfo = ProjectInfo(meson_api=meson_api)
     self.mesoninfo = MesonInfo(meson_api=meson_api)
     self.buildsystem_files = meson_api.get_object(
         group='buildsystem-files', extract_method='loader')
     self.targetsinfo: any = meson_api.get_object(group='targets',
                                                  extract_method='loader')
     self.ninja = Ninja(self.mesoninfo.sourcedir, self.mesoninfo.builddir)
     self.compiler = self.targetsinfo[0]['target_sources'][0]['compiler'][0]
コード例 #3
0
    def test_codeblocks_backend(self):
        #
        # Setting up tmp test directory
        source = Path(join_paths('test-cases', 'backends',
                                 '02-codeblocks')).resolve()
        build = Path(
            join_paths('test-cases', 'backends', '02-codeblocks',
                       'builddir')).resolve()

        #
        # Running Meson command
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup(['--backend=ninja'])
        api = MesonAPI(sourcedir=source, builddir=build)
        ide = CodeBlocksBackend(api)
        ide.generator()

        #
        # Run asserts to check it is working
        assert os.path.exists(join_paths(source, 'meson.build'))
        assert os.path.exists(join_paths(build, 'build.ninja'))
        assert os.path.exists(
            join_paths(build, 'meson-info', 'intro-projectinfo.json'))
        assert os.path.exists(join_paths(build, 'compile_commands.json'))
        assert os.path.exists(join_paths(build, 'basic.cbp'))
コード例 #4
0
 def test_meson_api_bad_extract_method(self):
     reader: MesonAPI = MesonAPI(None, None)
     with pytest.raises(Exception) as e:
         reader = reader.get_object(group='not-a-key',
                                    extract_method='not-a-method')
     assert ('Extract method not-a-method not found in Meson "JSON" API!' ==
             str(e.value))
コード例 #5
0
    def test_qtcreator_backend(self):
        #
        # Setting up tmp test directory
        source = Path(join_paths('test-cases', 'backends', '03-qtcreator'))
        build = Path(
            join_paths('test-cases', 'backends', '03-qtcreator', 'builddir'))

        #
        # Running Meson command
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()
        api = MesonAPI(sourcedir=source, builddir=build)
        ide = QtCreatorBackend(api)
        ide.generator()

        #
        # Run asserts to check it is working
        assert os.path.exists(join_paths(source, 'meson.build'))
        assert os.path.exists(join_paths(build, 'build.ninja'))
        assert os.path.exists(
            join_paths(build, 'meson-info', 'intro-projectinfo.json'))
        assert os.path.exists(join_paths(build, 'compile_commands.json'))
        assert os.path.exists(join_paths(build, 'basic.creator'))
        assert os.path.exists(join_paths(build, 'basic.includes'))
        assert os.path.exists(join_paths(build, 'basic.files'))
コード例 #6
0
 def test_meson_api_bad_group_type(self):
     reader: MesonAPI = MesonAPI(None, None)
     with pytest.raises(Exception) as e:
         reader = reader.get_object(group=1234.09,
                                    extract_method='not-a-method')
     assert (
         'API group key pair <class \'float\'> is not valid type!' == str(
             e.value))
コード例 #7
0
 def __init__(self, meson_api: MesonAPI):
     self._project_info: any = meson_api.get_object(group='projectinfo',
                                                    extract_method='loader')
     self.descriptive_name: str = re.sub(
         r'[^a-z0-9]', '_', self._project_info['descriptive_name'])
     self.subprojects: list = self._project_info['subprojects']
     self.number_of_subprojects: list = len(
         self._project_info['subprojects'])
コード例 #8
0
    def test_meson_api_scanner_fullback_get_none(self):
        source = join('test-cases', 'meson-api', '08-scan-null')
        build = join('test-cases', 'meson-api', '08-scan-null', 'builddir')

        script: MesonAPI = MesonAPI(sourcedir=source, builddir=build)
        #
        # As a last posable value we will give None
        info = script.get_object(group='projectinfo', extract_method='script')

        assert (info is None)
コード例 #9
0
    def test_meson_api_scanner_testlogs_get_none(self):
        source = join('test-cases', 'meson-api', '11-scan-testlog-null')
        build = join('test-cases', 'meson-api', '11-scan-testlog-null',
                     'builddir')

        script: MesonAPI = MesonAPI(sourcedir=source, builddir=build)
        #
        # Posable value of passing testlog will be None
        info = script.get_object(group='testlog', extract_method='script')

        assert (info is None)
コード例 #10
0
    def test_meson_api_loader_use_fullback(self):
        source = join('test-cases', 'meson-api', '05-load-fullback')
        build = join('test-cases', 'meson-api', '05-load-fullback', 'builddir')

        script: MesonAPI = MesonAPI(sourcedir=source, builddir=build)
        #
        # Should automatically use fullback if builddir not found
        info = script.get_object(group='projectinfo', extract_method='loader')

        assert (info['descriptive_name'] == 'simple-case')
        assert (info['version'] == '0.1')
        assert (info['subproject_dir'] == 'subprojects')
コード例 #11
0
    def test_option_not_found(self):
        source = join('test-cases', 'meson-api', '01-scan-script')
        build = join('test-cases', 'meson-api', '01-scan-script', 'builddir')
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        api: MesonAPI = MesonAPI(sourcedir=source, builddir=build)
        option: BuildOption = BuildOption(api)

        with pytest.raises(MesonUiException) as e:
            option.integer('smap-option')
        assert ('Option smap-option not found!' == str(e.value))
コード例 #12
0
    def test_change_sourcedir(self):
        script: MesonAPI = MesonAPI('test/dir/one', 'test/dir/one/builddir')

        assert (script.sourcedir == 'test/dir/one')
        assert (script.builddir == 'test/dir/one/builddir')

        script.sourcedir = 'test/dir/two'
        script.builddir = 'test/dir/two/builddir'

        assert (script.sourcedir != 'test/dir/one')
        assert (script.builddir != 'test/dir/one/builddir')
        assert (script.sourcedir == 'test/dir/two')
        assert (script.builddir == 'test/dir/two/builddir')
コード例 #13
0
    def test_meson_api_load_from_builddir(self):
        source = join('test-cases', 'meson-api', '03-load-builddir')
        build = join('test-cases', 'meson-api', '03-load-builddir', 'builddir')
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        script: MesonAPI = MesonAPI(sourcedir=source, builddir=build)
        info = script.get_object(group='projectinfo', extract_method='loader')

        assert (info['descriptive_name'] == 'simple-case')
        assert (info['version'] == '0.1')
        assert (info['subproject_dir'] == 'subprojects')
コード例 #14
0
    def test_array_wrong_type_name_pram(self):
        source = join('test-cases', 'meson-api', '01-scan-script')
        build = join('test-cases', 'meson-api', '01-scan-script', 'builddir')
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        api: MesonAPI = MesonAPI(sourcedir=source, builddir=build)
        option: BuildOption = BuildOption(api)

        with pytest.raises(MesonUiException) as e:
            option.array(None)
        assert ('Option has wrong type <class \'NoneType\'> should be string!'
                == str(e.value))
コード例 #15
0
    def test_combo(self):
        source = join('test-cases', 'meson-api', '01-scan-script')
        build = join('test-cases', 'meson-api', '01-scan-script', 'builddir')
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        api: MesonAPI = MesonAPI(sourcedir=source, builddir=build)
        option: BuildOption = BuildOption(api)
        opt = option.combo('backend')

        assert (opt.section in MESON_OPTION_SECTION)
        assert (opt.machine in MESON_OPTION_MACHINE)
        assert (opt.type in MESON_OPTION_TYPES)
コード例 #16
0
    def test_gnome_builder_backend(self):
        #
        # Setting up tmp test directory
        source = Path(join_paths('test-cases', 'backends',
                                 '04-gnome')).resolve()
        build = Path(
            join_paths('test-cases', 'backends', '04-gnome',
                       'builddir')).resolve()

        #
        # Running Meson command
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup(['--backend=ninja'])
        api = MesonAPI(sourcedir=source, builddir=build)
        ide = GNOMEBuilderBackend(api)
        ide.generator()

        #
        # Run asserts to check it is working
        assert os.path.exists(join_paths(source, 'meson.build'))
        assert os.path.exists(join_paths(build, 'build.ninja'))
        assert os.path.exists(join_paths(build, 'compile_commands.json'))
コード例 #17
0
 def __init__(self, meson_api: MesonAPI):
     self._meson_info: any = meson_api.get_object(group='meson-info',
                                                  extract_method='loader')
     self.sourcedir: Path = Path(self._meson_info['directories']['source'])
     self.builddir: Path = Path(self._meson_info['directories']['build'])
     self.infodir: Path = Path(self._meson_info['directories']['info'])
コード例 #18
0
 def test_meson_api_bad_extract_method_type(self):
     reader: MesonAPI = MesonAPI(None, None)
     with pytest.raises(Exception) as e:
         reader = reader.get_object(group='not-a-key', extract_method=None)
     assert ('API extract method <class \'NoneType\'> is not valid type!' ==
             str(e.value))