Ticket #3547: mc-3547-remove-unused-execute_with_vfs_arg-function.patch

File mc-3547-remove-unused-execute_with_vfs_arg-function.patch, 11.9 KB (added by and, 8 years ago)
  • po/mc.pot

    From 17b6cb49a13a5c3cf8e7ebb40cfdbec20431d290 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Fri, 1 Jan 2016 15:24:56 +0000
    Subject: [PATCH] remove unused execute_with_vfs_arg function
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     po/mc.pot                                 |   4 -
     src/execute.c                             |  24 ---
     src/execute.h                             |   1 -
     tests/src/Makefile.am                     |   4 -
     tests/src/execute__execute_with_vfs_arg.c | 248 ------------------------------
     5 files changed, 281 deletions(-)
     delete mode 100644 tests/src/execute__execute_with_vfs_arg.c
    
    diff --git a/po/mc.pot b/po/mc.pot
    index 7756f86..e39ccbe 100644
    a b msgstr "" 
    756756#: src/editor/editcmd.c:377 src/editor/editcmd.c:2958 src/editor/spell.c:317 
    757757#: src/editor/spell.c:553 src/editor/spell.c:561 
    758758#: tests/src/execute__common.c:145 
    759 #: tests/src/execute__execute_with_vfs_arg.c:154 
    760759msgid "Error" 
    761760msgstr "" 
    762761 
    msgstr "" 
    54655464msgid "Continue from beginning?" 
    54665465msgstr "" 
    54675466 
    5468 #: tests/src/execute__execute_with_vfs_arg.c:156 
    5469 msgid "Cannot fetch a local copy of /ftp://some.host/editme.txt" 
    5470 msgstr "" 
  • src/execute.c

    diff --git a/src/execute.c b/src/execute.c
    index c12d58c..237264b 100644
    a b execute_suspend (const gchar * event_group_name, const gchar * event_name, 
    581581} 
    582582 
    583583/* --------------------------------------------------------------------------------------------- */ 
    584  
    585 /** 
    586  * Execute command on a filename that can be on VFS. 
    587  * Errors are reported to the user. 
    588  */ 
    589  
    590 void 
    591 execute_with_vfs_arg (const char *command, const vfs_path_t * filename_vpath) 
    592 { 
    593     vfs_path_t *localcopy_vpath = NULL; 
    594     const vfs_path_t *do_execute_vpath; 
    595     time_t mtime; 
    596  
    597     if (!execute_prepare_with_vfs_arg (filename_vpath, &localcopy_vpath, &mtime)) 
    598         return; 
    599  
    600     do_execute_vpath = (localcopy_vpath == NULL) ? filename_vpath : localcopy_vpath; 
    601  
    602     do_execute (command, vfs_path_get_last_path_str (do_execute_vpath), EXECUTE_INTERNAL); 
    603  
    604     execute_cleanup_with_vfs_arg (filename_vpath, &localcopy_vpath, &mtime); 
    605 } 
    606  
    607 /* --------------------------------------------------------------------------------------------- */ 
    608584/** 
    609585 * Execute external editor or viewer. 
    610586 * 
  • src/execute.h

    diff --git a/src/execute.h b/src/execute.h
    index 56d24c5..08803de 100644
    a b gboolean execute_suspend (const gchar * event_group_name, const gchar * event_na 
    3939                          gpointer init_data, gpointer data); 
    4040 
    4141/* Execute command on a filename that can be on VFS */ 
    42 void execute_with_vfs_arg (const char *command, const vfs_path_t * filename_vpath); 
    4342void execute_external_editor_or_viewer (const char *command, const vfs_path_t * filename_vpath, 
    4443                                        long start_line); 
    4544 
  • tests/src/Makefile.am

    diff --git a/tests/src/Makefile.am b/tests/src/Makefile.am
    index 74eecf6..23928a8 100644
    a b endif 
    2626EXTRA_DIST = execute__common.c 
    2727 
    2828TESTS = \ 
    29         execute__execute_with_vfs_arg \ 
    3029        execute__execute_external_editor_or_viewer \ 
    3130        execute__execute_get_external_cmd_opts_from_config 
    3231 
    3332check_PROGRAMS = $(TESTS) 
    3433 
    35 execute__execute_with_vfs_arg_SOURCES = \ 
    36         execute__execute_with_vfs_arg.c 
    37  
    3834 
    3935execute__execute_external_editor_or_viewer_SOURCES = \ 
    4036        execute__execute_external_editor_or_viewer.c 
  • deleted file tests/src/execute__execute_with_vfs_arg.c

    diff --git a/tests/src/execute__execute_with_vfs_arg.c b/tests/src/execute__execute_with_vfs_arg.c
    deleted file mode 100644
    index 2c7733a..0000000
    + -  
    1 /* 
    2    src - tests for execute_with_vfs_arg() function 
    3  
    4    Copyright (C) 2013-2016 
    5    Free Software Foundation, Inc. 
    6  
    7    Written by: 
    8    Slava Zanko <slavazanko@gmail.com>, 2013 
    9  
    10    This file is part of the Midnight Commander. 
    11  
    12    The Midnight Commander is free software: you can redistribute it 
    13    and/or modify it under the terms of the GNU General Public License as 
    14    published by the Free Software Foundation, either version 3 of the License, 
    15    or (at your option) any later version. 
    16  
    17    The Midnight Commander is distributed in the hope that it will be useful, 
    18    but WITHOUT ANY WARRANTY; without even the implied warranty of 
    19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    20    GNU General Public License for more details. 
    21  
    22    You should have received a copy of the GNU General Public License 
    23    along with this program.  If not, see <http://www.gnu.org/licenses/>. 
    24  */ 
    25  
    26 #define TEST_SUITE_NAME "/src" 
    27  
    28 #include "tests/mctest.h" 
    29  
    30 #include "execute__common.c" 
    31  
    32 /* --------------------------------------------------------------------------------------------- */ 
    33  
    34 /* @DataSource("the_file_is_local_ds") */ 
    35 /* *INDENT-OFF* */ 
    36 static const struct the_file_is_local_ds 
    37 { 
    38     const char *input_path; 
    39 } the_file_is_local_ds[] = 
    40 { 
    41     { 
    42         NULL, 
    43     }, 
    44     { 
    45         "/blabla", 
    46     }, 
    47 }; 
    48 /* *INDENT-ON* */ 
    49  
    50 /* @Test(dataSource = "the_file_is_local_ds") */ 
    51 /* *INDENT-OFF* */ 
    52 START_PARAMETRIZED_TEST (the_file_is_local, the_file_is_local_ds) 
    53 /* *INDENT-ON* */ 
    54 { 
    55     /* given */ 
    56     vfs_path_t *filename_vpath; 
    57     filename_vpath = vfs_path_from_str (data->input_path); 
    58  
    59     vfs_file_is_local__return_value = TRUE; 
    60  
    61     /* when */ 
    62     execute_with_vfs_arg ("cmd_for_local_file", filename_vpath); 
    63  
    64     /* then */ 
    65     mctest_assert_str_eq (do_execute__lc_shell__captured, "cmd_for_local_file"); 
    66     mctest_assert_str_eq (do_execute__command__captured, data->input_path); 
    67  
    68     mctest_assert_int_eq (vfs_file_is_local__vpath__captured->len, 1); 
    69     { 
    70         const vfs_path_t *tmp_vpath; 
    71  
    72         tmp_vpath = (data->input_path == NULL) ? vfs_get_raw_current_dir () : filename_vpath; 
    73         mctest_assert_int_eq (vfs_path_equal 
    74                               (g_ptr_array_index (vfs_file_is_local__vpath__captured, 0), 
    75                                tmp_vpath), TRUE); 
    76     } 
    77     mctest_assert_int_eq (do_execute__flags__captured, EXECUTE_INTERNAL); 
    78     fail_unless (mc_getlocalcopy__pathname_vpath__captured == NULL, 
    79                  "\nFunction mc_getlocalcopy() shouldn't be called!"); 
    80  
    81     vfs_path_free (filename_vpath); 
    82 } 
    83 /* *INDENT-OFF* */ 
    84 END_PARAMETRIZED_TEST 
    85 /* *INDENT-ON* */ 
    86  
    87 /* --------------------------------------------------------------------------------------------- */ 
    88  
    89 /* @Test */ 
    90 /* *INDENT-OFF* */ 
    91 START_TEST (the_file_is_remote_but_empty) 
    92 /* *INDENT-ON* */ 
    93 { 
    94     /* given */ 
    95     vfs_path_t *filename_vpath; 
    96     filename_vpath = NULL; 
    97  
    98     vfs_file_is_local__return_value = FALSE; 
    99  
    100     /* when */ 
    101     execute_with_vfs_arg ("cmd_for_remote_file", filename_vpath); 
    102  
    103     /* then */ 
    104     mctest_assert_str_eq (do_execute__lc_shell__captured, NULL); 
    105     mctest_assert_str_eq (do_execute__command__captured, NULL); 
    106  
    107     mctest_assert_int_eq (vfs_file_is_local__vpath__captured->len, 2); 
    108  
    109     mctest_assert_int_eq (vfs_path_equal 
    110                           (g_ptr_array_index (vfs_file_is_local__vpath__captured, 0), 
    111                            vfs_get_raw_current_dir ()), TRUE); 
    112     fail_unless (g_ptr_array_index (vfs_file_is_local__vpath__captured, 1) == NULL, 
    113                  "\nParameter for second call to vfs_file_is_local() should be NULL!"); 
    114     fail_unless (mc_getlocalcopy__pathname_vpath__captured == NULL, 
    115                  "\nFunction mc_getlocalcopy() shouldn't be called!"); 
    116  
    117     vfs_path_free (filename_vpath); 
    118 } 
    119 /* *INDENT-OFF* */ 
    120 END_TEST 
    121 /* *INDENT-ON* */ 
    122  
    123 /* --------------------------------------------------------------------------------------------- */ 
    124  
    125 /* @Test */ 
    126 /* *INDENT-OFF* */ 
    127 START_TEST (the_file_is_remote_fail_to_create_local_copy) 
    128 /* *INDENT-ON* */ 
    129 { 
    130     /* given */ 
    131     vfs_path_t *filename_vpath; 
    132  
    133     filename_vpath = vfs_path_from_str ("/ftp://some.host/editme.txt"); 
    134  
    135     vfs_file_is_local__return_value = FALSE; 
    136     mc_getlocalcopy__return_value = NULL; 
    137  
    138     /* when */ 
    139     execute_with_vfs_arg ("cmd_for_remote_file", filename_vpath); 
    140  
    141     /* then */ 
    142     mctest_assert_str_eq (do_execute__lc_shell__captured, NULL); 
    143     mctest_assert_str_eq (do_execute__command__captured, NULL); 
    144  
    145     mctest_assert_int_eq (vfs_file_is_local__vpath__captured->len, 1); 
    146  
    147     mctest_assert_int_eq (vfs_path_equal 
    148                           (g_ptr_array_index (vfs_file_is_local__vpath__captured, 0), 
    149                            filename_vpath), TRUE); 
    150  
    151     mctest_assert_int_eq (vfs_path_equal 
    152                           (mc_getlocalcopy__pathname_vpath__captured, filename_vpath), TRUE); 
    153  
    154     mctest_assert_str_eq (message_title__captured, _("Error")); 
    155     mctest_assert_str_eq (message_text__captured, 
    156                           _("Cannot fetch a local copy of /ftp://some.host/editme.txt")); 
    157  
    158  
    159     vfs_path_free (filename_vpath); 
    160 } 
    161 /* *INDENT-OFF* */ 
    162 END_TEST 
    163 /* *INDENT-ON* */ 
    164  
    165 /* --------------------------------------------------------------------------------------------- */ 
    166  
    167 /* @Test */ 
    168 /* *INDENT-OFF* */ 
    169 START_TEST (the_file_is_remote) 
    170 /* *INDENT-ON* */ 
    171 { 
    172     /* given */ 
    173     vfs_path_t *filename_vpath, *local_vpath, *local_vpath_should_be_freeing; 
    174  
    175     filename_vpath = vfs_path_from_str ("/ftp://some.host/editme.txt"); 
    176     local_vpath = vfs_path_from_str ("/tmp/blabla-editme.txt"); 
    177     local_vpath_should_be_freeing = vfs_path_clone (local_vpath); 
    178  
    179     vfs_file_is_local__return_value = FALSE; 
    180     mc_getlocalcopy__return_value = local_vpath_should_be_freeing; 
    181  
    182     /* when */ 
    183     execute_with_vfs_arg ("cmd_for_remote_file", filename_vpath); 
    184  
    185     /* then */ 
    186     mctest_assert_str_eq (do_execute__lc_shell__captured, "cmd_for_remote_file"); 
    187     mctest_assert_str_eq (do_execute__command__captured, "/tmp/blabla-editme.txt"); 
    188  
    189     mctest_assert_int_eq (vfs_file_is_local__vpath__captured->len, 1); 
    190  
    191     mctest_assert_int_eq (vfs_path_equal 
    192                           (g_ptr_array_index (vfs_file_is_local__vpath__captured, 0), 
    193                            filename_vpath), TRUE); 
    194  
    195     mctest_assert_int_eq (vfs_path_equal 
    196                           (mc_getlocalcopy__pathname_vpath__captured, filename_vpath), TRUE); 
    197  
    198     mctest_assert_int_eq (mc_stat__vpath__captured->len, 2); 
    199  
    200     mctest_assert_int_eq (vfs_path_equal 
    201                           (g_ptr_array_index (mc_stat__vpath__captured, 0), local_vpath), TRUE); 
    202     mctest_assert_int_eq (vfs_path_equal 
    203                           (g_ptr_array_index (mc_stat__vpath__captured, 0), 
    204                            g_ptr_array_index (mc_stat__vpath__captured, 1)), TRUE); 
    205  
    206     mctest_assert_int_eq (vfs_path_equal 
    207                           (mc_ungetlocalcopy__pathname_vpath__captured, filename_vpath), TRUE); 
    208  
    209     mctest_assert_int_eq (vfs_path_equal (mc_ungetlocalcopy__local_vpath__captured, local_vpath), 
    210                           TRUE); 
    211  
    212     vfs_path_free (filename_vpath); 
    213     vfs_path_free (local_vpath); 
    214 } 
    215 /* *INDENT-OFF* */ 
    216 END_TEST 
    217 /* *INDENT-ON* */ 
    218  
    219 /* --------------------------------------------------------------------------------------------- */ 
    220  
    221 int 
    222 main (void) 
    223 { 
    224     int number_failed; 
    225  
    226     Suite *s = suite_create (TEST_SUITE_NAME); 
    227     TCase *tc_core = tcase_create ("Core"); 
    228     SRunner *sr; 
    229  
    230     tcase_add_checked_fixture (tc_core, setup, teardown); 
    231  
    232     /* Add new tests here: *************** */ 
    233     mctest_add_parameterized_test (tc_core, the_file_is_local, the_file_is_local_ds); 
    234     tcase_add_test (tc_core, the_file_is_remote_but_empty); 
    235     tcase_add_test (tc_core, the_file_is_remote_fail_to_create_local_copy); 
    236     tcase_add_test (tc_core, the_file_is_remote); 
    237     /* *********************************** */ 
    238  
    239     suite_add_tcase (s, tc_core); 
    240     sr = srunner_create (s); 
    241     srunner_set_log (sr, "execute__execute_with_vfs_arg.log"); 
    242     srunner_run_all (sr, CK_ENV); 
    243     number_failed = srunner_ntests_failed (sr); 
    244     srunner_free (sr); 
    245     return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 
    246 } 
    247  
    248 /* --------------------------------------------------------------------------------------------- */