Beispiel #1
0
    def test_parse_build_results_banned_files(self):
        """
        Test parse_build_results with a test log indicating banned files are missing
        """
        def mock_util_call(cmd):
            del cmd

        conf = config.Config()
        conf.setup_patterns()
        reqs = buildreq.Requirements("")
        tcontent = tarball.Content("", "", "", [], conf)
        call_backup = build.util.call
        build.util.call = mock_util_call
        fm = files.FileManager(conf)

        open_name = 'build.util.open_auto'
        content = 'line 1\n' \
                  'Installed (but unpackaged) file(s) found:\n' \
                  '/opt/file\n' \
                  '/usr/etc/file\n' \
                  '/usr/local/file\n' \
                  '/usr/src/file\n' \
                  '/var/file\n' \
                  'RPM build errors\n' \
                  'errors here\n'
        m_open = mock_open(read_data=content)

        with patch(open_name, m_open, create=True):
            build.parse_build_results('testname', 0, fm, conf, reqs, tcontent)

        build.util.call = call_backup

        self.assertEqual(fm.has_banned, True)
        # check no files were added
        self.assertEqual(build.must_restart, 0)
Beispiel #2
0
    def test_parse_build_results_patch(self):
        """
        Test parse_build_results with a test log indicating failure due to a
        a backport patch no longer applying
        """
        def mock_util_call(cmd):
            del cmd

        def mock_conf_remove_backport_patch(patch):
            del patch
            return 1

        conf = config.Config('')
        conf.setup_patterns()
        conf.remove_backport_patch = mock_conf_remove_backport_patch
        conf.patches = ['backport-test.patch']
        reqs = buildreq.Requirements("")
        tcontent = tarball.Content("", "", "", [], conf, "/")
        call_backup = build.util.call
        build.util.call = mock_util_call
        pkg = build.Build()
        fm = files.FileManager(conf, pkg)

        open_name = 'build.util.open_auto'
        content = 'line 1\nPatch #1 (backport-test.patch):\nSkipping patch.'
        m_open = mock_open(read_data=content)

        with patch(open_name, m_open, create=True):
            pkg.parse_build_results('testname', 0, fm, conf, reqs, tcontent)

        build.util.call = call_backup

        self.assertEqual(pkg.must_restart, 1)
Beispiel #3
0
    def test_parse_build_results_pkgconfig(self):
        """
        Test parse_build_results with a test log indicating failure due to a
        missing qmake package (pkgconfig error)
        """
        def mock_util_call(cmd):
            del cmd

        conf = config.Config('')
        conf.setup_patterns()
        reqs = buildreq.Requirements("")
        tcontent = tarball.Content("", "", "", [], conf, "/")
        conf.config_opts['32bit'] = True
        call_backup = build.util.call
        build.util.call = mock_util_call
        pkg = build.Build()
        fm = files.FileManager(conf, pkg)

        open_name = 'build.util.open_auto'
        content = 'line 1\nwhich: no qmake\nexiting'
        m_open = mock_open(read_data=content)

        with patch(open_name, m_open, create=True):
            pkg.parse_build_results('testname', 0, fm, conf, reqs, tcontent)

        build.util.call = call_backup

        self.assertIn('pkgconfig(Qt)', reqs.buildreqs)
        self.assertIn('pkgconfig(32Qt)', reqs.buildreqs)
        self.assertEqual(pkg.must_restart, 1)
Beispiel #4
0
    def test_parse_build_results_simple_pats(self):
        """
        Test parse_build_results with a test log indicating failure due to a
        missing httpd-dev package (simple pat error)
        """
        def mock_util_call(cmd):
            del cmd

        conf = config.Config('')
        conf.setup_patterns()
        reqs = buildreq.Requirements("")
        tcontent = tarball.Content("", "", "", [], conf, "/")
        call_backup = build.util.call
        build.util.call = mock_util_call
        pkg = build.Build()
        fm = files.FileManager(conf, pkg)

        open_name = 'build.util.open_auto'
        content = 'line 1\nchecking for Apache test module support\nexiting'
        m_open = mock_open(read_data=content)

        with patch(open_name, m_open, create=True):
            pkg.parse_build_results('testname', 0, fm, conf, reqs, tcontent)

        build.util.call = call_backup

        self.assertIn('httpd-dev', reqs.buildreqs)
        self.assertEqual(pkg.must_restart, 1)
Beispiel #5
0
    def test_parse_build_results_failed_pats(self):
        """
        Test parse_build_results with a test log indicating failure due to a
        missing package.
        """
        conf = config.Config('')
        conf.setup_patterns()
        reqs = buildreq.Requirements("")
        tcontent = tarball.Content("", "", "", [], conf, "/")
        call_backup = build.util.call
        open_auto_backup = build.util.open_auto
        build.util.call = MagicMock(return_value=None)
        pkg = build.Build()
        fm = files.FileManager(conf, pkg)

        with open('tests/builderrors', 'r') as f:
            builderrors = f.readlines()
            for error in builderrors:
                if not error.startswith('#'):
                    input, output = error.strip('\n').split('|')
                    reqs.buildreqs = set()
                    build.util.open_auto = mock_open(read_data=input)
                    pkg.parse_build_results('testname', 0, fm, conf, reqs,
                                            tcontent)

                    self.assertIn(output, reqs.buildreqs)
                    self.assertGreater(pkg.must_restart, 0)

        # Restoring functions
        build.util.call = call_backup
        build.util.open_auto = open_auto_backup
Beispiel #6
0
 def test_simple_pattern_no_match(self):
     """
     Test simple_pattern with no match, nothing should be modified
     """
     reqs = buildreq.Requirements("")
     build.simple_pattern('line to test for somepkg.xyz', r'testpkg.xyz',
                          'testpkg', reqs)
     self.assertEqual(reqs.buildreqs, set())
     self.assertEqual(build.must_restart, 0)
Beispiel #7
0
 def test_simple_pattern_pkgconfig(self):
     """
     Test simple_pattern_pkgconfig with match
     """
     reqs = buildreq.Requirements("")
     build.simple_pattern_pkgconfig('line to test for testpkg.xyz',
                                    r'testpkg.xyz', 'testpkg', False, reqs)
     self.assertIn('pkgconfig(testpkg)', reqs.buildreqs)
     self.assertEqual(build.must_restart, 1)
Beispiel #8
0
 def test_simple_pattern_pkgconfig_32bit(self):
     """
     Test simple_pattern_pkgconfig with match and 32bit option set
     """
     reqs = buildreq.Requirements("")
     build.simple_pattern_pkgconfig('line to test for testpkg.zyx',
                                    r'testpkg.zyx', 'testpkgz', True, reqs)
     self.assertIn('pkgconfig(32testpkgz)', reqs.buildreqs)
     self.assertIn('pkgconfig(testpkgz)', reqs.buildreqs)
     self.assertEqual(build.must_restart, 1)
Beispiel #9
0
    def setUp(self):
        # url, version, name, release
        url = "http://www.testpkg.com/testpkg/pkg-1.0.tar.gz"
        conf = config.Config("")
        content = tarball.Content('', '', '', [], conf, "")
        conf.content = content
        self.specfile = specfiles.Specfile(url, '1.1.1', 'test_pkg', '1', conf,
                                           buildreq.Requirements(url), content)

        self.bb_dict = {"DEPENDS": "ncurses gettext-native", "LICENSE": "new"}
Beispiel #10
0
 def test_simple_pattern_pkgconfig_no_match(self):
     """
     Test simple_pattern_pkgconfig with no match, nothing should be modified
     """
     reqs = buildreq.Requirements("")
     pkg = build.Build()
     pkg.simple_pattern_pkgconfig('line to test for somepkg.xyz',
                                  r'testpkg.xyz', 'testpkg', False, reqs)
     self.assertEqual(reqs.buildreqs, set())
     self.assertEqual(pkg.must_restart, 0)
Beispiel #11
0
 def test_failed_pattern_no_match(self):
     """
     Test failed_pattern with no match
     """
     conf = config.Config()
     reqs = buildreq.Requirements("")
     build.failed_pattern('line to test for failure: somepkg', conf, reqs,
                          r'(test)', 0)
     self.assertEqual(reqs.buildreqs, set())
     self.assertEqual(build.must_restart, 0)
Beispiel #12
0
 def test_simple_pattern(self):
     """
     Test simple_pattern with match. The main difference between
     simple_pattern and simple_pattern_pkgconfig is the string that is added
     to buildreq.buildreqs.
     """
     reqs = buildreq.Requirements("")
     build.simple_pattern('line to test for testpkg.xyz', r'testpkg.xyz',
                          'testpkg', reqs)
     self.assertIn('testpkg', reqs.buildreqs)
     self.assertEqual(build.must_restart, 1)
Beispiel #13
0
 def test_failed_pattern_no_buildtool_match(self):
     """
     Test failed_pattern with buildtool unset and match in failed_commands
     """
     conf = config.Config()
     reqs = buildreq.Requirements("")
     conf.setup_patterns()
     build.failed_pattern('line to test for failure: lex', conf, reqs,
                          r'(lex)', 0)
     self.assertIn('flex', reqs.buildreqs)
     self.assertEqual(build.must_restart, 1)
Beispiel #14
0
 def test_failed_pattern_no_buildtool(self):
     """
     Test failed_pattern with buildtool unset and initial match, but no
     match in failed_commands.
     """
     conf = config.Config()
     reqs = buildreq.Requirements("")
     build.failed_pattern('line to test for failure: testpkg', conf, reqs,
                          r'(test)', 0)
     self.assertEqual(reqs.buildreqs, set())
     self.assertEqual(build.must_restart, 0)
Beispiel #15
0
    def setUp(self):
        conf = config.Config()
        conf.config_opts['dev_requires_extras'] = False
        url = "http://www.testpkg.com/testpkg/pkg-1.0.tar.gz"
        reqs = buildreq.Requirements(url)
        self.specfile = specfiles.Specfile(url, '1.0', 'pkg', '2', conf, reqs)

        def mock_write(string):
            self.WRITES.append(string)

        self.specfile._write = mock_write
        self.specfile._write_strip = mock_write
        self.WRITES = []
Beispiel #16
0
 def test_scan_for_tests_perlcheck_PL(self):
     """
     Test scan_for_tests with perlcheck suite
     """
     reqs = buildreq.Requirements("")
     conf = config.Config("")
     tcontent = tarball.Content("", "", "", [], conf, "")
     listdir_backup = os.listdir
     check.os.listdir = mock_generator(['Makefile.PL'])
     conf.default_pattern = "cpan"
     check.scan_for_tests('pkgdir', conf, reqs, tcontent)
     check.os.listdir = listdir_backup
     self.assertEqual(check.tests_config, 'make TEST_VERBOSE=1 test')
Beispiel #17
0
 def test_failed_pattern_pypi(self):
     """
     Test failed_pattern with buildtool set to pypi
     """
     conf = config.Config()
     reqs = buildreq.Requirements("")
     build.failed_pattern(
         'line to test for failure: testpkg.py',
         conf,
         reqs,
         r'(testpkg)',
         0,  # verbose=0
         buildtool='pypi')
     self.assertIn('testpkg-python', reqs.buildreqs)
     self.assertEqual(build.must_restart, 1)
Beispiel #18
0
 def test_scan_for_tests_tox_requires(self):
     """
     Test scan_for_tests with tox.ini in the files list, should add several
     build requirements
     """
     reqs = buildreq.Requirements("")
     conf = config.Config("")
     tcontent = tarball.Content("", "", "", [], conf, "")
     listdir_backup = os.listdir
     check.os.listdir = mock_generator(['tox.ini'])
     check.scan_for_tests('pkgdir', conf, reqs, tcontent)
     check.os.listdir = listdir_backup
     self.assertEqual(
         reqs.buildreqs,
         set(['tox', 'pytest', 'virtualenv', 'pluggy', 'py-python']))
Beispiel #19
0
 def test_failed_pattern_ruby_table_no_match(self):
     """
     Test failed_pattern with buildtool set to ruby table but no match in
     config.gems. This should not modify anything.
     """
     conf = config.Config()
     reqs = buildreq.Requirements("")
     build.failed_pattern(
         'line to test for failure: testpkg',
         conf,
         reqs,
         r'(testpkg)',
         0,  # verbose=0
         buildtool='ruby table')
     self.assertEqual(reqs.buildreqs, set())
     self.assertEqual(build.must_restart, 0)
Beispiel #20
0
 def test_failed_pattern_maven(self):
     """
     Test failed_pattern with buildtool set to maven, but no match in
     config.maven_jars, it should just prepend 'mvn-' to the package name.
     """
     conf = config.Config()
     reqs = buildreq.Requirements("")
     build.failed_pattern(
         'line to test for failure: testpkg',
         conf,
         reqs,
         r'(testpkg)',
         0,  # verbose=0
         buildtool='maven')
     self.assertIn('mvn-testpkg', reqs.buildreqs)
     self.assertEqual(build.must_restart, 1)
Beispiel #21
0
 def test_failed_pattern_perl(self):
     """
     Test failed_pattern with buildtool set to perl
     """
     conf = config.Config('')
     reqs = buildreq.Requirements("")
     pkg = build.Build()
     pkg.failed_pattern(
         'line to test for failure: testpkg.pl',
         conf,
         reqs,
         r'(testpkg)',
         0,  # verbose=0
         buildtool='perl')
     self.assertIn('perl(testpkg)', reqs.buildreqs)
     self.assertEqual(pkg.must_restart, 1)
Beispiel #22
0
    def setUp(self):
        conf = config.Config('/download/path')
        conf.config_opts['dev_requires_extras'] = False
        url = "http://www.testpkg.com/testpkg/pkg-1.0.tar.gz"
        content = tarball.Content(url, 'pkg', '1.0', [], conf, '/tmp')
        conf.content = content
        reqs = buildreq.Requirements(url)
        self.specfile = specfiles.Specfile(url, '1.0', 'pkg', '2', conf, reqs,
                                           content)

        def mock_write(string):
            self.WRITES.append(string)

        self.specfile._write = mock_write
        self.specfile._write_strip = mock_write
        self.WRITES = []
Beispiel #23
0
    def test_scan_for_tests_cmake(self):
        """
        Test scan_for_tests with cmake suite
        """
        reqs = buildreq.Requirements("")
        conf = config.Config("")
        tcontent = tarball.Content("", "", "", [], conf, "")
        listdir_backup = os.listdir
        check.os.listdir = mock_generator(['CMakeLists.txt'])
        content = 'enable_testing'
        m_open = mock_open(read_data=content)
        with patch(self.open_name, m_open, create=True):
            conf.default_pattern = "cmake"
            check.scan_for_tests('pkgdir', conf, reqs, tcontent)

        check.os.listdir = listdir_backup
        self.assertEqual(check.tests_config, 'cd clr-build; make test')
Beispiel #24
0
    def test_scan_for_tests_perlcheck_in(self):
        """
        Test scan_for_tests with perlcheck suite via Makefile.in
        """
        reqs = buildreq.Requirements("")
        conf = config.Config("")
        tcontent = tarball.Content("", "", "", [], conf, "")
        listdir_backup = os.listdir
        check.os.listdir = mock_generator(['Makefile.in'])
        content = 'test:'
        m_open = mock_open(read_data=content)
        with patch(self.open_name, m_open, create=True):
            conf.default_pattern = "cpan"
            check.scan_for_tests('pkgdir', conf, reqs, tcontent)

        check.os.listdir = listdir_backup
        self.assertEqual(check.tests_config, 'make TEST_VERBOSE=1 test')
Beispiel #25
0
    def test_scan_for_tests_makecheck_am(self):
        """
        Test scan_for_tests with makecheck suite via Makefile.am
        """
        reqs = buildreq.Requirements("")
        conf = config.Config("")
        tcontent = tarball.Content("", "", "", [], conf, "")
        listdir_backup = os.listdir
        check.os.listdir = mock_generator(['Makefile.am'])
        m_open = mock_open()
        with patch(self.open_name, m_open, create=True):
            conf.default_pattern = "configure_ac"
            check.scan_for_tests('pkgdir', conf, reqs, tcontent)

        check.os.listdir = listdir_backup
        self.assertEqual(check.tests_config,
                         'make %{?_smp_mflags} check')
Beispiel #26
0
 def test_failed_pattern_R(self):
     """
     Test failed_pattern with buildtool set to R
     """
     conf = config.Config()
     conf.setup_patterns()
     reqs = buildreq.Requirements("")
     build.failed_pattern(
         'line to test for failure: testpkg.r',
         conf,
         reqs,
         r'(testpkg)',
         0,  # verbose=0
         buildtool='R')
     self.assertIn('R-testpkg', reqs.buildreqs)
     self.assertIn('R-testpkg', reqs.requires)
     self.assertEqual(build.must_restart, 1)
Beispiel #27
0
 def test_failed_pattern_ruby_table(self):
     """
     Test failed_pattern with buildtool set to ruby table and a match in
     config.gems
     """
     conf = config.Config()
     conf.setup_patterns()
     reqs = buildreq.Requirements("")
     build.failed_pattern(
         'line to test for failure: test/unit',
         conf,
         reqs,
         r'(test/unit)',
         0,  # verbose=0
         buildtool='ruby table')
     self.assertIn('rubygem-test-unit', reqs.buildreqs)
     self.assertEqual(build.must_restart, 1)
Beispiel #28
0
 def test_failed_pattern_ruby(self):
     """
     Test failed_pattern with buildtool set to ruby, but no match in
     config.gems, it should just prepend 'rubygem-' to the package name.
     """
     conf = config.Config('')
     reqs = buildreq.Requirements("")
     pkg = build.Build()
     pkg.failed_pattern(
         'line to test for failure: testpkg.rb',
         conf,
         reqs,
         r'(testpkg)',
         0,  # verbose=0
         buildtool='ruby')
     self.assertIn('rubygem-testpkg', reqs.buildreqs)
     self.assertEqual(pkg.must_restart, 1)
Beispiel #29
0
 def test_failed_pattern_maven_match(self):
     """
     Test failed_pattern with buildtool set to maven with a match in
     config.maven_jars. In the particular case of aether, the corresponding
     maven jar is 'mvn-aether-core'
     """
     conf = config.Config()
     conf.setup_patterns()
     reqs = buildreq.Requirements("")
     build.failed_pattern(
         'line to test for failure: aether',
         conf,
         reqs,
         r'(aether)',
         0,  # verbose=0
         buildtool='maven')
     self.assertIn('mvn-aether-core', reqs.buildreqs)
     self.assertEqual(build.must_restart, 1)
Beispiel #30
0
    def test_scan_for_tests_makecheck_in(self):
        """
        Test scan_for_tests with makecheck suite
        """
        reqs = buildreq.Requirements("")
        conf = config.Config()
        listdir_backup = os.listdir
        check.os.listdir = mock_generator(['Makefile.in'])
        content = 'check:'
        m_open = mock_open(read_data=content)
        with patch(self.open_name, m_open, create=True):
            check.buildpattern.default_pattern = "configure"
            check.scan_for_tests('pkgdir', conf, reqs)

        check.os.listdir = listdir_backup
        check.buildpattern.default_pattern = "make"
        self.assertEqual(check.tests_config,
                         'make VERBOSE=1 V=1 %{?_smp_mflags} check')