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 c2513961c96d725ef96f96a3e170a1dbcd9531ca

Fix some tests on Windows and Wine
Two command-line completion tests and one related to output
processing.
Author: xaizek
Author date (UTC): 2016-07-16 11:02
Committer name: xaizek
Committer date (UTC): 2016-07-16 11:38
Parent(s): f90c7fb18bd0780ce9848eeb9e7eb5513c7a6801
Signing key: 99DC5E4DB05F6BE2
Tree: 1721b1fb1b79dd3406e3088f22d1c66c00808658
File Lines added Lines deleted
tests/misc/cmdline_completion.c 12 11
tests/utils/process_cmd_output.c 20 1
File tests/misc/cmdline_completion.c changed (mode: 100644) (index bba9a62d9..463bc4e1e)
... ... TEST(abbreviations)
457 457 vle_abbr_reset(); vle_abbr_reset();
458 458 } }
459 459
460 #if defined(_WIN32) && !defined(_WIN64)
461 #define WPRINTF_MBSTR L"S"
462 #else
463 #define WPRINTF_MBSTR L"s"
464 #endif
465
466 460 TEST(bang_exec_completion) TEST(bang_exec_completion)
467 461 { {
468 462 char *const original_path_env = strdup(env_get("PATH")); char *const original_path_env = strdup(env_get("PATH"));
 
... ... TEST(bang_exec_completion)
476 470
477 471 create_executable("exec-for-completion" EXE_SUFFIX); create_executable("exec-for-completion" EXE_SUFFIX);
478 472
479 prepare_for_line_completion(L"!exec-for-com" EXE_SUFFIXW);
473 prepare_for_line_completion(L"!exec-for-com");
480 474 assert_success(line_completion(&stats)); assert_success(line_completion(&stats));
481 475 assert_wstring_equal(L"!exec-for-completion" EXE_SUFFIXW, stats.line); assert_wstring_equal(L"!exec-for-completion" EXE_SUFFIXW, stats.line);
482 476
 
... ... TEST(bang_abs_path_completion)
492 486 wchar_t input[PATH_MAX]; wchar_t input[PATH_MAX];
493 487 wchar_t cmd[PATH_MAX]; wchar_t cmd[PATH_MAX];
494 488 char cwd[PATH_MAX]; char cwd[PATH_MAX];
489 wchar_t *wcwd;
495 490
496 491 restore_cwd(saved_cwd); restore_cwd(saved_cwd);
497 492 saved_cwd = save_cwd(); saved_cwd = save_cwd();
498 493 assert_success(chdir(SANDBOX_PATH)); assert_success(chdir(SANDBOX_PATH));
499 494
500 495 assert_true(get_cwd(cwd, sizeof(cwd)) == cwd); assert_true(get_cwd(cwd, sizeof(cwd)) == cwd);
496 wcwd = to_wide(cwd);
501 497
502 498 create_executable("exec-for-completion" EXE_SUFFIX); create_executable("exec-for-completion" EXE_SUFFIX);
503 499
504 500 vifm_swprintf(input, ARRAY_LEN(input), vifm_swprintf(input, ARRAY_LEN(input),
505 L"!%" WPRINTF_MBSTR L"/exec-for-compl", cwd);
501 L"!%" WPRINTF_WSTR L"/exec-for-compl", wcwd);
506 502 vifm_swprintf(cmd, ARRAY_LEN(cmd), vifm_swprintf(cmd, ARRAY_LEN(cmd),
507 L"!%" WPRINTF_MBSTR L"/exec-for-completion" EXE_SUFFIXW, cwd);
503 L"!%" WPRINTF_WSTR L"/exec-for-completion" EXE_SUFFIXW, wcwd);
508 504
509 505 prepare_for_line_completion(input); prepare_for_line_completion(input);
510 506 assert_success(line_completion(&stats)); assert_success(line_completion(&stats));
 
... ... TEST(bang_abs_path_completion)
513 509 assert_int_equal(2, vle_compl_get_count()); assert_int_equal(2, vle_compl_get_count());
514 510
515 511 assert_success(unlink("exec-for-completion" EXE_SUFFIX)); assert_success(unlink("exec-for-completion" EXE_SUFFIX));
516 }
517 512
518 #undef WPRINTF_MBSTR
513 free(wcwd);
514 }
519 515
520 516 TEST(tilde_is_completed_after_emark) TEST(tilde_is_completed_after_emark)
521 517 { {
 
... ... TEST(find_completion)
650 646 { {
651 647 prepare_for_line_completion(L"find -"); prepare_for_line_completion(L"find -");
652 648 assert_success(line_completion(&stats)); assert_success(line_completion(&stats));
649 #ifdef _WIN32
650 /* Windows escaping code doesn't prepend "./". */
651 assert_wstring_equal(L"find -", stats.line);
652 #else
653 653 assert_wstring_equal(L"find ./-", stats.line); assert_wstring_equal(L"find ./-", stats.line);
654 #endif
654 655
655 656 prepare_for_line_completion(L"find .."); prepare_for_line_completion(L"find ..");
656 657 assert_success(line_completion(&stats)); assert_success(line_completion(&stats));
File tests/utils/process_cmd_output.c changed (mode: 100644) (index 094c2b804..619171c55)
5 5 #include <stdio.h> /* fclose() fopen() fprintf() */ #include <stdio.h> /* fclose() fopen() fprintf() */
6 6
7 7 #include "../../src/cfg/config.h" #include "../../src/cfg/config.h"
8 #include "../../src/utils/fs.h"
8 9 #include "../../src/utils/str.h" #include "../../src/utils/str.h"
9 10 #include "../../src/utils/utils.h" #include "../../src/utils/utils.h"
11 #include "../../src/cmd_completion.h"
10 12
11 13 static void line_handler(const char line[], void *arg); static void line_handler(const char line[], void *arg);
14 static int cat_is_available(void);
12 15
13 16 static int nlines; static int nlines;
14 17
15 TEST(check_null_separation)
18 TEST(check_null_separation, IF(cat_is_available))
16 19 { {
20 char *saved_cwd;
21
17 22 FILE *const f = fopen(SANDBOX_PATH "/list", "w"); FILE *const f = fopen(SANDBOX_PATH "/list", "w");
18 23 fprintf(f, "%s%c", SANDBOX_PATH "/a\nb", '\0'); fprintf(f, "%s%c", SANDBOX_PATH "/a\nb", '\0');
19 24 fclose(f); fclose(f);
20 25
26 saved_cwd = save_cwd();
27
21 28 assert_success(chdir(SANDBOX_PATH)); assert_success(chdir(SANDBOX_PATH));
22 29
30 #ifndef _WIN32
23 31 replace_string(&cfg.shell, "/bin/sh"); replace_string(&cfg.shell, "/bin/sh");
32 #else
33 replace_string(&cfg.shell, "cmd");
34 #endif
24 35 stats_update_shell_type(cfg.shell); stats_update_shell_type(cfg.shell);
25 36
26 37 nlines = 0; nlines = 0;
 
... ... TEST(check_null_separation)
32 43 update_string(&cfg.shell, NULL); update_string(&cfg.shell, NULL);
33 44
34 45 assert_success(unlink("list")); assert_success(unlink("list"));
46
47 restore_cwd(saved_cwd);
35 48 } }
36 49
37 50 static void static void
 
... ... line_handler(const char line[], void *arg)
40 53 ++nlines; ++nlines;
41 54 } }
42 55
56 static int
57 cat_is_available(void)
58 {
59 return external_command_exists("cat");
60 }
61
43 62 /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
44 63 /* vim: set cinoptions+=t0 filetype=c : */ /* vim: set cinoptions+=t0 filetype=c : */
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