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 53c4d2f904d981f914cf1340c7b9876bb2e8ee5e

Improve response checks in tests/fileops/put_files
Don't just go by the change of the number of options, which is
unreliable.
Author: xaizek
Author date (UTC): 2026-03-13 17:43
Committer name: xaizek
Committer date (UTC): 2026-03-13 17:43
Parent(s): 7cd6cc306071743fd5c64513bec0a10ebe1a73ac
Signing key: 99DC5E4DB05F6BE2
Tree: 5f86773e3d3f32b77c9dec91dfedcc1eea76fc68
File Lines added Lines deleted
tests/fileops/put_files.c 27 12
File tests/fileops/put_files.c changed (mode: 100644) (index 23736a889..a015c918d)
... ... static char options_prompt_rename(const custom_prompt_t *details);
28 28 static char options_prompt_rename_rec(const custom_prompt_t *details); static char options_prompt_rename_rec(const custom_prompt_t *details);
29 29 static char options_prompt_overwrite(const custom_prompt_t *details); static char options_prompt_overwrite(const custom_prompt_t *details);
30 30 static char options_prompt_abort(const custom_prompt_t *details); static char options_prompt_abort(const custom_prompt_t *details);
31 static char options_prompt_abort_and_record(const custom_prompt_t *details);
31 32 static char options_prompt_skip_all(const custom_prompt_t *details); static char options_prompt_skip_all(const custom_prompt_t *details);
32 33 static char options_prompt_merge(const custom_prompt_t *details); static char options_prompt_merge(const custom_prompt_t *details);
33 34 static char options_prompt_merge_no_overwrite(const custom_prompt_t *details); static char options_prompt_merge_no_overwrite(const custom_prompt_t *details);
 
... ... static void parent_overwrite_with_put(int move);
38 39 static void double_clash_with_put(int move); static void double_clash_with_put(int move);
39 40
40 41 static fo_prompt_cb rename_cb; static fo_prompt_cb rename_cb;
41 static int options_count;
42 42 static int merge_prompt_count; static int merge_prompt_count;
43 43 static int yes_prompt_count; static int yes_prompt_count;
44 44 static int no_prompt_count; static int no_prompt_count;
45 static char response_options[32];
45 46
46 47 static char *saved_cwd; static char *saved_cwd;
47 48
 
... ... TEST(show_merge_all_option_if_paths_include_dir)
589 590 create_file(SANDBOX_PATH "/dir/b"); create_file(SANDBOX_PATH "/dir/b");
590 591 create_dir(SANDBOX_PATH "/dir/sub"); create_dir(SANDBOX_PATH "/dir/sub");
591 592
592 fops_init(&line_prompt, &options_prompt_abort);
593 fops_init(&line_prompt, &options_prompt_abort_and_record);
593 594
594 595 make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/a", saved_cwd); make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/a", saved_cwd);
595 596 assert_success(regs_append('a', path)); assert_success(regs_append('a', path));
596 597 make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/b", saved_cwd); make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/b", saved_cwd);
597 598 assert_success(regs_append('a', path)); assert_success(regs_append('a', path));
598 599
599 options_count = 0;
600 response_options[0] = '\0';
600 601 (void)fops_put(&lwin, -1, 'a', 0, /*deep=*/0); (void)fops_put(&lwin, -1, 'a', 0, /*deep=*/0);
601 assert_int_equal(8, options_count);
602 assert_string_doesnt_contain("M", response_options);
602 603
603 604 restore_cwd(saved_cwd); restore_cwd(saved_cwd);
604 605 saved_cwd = save_cwd(); saved_cwd = save_cwd();
 
... ... TEST(show_merge_all_option_if_paths_include_dir)
606 607 make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/sub", saved_cwd); make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/sub", saved_cwd);
607 608 assert_success(regs_append('a', path)); assert_success(regs_append('a', path));
608 609
609 options_count = 0;
610 response_options[0] = '\0';
610 611 (void)fops_put(&lwin, -1, 'a', 0, /*deep=*/0); (void)fops_put(&lwin, -1, 'a', 0, /*deep=*/0);
611 assert_int_equal(9, options_count);
612 assert_string_contains("M", response_options);
612 613
613 614 restore_cwd(saved_cwd); restore_cwd(saved_cwd);
614 615 saved_cwd = save_cwd(); saved_cwd = save_cwd();
 
... ... TEST(no_merge_options_on_putting_links)
630 631 create_dir(SANDBOX_PATH "/dir"); create_dir(SANDBOX_PATH "/dir");
631 632 create_dir(SANDBOX_PATH "/dir/sub"); create_dir(SANDBOX_PATH "/dir/sub");
632 633
633 fops_init(&line_prompt, &options_prompt_abort);
634 fops_init(&line_prompt, &options_prompt_abort_and_record);
634 635
635 636 make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/sub", saved_cwd); make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/sub", saved_cwd);
636 637 assert_success(regs_append('a', path)); assert_success(regs_append('a', path));
637 638
638 options_count = 0;
639 response_options[0] = '\0';
639 640 (void)fops_put_links(&lwin, 'a', 0); (void)fops_put_links(&lwin, 'a', 0);
640 assert_int_equal(7, options_count);
641 assert_string_doesnt_contain("m", response_options);
642 assert_string_doesnt_contain("M", response_options);
641 643
642 644 restore_cwd(saved_cwd); restore_cwd(saved_cwd);
643 645 saved_cwd = save_cwd(); saved_cwd = save_cwd();
 
... ... options_prompt_overwrite(const custom_prompt_t *details)
841 843
842 844 static char static char
843 845 options_prompt_abort(const custom_prompt_t *details) options_prompt_abort(const custom_prompt_t *details)
846 {
847 return '\x03';
848 }
849
850 static char
851 options_prompt_abort_and_record(const custom_prompt_t *details)
844 852 { {
845 853 const response_variant *variants = details->variants; const response_variant *variants = details->variants;
846 854
847 options_count = 0;
855 int options_count = 0;
848 856 while(variants->key != '\0') while(variants->key != '\0')
849 857 { {
850 ++options_count;
851 ++variants;
858 if(options_count + 1 == sizeof(response_options))
859 {
860 assert_fail("Can't fit all prompt options!");
861 break;
862 }
863
864 response_options[options_count++] = (variants++)->key;
852 865 } }
853 866
867 response_options[options_count] = '\0';
868
854 869 return '\x03'; return '\x03';
855 870 } }
856 871
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