예제 #1
0
    def test_no_pom_explicit(self):
        package = Package("nonexistent_pom_explicit")
        package.append_to_prep('%pom_remove_parent nonexistent_pom.xml')
        _, stderr, returncode = package.run_prep()

        self.assertEqual(returncode, 1, stderr)
        assertIn(self, "Couldn't locate ", stderr)
예제 #2
0
    def test_no_pom_explicit(self):
        package = Package("nonexistent_pom_explicit")
        package.append_to_prep('%pom_remove_parent nonexistent_pom.xml')
        _, stderr, returncode = package.run_prep()

        self.assertEqual(returncode, 1, stderr)
        assertIn(self, "Couldn't locate ", stderr)
예제 #3
0
def exec_pom_macro(line, poms_tree, want_tree=None, filename='pom.xml'):
    """
    Parameters:
        line::
            A line of spec code injected to %prep
        poms_tree::
            dictionary that maps subpackage directory paths to input poms
        want_tree::
            dictionary that maps subpackage directory paths to wanted poms
            (in want directory)
    It creates a directory structure corresponding to keys in poms_tree and
    copies pom files into it. Then it executes prep and compares altered poms
    to wanted ones from want_tree (if not specified in want_tree it is assumed
    to remain unchanged and is compared with the original pom). Returns tuple
    of rpmbuild's return value, stderr and report of differences in xml files.
    """
    DATADIR = path.join(DIRPATH, 'data', 'pom_editor')
    pack = Package('test')
    pack.append_to_prep(line)
    for destpath, sourcepath in poms_tree.items():
        pack.add_source(path.join(DATADIR, sourcepath),
                        path.join(destpath, filename))
    _, stderr, return_value = pack.run_prep()
    reports = []
    if return_value == 0:
        for filepath, pom in poms_tree.items():
            if want_tree and filepath in want_tree:
                expected_pom = path.join('want', want_tree[filepath])
            else:
                expected_pom = pom
            expected_pom = path.join(DATADIR, expected_pom)
            actual_pom = path.join(pack.buildpath, filepath, filename)
            reports.append(compare_xml_files(actual_pom, expected_pom))
    return return_value, stderr, '\n'.join(reports).strip()
예제 #4
0
 def test_usage(self):
     package = Package("usage")
     pompath = os.path.join(WORKDIR, "pom_remove_dep.xml")
     package.add_source(pompath, "pom.xml")
     package.append_to_prep('%pom_remove_dep')
     _, stderr, return_value = package.run_prep()
     self.assertEqual(return_value, 1)
     assertIn(self, "Usage: %pom_remove_dep "\
                   "[groupId]:[artifactId] [POM location]", stderr)
예제 #5
0
def exec_pom_macro(line, poms_tree, want_tree=None, filename='pom.xml'):
    """
    Parameters:
        line::
            A line of spec code injected to %prep
        poms_tree::
            dictionary that maps subpackage directory paths to input poms
        want_tree::
            dictionary that maps subpackage directory paths to wanted poms
            (in want directory)
    It creates a directory structure corresponding to keys in poms_tree and
    copies pom files into it. Then it executes prep and compares altered poms
    to wanted ones from want_tree (if not specified in want_tree it is assumed
    to remain unchanged and is compared with the original pom). Returns tuple
    of rpmbuild's return value, stderr and report of differences in xml files.
    """
    DATADIR = path.join(DIRPATH, 'data', 'pom_editor')
    pack = Package('test')
    pack.append_to_prep(line)
    for destpath, sourcepath in poms_tree.items():
        pack.add_source(path.join(DATADIR, sourcepath), path.join(destpath, filename))
    _, stderr, return_value = pack.run_prep()
    reports = []
    if return_value == 0:
        for filepath, pom in poms_tree.items():
            if want_tree and filepath in want_tree:
                expected_pom = path.join('want', want_tree[filepath])
            else:
                expected_pom = pom
            expected_pom = path.join(DATADIR, expected_pom)
            actual_pom = path.join(pack.buildpath, filepath, filename)
            reports.append(compare_xml_files(actual_pom, expected_pom))
    return return_value, stderr, '\n'.join(reports).strip()
예제 #6
0
        def test_decorated(self, *args, **kwargs):
            pompath = os.path.join(WORKDIR, pom)
            pomname = os.path.basename(pom)
            package = Package(function.__name__)
            package.add_source(pompath)
            pomsourcepath = os.path.join(package.buildpath, pomname)
            package.append_to_prep('%{command} {pom} {tail}'.format(
                command=command, pom=pomname, tail=tail))
            stdin, stderr, return_value = package.run_prep()

            function(self, stdin, stderr, return_value, pomsourcepath)
예제 #7
0
 def test_usage(self):
     package = Package("usage")
     pompath = os.path.join(WORKDIR, "pom_remove_dep.xml")
     package.add_source(pompath, "pom.xml")
     package.append_to_prep('%pom_remove_dep')
     _, stderr, return_value = package.run_prep()
     self.assertEqual(return_value, 1)
     assertIn(self, "Usage: %pom_remove_dep "\
                   "[groupId]:[artifactId] [POM location]", stderr)
예제 #8
0
        def test_decorated(self, *args, **kwargs):
            pompath = os.path.join(WORKDIR, pom)
            pomname = os.path.basename(pom)
            package = Package(function.__name__)
            package.add_source(pompath)
            pomsourcepath = os.path.join(package.buildpath, pomname)
            package.append_to_prep('%{command} {pom} {tail}'.format(command=command,
                pom=pomname, tail=tail))
            stdin, stderr, return_value = package.run_prep()

            function(self, stdin, stderr, return_value, pomsourcepath)
예제 #9
0
 def test_decorated(self):
     pack = Package(function.__name__)
     function(self, pack)
예제 #10
0
 def test_missing_jar(self):
     p = Package('test')
     p.append_to_prep("%add_maven_depmap g:a:1 this/file/doesnt/exist.jar")
     _, stderr, return_value = p.run_prep()
     self.assertEqual(1, return_value, 'bad return value')
     assertIn(self, 'file not found', stderr)
예제 #11
0
 def test_missing_jar(self):
     p = Package('test')
     p.append_to_prep("%add_maven_depmap g:a:1 this/file/doesnt/exist.jar")
     _, stderr, return_value = p.run_prep()
     self.assertEqual(1, return_value, 'bad return value')
     assertIn(self, 'file not found', stderr)