コード例 #1
0
    def test_change_sourcedir(self):
        meson = Meson('test/dir/one', 'test/dir/one/builddir')

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

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

        assert (meson.sourcedir == 'test/dir/two')
        assert (meson.builddir == 'test/dir/two/builddir')
コード例 #2
0
    def test_mdist_command(self, tmpdir):
        #
        # Setting up tmp test directory
        with tmpdir.as_cwd():
            pass
        tmpdir.chdir()

        #
        # Running Meson command
        meson: Meson = Meson(sourcedir=tmpdir, builddir=(tmpdir / 'builddir'))

        meson.init(['--language=c', '--type=executable'])
        meson.setup(['--backend=ninja'])
        meson.compile()

        CIUtility._git_init()
        meson.dist()

        #
        # Run asserts to check it is working
        assert tmpdir.join('meson.build').ensure()
        assert tmpdir.join('builddir', 'build.ninja').ensure()
        assert tmpdir.join('builddir', 'compile_commands.json').ensure()
        assert tmpdir.join('builddir', 'meson-dist',
                           'test_mdist_command0-0.1.tar.xz').ensure()
コード例 #3
0
    def test_subproject_checkout_subcommand(self, tmpdir):
        #
        # Setting up tmp test directory
        with tmpdir.as_cwd():
            pass
        tmpdir.chdir()

        #
        # Running Meson command
        meson: Meson = Meson(sourcedir=tmpdir, builddir=(tmpdir / 'builddir'))
        meson.init(['--language=c', '--deps', 'samplesubproject'])
        os.mkdir('subprojects')

        tmpdir.join(join_paths('subprojects',
                               'samplesubproject.wrap')).write('''\
        [wrap-git]
        directory=samplesubproject
        url=https://github.com/jpakkane/samplesubproject.git
        revision=head
        ''')

        meson.subprojects().download('samplesubproject')
        meson.subprojects().checkout('master', 'samplesubproject')

        #
        # Run asserts to check it is working
        assert tmpdir.join('meson.build').ensure()
        assert tmpdir.join('subprojects', 'samplesubproject.wrap').ensure()
        assert tmpdir.join('subprojects', 'samplesubproject',
                           '.gitignore').ensure()
        assert tmpdir.join('subprojects', 'samplesubproject',
                           'README.md').ensure()
コード例 #4
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'))
コード例 #5
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'))
コード例 #6
0
    def test_loader_meson_test(self):
        source = join('test-cases', 'intro-loader', '02-unittests')
        build = join('test-cases', 'intro-loader', '02-unittests', 'builddir')
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        script: MesonBuilddirLoader = MesonBuilddirLoader(build)
        info = script.extract_from(group='tests')

        assert (info[0]['name'] == 'basic unit test')
コード例 #7
0
    def test_reader_benchmarks(self):
        source = join('test-cases', 'intro-reader', '03-benchmarks')
        build = join('test-cases', 'intro-reader', '03-benchmarks', 'builddir')
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        script: MesonBuilddirReader = MesonBuilddirReader(build)
        info = script.extract_from(group='benchmarks')

        assert (info[0]['name'] == 'basic benchmark')
コード例 #8
0
    def test_reader_install(self):
        source = join('test-cases', 'intro-reader', '08-install')
        build = join('test-cases', 'intro-reader', '08-install', 'builddir')
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        script: MesonBuilddirReader = MesonBuilddirReader(build)
        info = script.extract_from(group='installed')

        assert (info == {})
コード例 #9
0
    def test_loader_dependencies(self):
        source = join('test-cases', 'intro-loader', '05-dependencies')
        build = join('test-cases', 'intro-loader', '05-dependencies',
                     'builddir')
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        script: MesonBuilddirLoader = MesonBuilddirLoader(build)
        info = script.extract_from(group='dependencies')

        assert (info == [])
コード例 #10
0
    def test_loader_no_testlogs(self):
        source = Path(join('test-cases', 'intro-loader', '10-no-testlog'))
        build = Path(
            join('test-cases', 'intro-loader', '10-no-testlog', 'builddir'))
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        script: MesonBuilddirLoader = MesonBuilddirLoader(build)
        info = script.extract_from(group='testlog')

        assert (info is None)
コード例 #11
0
    def test_reader_scan_dependencies(self):
        source = join('test-cases', 'intro-reader', '06-scan-dependencies')
        build = join('test-cases', 'intro-reader', '06-scan-dependencies',
                     'builddir')
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        script: MesonBuilddirReader = MesonBuilddirReader(build)
        info = script.extract_from(group='scan-dependencies')

        assert (info == {})
コード例 #12
0
    def test_reader_targets(self):
        source = join('test-cases', 'intro-reader', '07-targets')
        build = join('test-cases', 'intro-reader', '07-targets', 'builddir')
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        script: MesonBuilddirReader = MesonBuilddirReader(build)
        info = script.extract_from(group='targets')

        assert (info[0]['name'] == 'prog')
        assert (info[0]['type'] == 'executable')
        assert (info[0]['id'] == 'prog@exe')
コード例 #13
0
    def test_reader_buildoptions(self):
        source = join('test-cases', 'intro-reader', '04-buildoptions')
        build = join('test-cases', 'intro-reader', '04-buildoptions',
                     'builddir')
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        script: MesonBuilddirReader = MesonBuilddirReader(build)
        info = script.extract_from(group='buildoptions')

        assert (info[0]['name'] == 'auto_features')
        assert (info[0]['value'] == 'auto')
コード例 #14
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))
コード例 #15
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')
コード例 #16
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)
コード例 #17
0
    def test_reader_mesonbuild_files(self):
        source = Path(
            join('test-cases', 'intro-reader', '09-buildsystem_files'))
        build = Path(
            join('test-cases', 'intro-reader', '09-buildsystem_files',
                 'builddir'))
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        script: MesonBuilddirReader = MesonBuilddirReader(build)
        info = script.extract_from(group='buildsystem-files')
        print(info)
        assert (info[0] == join(source.resolve(), 'meson.build'))
コード例 #18
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))
コード例 #19
0
    def test_reader_projectinfo(self):
        source = join('test-cases', 'intro-reader', '01-projectinfo')
        build = join('test-cases', 'intro-reader', '01-projectinfo',
                     'builddir')
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        script: MesonBuilddirReader = MesonBuilddirReader(
            join(source, 'builddir'))
        info = script.extract_from(group='projectinfo')

        assert (info['descriptive_name'] == 'simple-case')
        assert (info['version'] == '0.1')
        assert (info['subproject_dir'] == 'subprojects')
コード例 #20
0
    def test_loader_mesoninfo(self):
        source = Path(join('test-cases', 'intro-loader', '08-mesoninfo'))
        build = Path(
            join('test-cases', 'intro-loader', '08-mesoninfo', 'builddir'))
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()

        script: MesonBuilddirLoader = MesonBuilddirLoader(build)
        info = script.extract_from(group='meson-info')

        assert (info['directories']['source'] == str(source.resolve()))
        assert (info['directories']['build'] == str(build.resolve()))
        assert (info['directories']['info'] == str(
            join(build.resolve(), 'meson-info')))
コード例 #21
0
    def test_loader_testlogs(self):
        source = Path(join('test-cases', 'intro-loader', '09-testlog'))
        build = Path(
            join('test-cases', 'intro-loader', '09-testlog', 'builddir'))
        meson: Meson = Meson(sourcedir=source, builddir=build)

        meson.setup()
        meson.compile()
        meson.test()
        meson.clean()

        script: MesonBuilddirLoader = MesonBuilddirLoader(build)
        info = script.extract_from(group='testlog')

        assert (info['name'] == 'running test for testlog data')
        assert (info['result'] == 'OK')
コード例 #22
0
    def test_vs_backend(self, tmpdir):
        #
        # Setting up tmp test directory
        with tmpdir.as_cwd():
            pass
        tmpdir.chdir()

        #
        # Running Meson command
        meson: Meson = Meson(sourcedir=tmpdir, builddir=(tmpdir / 'builddir'))

        meson.init(['--language=c'])
        meson.setup(['--backend=vs'])

        #
        # Run asserts to check it is working
        assert tmpdir.join('meson.build').ensure()
        assert tmpdir.join('builddir', 'build.ninja').ensure()
        assert tmpdir.join('builddir', 'compile_commands.json').ensure()
コード例 #23
0
    def test_wrap_install_subcommand(self, tmpdir):
        #
        # Setting up tmp test directory
        with tmpdir.as_cwd():
            pass
        tmpdir.chdir()

        #
        # Running Meson command
        meson: Meson = Meson(sourcedir=tmpdir, builddir=(tmpdir / 'builddir'))
        meson.init(['--language=c', '--deps', 'sqlite'])
        os.mkdir('subprojects')

        meson.wrap().install('sqlite')

        #
        # Run asserts to check it is working
        assert tmpdir.join('meson.build').ensure()
        assert tmpdir.join('subprojects', 'sqlite.wrap').ensure()
コード例 #24
0
    def test_subproject_download_subcommand(self, tmpdir):
        #
        # Setting up tmp test directory
        with tmpdir.as_cwd():
            pass
        tmpdir.chdir()

        #
        # Running Meson command
        meson: Meson = Meson(sourcedir=tmpdir, builddir=(tmpdir / 'builddir'))
        meson.init(['--language=c', '--deps', 'sqlite'])
        os.mkdir('subprojects')

        tmpdir.join(join_paths('subprojects', 'sqlite.wrap')).write(TEST_WRAP)

        meson.subprojects().download('sqlite')

        #
        # Run asserts to check it is working
        assert tmpdir.join('meson.build').ensure()
        assert tmpdir.join('subprojects', 'sqlite.wrap').ensure()
コード例 #25
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'))
コード例 #26
0
    def test_xcode_backend(self, tmpdir):
        #
        # Setting up tmp test directory
        with tmpdir.as_cwd():
            pass
        tmpdir.chdir()

        #
        # Running Meson command
        meson: Meson = Meson(sourcedir=tmpdir, builddir=(tmpdir / 'builddir'))

        meson.init(['--language=c', '--type=executable'])
        meson.setup(['--backend=xcode'])
        meson.compile()
        meson.test()

        #
        # Run asserts to check it is working
        assert tmpdir.join('meson.build').ensure()
        assert tmpdir.join('builddir', 'build.ninja').ensure()
        assert tmpdir.join('builddir', 'compile_commands.json').ensure()
        assert tmpdir.join('builddir', 'test-prog.xcodeproj',
                           'project.pbxproj').ensure()