xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit f64bad01f75c89bc8f17ce8153ebba1b58ae6d3b

Simplify tests/misc/running.c
Provide one function for registering associations instead of 3.
Author: xaizek
Author date (UTC): 2025-07-14 07:56
Committer name: xaizek
Committer date (UTC): 2025-07-14 07:56
Parent(s): f44b21ad45ff7561cbe24bb91d048ef4ef3cbadf
Signing key: 99DC5E4DB05F6BE2
Tree: ba71aba3209a00e23dce3e5779b5de865e46e23a
File Lines added Lines deleted
tests/misc/running.c 9 27
File tests/misc/running.c changed (mode: 100644) (index 7b5fcd0ea..88d8a0d6a)
28 28 static int prog_exists(const char name[]); static int prog_exists(const char name[]);
29 29 static void start_use_script(void); static void start_use_script(void);
30 30 static void stop_use_script(void); static void stop_use_script(void);
31 static void assoc_a(char macro);
32 static void assoc_b(char macro);
33 static void assoc_common(void);
31 static void assoc_script(const char pattern[], const char param[], char macro);
34 32
35 33 static char cwd[PATH_MAX + 1]; static char cwd[PATH_MAX + 1];
36 34 static char script_path[PATH_MAX + 1]; static char script_path[PATH_MAX + 1];
 
... ... TEST(selection_uses_vim_on_all_undefs, IF(not_windows))
215 213 TEST(selection_uses_vim_on_at_least_one_undef_non_current, IF(not_windows)) TEST(selection_uses_vim_on_at_least_one_undef_non_current, IF(not_windows))
216 214 { {
217 215 start_use_script(); start_use_script();
218 assoc_a('c');
216 assoc_script("{a}", "a", 'c');
219 217
220 218 rn_open(&lwin, FHE_NO_RUN); rn_open(&lwin, FHE_NO_RUN);
221 219
 
... ... TEST(selection_uses_vim_on_at_least_one_undef_non_current, IF(not_windows))
231 229 TEST(selection_uses_vim_on_at_least_one_undef_current, IF(not_windows)) TEST(selection_uses_vim_on_at_least_one_undef_current, IF(not_windows))
232 230 { {
233 231 start_use_script(); start_use_script();
234 assoc_b('c');
232 assoc_script("{b}", "b", 'c');
235 233
236 234 rn_open(&lwin, FHE_NO_RUN); rn_open(&lwin, FHE_NO_RUN);
237 235
 
... ... TEST(selection_uses_vim_on_at_least_one_undef_current, IF(not_windows))
247 245 TEST(selection_uses_common_handler, IF(not_windows)) TEST(selection_uses_common_handler, IF(not_windows))
248 246 { {
249 247 start_use_script(); start_use_script();
250 assoc_common();
248 assoc_script("{a,b}", "common", 'f');
251 249
252 250 rn_open(&lwin, FHE_NO_RUN); rn_open(&lwin, FHE_NO_RUN);
253 251
 
... ... TEST(selection_uses_common_handler, IF(not_windows))
263 261 TEST(selection_is_incompatible, IF(not_windows)) TEST(selection_is_incompatible, IF(not_windows))
264 262 { {
265 263 start_use_script(); start_use_script();
266 assoc_a('c');
267 assoc_b('f');
264 assoc_script("{a}", "a", 'c');
265 assoc_script("{b}", "b", 'f');
268 266
269 267 rn_open(&lwin, FHE_NO_RUN); rn_open(&lwin, FHE_NO_RUN);
270 268
 
... ... stop_use_script(void)
672 670 } }
673 671
674 672 static void static void
675 assoc_a(char macro)
673 assoc_script(const char pattern[], const char param[], char macro)
676 674 { {
677 675 char cmd[PATH_MAX + 1]; char cmd[PATH_MAX + 1];
678 snprintf(cmd, sizeof(cmd), "%s a %%%c", script_path, macro);
679 assoc_programs("{a}", cmd, 0, 0);
680 }
681
682 static void
683 assoc_b(char macro)
684 {
685 char cmd[PATH_MAX + 1];
686 snprintf(cmd, sizeof(cmd), "%s b %%%c", script_path, macro);
687 assoc_programs("{b}", cmd, 0, 0);
688 }
689
690 static void
691 assoc_common(void)
692 {
693 char cmd[PATH_MAX + 1];
694 snprintf(cmd, sizeof(cmd), "%s common %%f", script_path);
695 assoc_programs("{a,b}", cmd, 0, 0);
676 snprintf(cmd, sizeof(cmd), "%s %s %%%c", script_path, param, macro);
677 assoc_programs(pattern, cmd, 0, 0);
696 678 } }
697 679
698 680 /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master