Exemplo n.º 1
0
    def test_should_apply_callback_to_one_file_when_expression_matches_one_file(self, walk):
        called_on_file = []

        def callback(absolute_file_name, relative_file_name):
            called_on_file.append(absolute_file_name)

        apply_on_files("spam", callback, "a")
        self.assertEquals(["spam/a"], called_on_file)

        walk.assert_called_with("spam")
Exemplo n.º 2
0
    def test_should_apply_callback_to_one_file_when_expression_matches_one_file(self, walk):
        called_on_file = []

        def callback(absolute_file_name, relative_file_name):
            called_on_file.append(absolute_file_name)

        apply_on_files("spam", callback, "a")
        self.assertEquals(["spam/a"], called_on_file)

        walk.assert_called_with("spam")
def package(project, logger):
    globs = project.get_mandatory_property("copy_resources_glob")
    if not globs:
        logger.warn("No resources to copy configured. Consider removing plugin.")
        return

    source = project.basedir
    target = project.expand_path("$copy_resources_target")
    logger.info("Copying resources matching '%s' from %s to %s", " ".join(globs), source, target)

    apply_on_files(source, copy_resource, globs, target, logger)
Exemplo n.º 4
0
    def test_should_pass_additional_arguments_to_closure(self, walk):
        called_on_file = []

        def callback(absolute_file_name, relative_file_name, additional_argument):
            self.assertEquals("additional argument", additional_argument)
            called_on_file.append(absolute_file_name)

        apply_on_files("spam", callback, "a", "additional argument")
        self.assertEquals(["spam/a"], called_on_file)

        walk.assert_called_with("spam")
Exemplo n.º 5
0
    def test_should_pass_additional_arguments_to_closure(self, walk):
        called_on_file = []

        def callback(absolute_file_name, relative_file_name, additional_argument):
            self.assertEquals("additional argument", additional_argument)
            called_on_file.append(absolute_file_name)

        apply_on_files("spam", callback, "a", "additional argument")
        self.assertEquals(["spam/a"], called_on_file)

        walk.assert_called_with("spam")
Exemplo n.º 6
0
def package(project, logger) :
    globs = project.get_mandatory_property("copy_root_files_glob")
    if not globs :
        logger.warn("No files to copy configured. Consider removing plugin.")
        return

    source = project.basedir
    target = project.expand_path("$copy_root_files_target")
    logger.info("Copying files matching '%s' from %s to %s", " ".join(globs), source, target)

    apply_on_files(source, copy_files, globs, target, logger)
Exemplo n.º 7
0
def filter_resources(project, logger):
    globs = project.get_mandatory_property("filter_resources_glob")
    if not globs:
        logger.warn("No resources to filter configured. Consider removing plugin.")
        return

    target = project.expand_path("$filter_resources_target")
    logger.info("Filter resources matching %s in %s", " ".join(globs), target)

    project_dict_wrapper = ProjectDictWrapper(project)

    apply_on_files(target, filter_resource, globs, project_dict_wrapper, logger)
Exemplo n.º 8
0
    def test_should_apply_callback_to_one_file_when_expression_matches_one_file(self):
        when(os).walk("spam").thenReturn([("spam", [], ["a", "b", "c"])])

        called_on_file = []

        def callback(absolute_file_name, relative_file_name):
            called_on_file.append(absolute_file_name)

        apply_on_files("spam", callback, "a")
        self.assertEquals(["spam/a"], called_on_file)

        verify(os).walk("spam")
Exemplo n.º 9
0
    def test_should_apply_callback_to_one_file_when_expression_matches_one_file(self):
        when(os).walk("spam").thenReturn([("spam", [], ["a", "b", "c"])])

        called_on_file = []

        def callback(absolute_file_name, relative_file_name):
            called_on_file.append(absolute_file_name)

        apply_on_files("spam", callback, "a")
        self.assertEquals(["spam/a"], called_on_file)

        verify(os).walk("spam")
Exemplo n.º 10
0
    def test_should_pass_additional_arguments_to_closure(self):
        when(os).walk("spam").thenReturn([("spam", [], ["a"])])

        called_on_file = []

        def callback(absolute_file_name, relative_file_name, additional_argument):
            self.assertEquals("additional argument", additional_argument)
            called_on_file.append(absolute_file_name)

        apply_on_files("spam", callback, "a", "additional argument")
        self.assertEquals(["spam/a"], called_on_file)

        verify(os).walk("spam")
Exemplo n.º 11
0
    def test_should_pass_additional_arguments_to_closure(self):
        when(os).walk("spam").thenReturn([("spam", [], ["a"])])

        called_on_file = []

        def callback(absolute_file_name, relative_file_name, additional_argument):
            self.assertEquals("additional argument", additional_argument)
            called_on_file.append(absolute_file_name)

        apply_on_files("spam", callback, "a", "additional argument")
        self.assertEquals(["spam/a"], called_on_file)

        verify(os).walk("spam")
Exemplo n.º 12
0
    def test_should_apply_callback_to_all_files_when_expression_matches_all_files(self, walk):
        absolute_file_names = []
        relative_file_names = []

        def callback(absolute_file_name, relative_file_name):
            absolute_file_names.append(absolute_file_name)
            relative_file_names.append(relative_file_name)

        apply_on_files("spam", callback, "*")
        self.assertEquals(["spam/a", "spam/b", "spam/c"], absolute_file_names)
        self.assertEquals(["a", "b", "c"], relative_file_names)

        walk.assert_called_with("spam")
Exemplo n.º 13
0
    def test_should_apply_callback_to_all_files_when_expression_matches_all_files(self, walk):
        absolute_file_names = []
        relative_file_names = []

        def callback(absolute_file_name, relative_file_name):
            absolute_file_names.append(absolute_file_name)
            relative_file_names.append(relative_file_name)

        apply_on_files("spam", callback, "*")
        self.assertEquals(["spam/a", "spam/b", "spam/c"], absolute_file_names)
        self.assertEquals(["a", "b", "c"], relative_file_names)

        walk.assert_called_with("spam")
Exemplo n.º 14
0
    def test_should_apply_callback_to_all_files_when_expression_matches_all_files(self):
        when(os).walk("spam").thenReturn([("spam", [], ["a", "b", "c"])])

        absolute_file_names = []
        relative_file_names = []

        def callback(absolute_file_name, relative_file_name):
            absolute_file_names.append(absolute_file_name)
            relative_file_names.append(relative_file_name)

        apply_on_files("spam", callback, "*")
        self.assertEquals(["spam/a", "spam/b", "spam/c"], absolute_file_names)
        self.assertEquals(["a", "b", "c"], relative_file_names)

        verify(os).walk("spam")
Exemplo n.º 15
0
    def test_should_apply_callback_to_all_files_when_expression_matches_all_files(self):
        when(os).walk("spam").thenReturn([("spam", [], ["a", "b", "c"])])

        absolute_file_names = []
        relative_file_names = []

        def callback(absolute_file_name, relative_file_name):
            absolute_file_names.append(absolute_file_name)
            relative_file_names.append(relative_file_name)

        apply_on_files("spam", callback, "*")
        self.assertEquals(["spam/a", "spam/b", "spam/c"], absolute_file_names)
        self.assertEquals(["a", "b", "c"], relative_file_names)

        verify(os).walk("spam")