def test_install_via_invalid_enum(self):
        self.options.install_via = 'invalid'
        with self.assertRaises(RuntimeError) as raised:
            autotools.AutotoolsPlugin('test-part', self.options)

        self.assertEqual(str(raised.exception),
                         'Unsupported installation method: "invalid"')
Example #2
0
    def test_build_nonexecutable_autogen(self, stdout_mock):
        plugin = autotools.AutotoolsPlugin('test-part', self.options,
                                           self.project_options)
        os.makedirs(plugin.sourcedir)

        # Make a non-executable autogen.sh
        with open(os.path.join(plugin.sourcedir, 'autogen.sh'), 'w') as f:
            f.write('#!/bin/sh')

        patcher = mock.patch.object(autotools.AutotoolsPlugin, 'run')
        run_mock = patcher.start()

        # We want to mock out every run() call except the one to autogen
        def _run(cmd, env=None):
            if './autogen.sh' in cmd:
                patcher.stop()
                output = plugin.run(cmd, env=env)
                patcher.start()
                return output

        run_mock.side_effect = _run

        # An exception will be raised if build can't handle the non-executable
        # autogen.
        plugin.build()
Example #3
0
    def test_build_nonexecutable_autogen(self, stdout_mock):
        plugin = autotools.AutotoolsPlugin('test-part', self.options)
        os.makedirs(plugin.sourcedir)

        # Make a non-executable autogen.sh
        with open(os.path.join(plugin.sourcedir, 'autogen.sh'), 'w') as f:
            f.write('#!/bin/sh')

        patcher = mock.patch.object(autotools.AutotoolsPlugin, 'run')
        run_mock = patcher.start()

        # We want to mock out every run() call except the one to autogen
        def _run(cmd):
            if './autogen.sh' in cmd:
                patcher.stop()
                output = plugin.run(cmd)
                patcher.start()
                return output

        run_mock.side_effect = _run

        try:
            plugin.build()
        except:
            self.fail('Expected build() to be able to handle non-executable '
                      'autogen.sh')
 def test_fileset_ignores(self):
     plugin = autotools.AutotoolsPlugin('test-part', self.options,
                                        self.project_options)
     expected_fileset = [
         '-**/*.la',
     ]
     fileset = plugin.snap_fileset()
     self.assertListEqual(expected_fileset, fileset)
Example #5
0
 def test_cross_compile(self):
     plugin = autotools.AutotoolsPlugin('test-part', self.options,
                                        self.project_options)
     plugin.enable_cross_compilation()
     env = plugin.env(plugin.sourcedir)
     self.assertIn('CC={}-gcc'.format(self.project_options.arch_triplet),
                   env)
     self.assertIn('CXX={}-g++'.format(self.project_options.arch_triplet),
                   env)
    def build_with_autoreconf(self):
        plugin = autotools.AutotoolsPlugin('test-part', self.options)
        os.makedirs(plugin.sourcedir)

        # No configure or autogen.sh.

        plugin.build()

        return plugin
Example #7
0
 def test_cross_compile(self):
     plugin = autotools.AutotoolsPlugin('test-part', self.options,
                                        self.project_options)
     plugin.enable_cross_compilation()
     plugin.build()
     self.run_mock.assert_has_calls([
         mock.call(
             ['./configure', '--prefix=', '--host={}'.format(self.triplet)],
             cwd=mock.ANY)
     ])
    def build_with_autogen(self):
        plugin = autotools.AutotoolsPlugin('test-part', self.options)
        os.makedirs(plugin.sourcedir)

        # No configure-- only autogen.sh. Make sure it's executable.
        open(os.path.join(plugin.sourcedir, 'autogen.sh'), 'w').close()
        os.chmod(os.path.join(plugin.sourcedir, 'autogen.sh'),
                 stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)

        plugin.build()

        return plugin
    def build_with_configure(self):
        plugin = autotools.AutotoolsPlugin('test-part', self.options)
        os.makedirs(plugin.sourcedir)

        # Create both configure and autogen.sh.
        # Configure should take precedence.
        open(os.path.join(plugin.sourcedir, 'configure'), 'w').close()
        open(os.path.join(plugin.sourcedir, 'autogen.sh'), 'w').close()

        plugin.build()

        return plugin
Example #10
0
 def test_cross_compile(self):
     plugin = autotools.AutotoolsPlugin("test-part", self.options, self.project)
     plugin.enable_cross_compilation()
     plugin.build()
     self.run_mock.assert_has_calls(
         [
             mock.call(
                 ["./configure", "--prefix=", "--host={}".format(self.triplet)],
                 cwd=mock.ANY,
             )
         ]
     )
Example #11
0
    def build_with_configure(self):
        plugin = autotools.AutotoolsPlugin("test-part", self.options, self.project)
        os.makedirs(plugin.builddir)

        # Create both configure and autogen.sh.
        # Configure should take precedence.
        open(os.path.join(plugin.builddir, "configure"), "w").close()
        open(os.path.join(plugin.builddir, "autogen.sh"), "w").close()

        plugin.build()

        return plugin
Example #12
0
    def test_build_autoreconf(self, run_mock):
        plugin = autotools.AutotoolsPlugin('test-part', self.options)
        os.makedirs(plugin.sourcedir)

        # No configure or autogen.sh.

        plugin.build()

        self.assertEqual(3, run_mock.call_count)
        run_mock.assert_has_calls([
            mock.call(['autoreconf', '-i']),
            mock.call(['./configure', '--prefix=']),
            mock.call(['make', 'install',
                       'DESTDIR={}'.format(plugin.installdir)])
        ])
Example #13
0
    def test_build_configure(self, run_mock):
        plugin = autotools.AutotoolsPlugin('test-part', self.options)
        os.makedirs(plugin.sourcedir)

        # Create both configure and autogen.sh.
        # Configure should take precedence.
        open(os.path.join(plugin.sourcedir, 'configure'), 'w').close()
        open(os.path.join(plugin.sourcedir, 'autogen.sh'), 'w').close()

        plugin.build()

        self.assertEqual(2, run_mock.call_count)
        run_mock.assert_has_calls([
            mock.call(['./configure', '--prefix=']),
            mock.call(['make', 'install',
                       'DESTDIR={}'.format(plugin.installdir)])
        ])
Example #14
0
    def build_with_autogen(self, files=None):
        plugin = autotools.AutotoolsPlugin('test-part', self.options,
                                           self.project_options)
        os.makedirs(plugin.sourcedir)

        if not files:
            files = ['autogen.sh']

        # No configure-- only autogen.sh. Make sure it's executable.
        for filename in files:
            open(os.path.join(plugin.sourcedir, filename), 'w').close()
            os.chmod(os.path.join(plugin.sourcedir, filename),
                     stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)

        plugin.build()

        return plugin
Example #15
0
    def test_build_autogen(self, run_mock):
        plugin = autotools.AutotoolsPlugin('test-part', self.options)
        os.makedirs(plugin.sourcedir)

        # No configure-- only autogen.sh. Make sure it's executable.
        open(os.path.join(plugin.sourcedir, 'autogen.sh'), 'w').close()
        os.chmod(os.path.join(plugin.sourcedir, 'autogen.sh'),
                 stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)

        plugin.build()

        self.assertEqual(3, run_mock.call_count)
        run_mock.assert_has_calls([
            mock.call(['env', 'NOCONFIGURE=1', './autogen.sh']),
            mock.call(['./configure', '--prefix=']),
            mock.call(['make', 'install',
                       'DESTDIR={}'.format(plugin.installdir)])
        ])
Example #16
0
    def build_with_autogen(self, files=None, dirs=None):
        plugin = autotools.AutotoolsPlugin("test-part", self.options, self.project)
        os.makedirs(plugin.builddir)

        if not files:
            files = ["autogen.sh"]
        if not dirs:
            dirs = []

        # No configure-- only autogen.sh. Make sure it's executable.
        for filename in files:
            open(os.path.join(plugin.builddir, filename), "w").close()
            os.chmod(
                os.path.join(plugin.builddir, filename),
                stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR,
            )
        for directory in dirs:
            os.makedirs(os.path.join(plugin.builddir, directory))

        plugin.build()

        return plugin
Example #17
0
 def test_fileset_ignores(self):
     plugin = autotools.AutotoolsPlugin("test-part", self.options, self.project)
     expected_fileset = ["-**/*.la"]
     fileset = plugin.snap_fileset()
     self.assertListEqual(expected_fileset, fileset)