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 2018d23bb31216c70a9f64f3326e5a7957a934c0

Add assoc_{programs,viewers}() to test-utils
This makes utilities from filetype test suite public.
Author: xaizek
Author date (UTC): 2025-07-14 07:49
Committer name: xaizek
Committer date (UTC): 2025-07-14 07:49
Parent(s): e40063483ee87e083cb684198a8ac590169054f1
Signing key: 99DC5E4DB05F6BE2
Tree: 830a9dc33cd23a1d7f8170184dbe2253d52c582d
File Lines added Lines deleted
tests/filetype/classes.c 6 5
tests/filetype/description.c 6 5
tests/filetype/filetype.c 20 18
tests/filetype/filextype.c 10 9
tests/filetype/find_program.c 4 3
tests/filetype/regexps.c 3 2
tests/filetype/test.c 0 23
tests/filetype/test.h 0 7
tests/filetype/viewers.c 12 10
tests/test-support/test-utils.c 23 0
tests/test-support/test-utils.h 7 0
File tests/filetype/classes.c changed (mode: 100644) (index af21ce4fc..1a65ec38c)
2 2
3 3 #include <stdlib.h> #include <stdlib.h>
4 4
5 #include <test-utils.h>
6
5 7 #include "../../src/filetype.h" #include "../../src/filetype.h"
6 8 #include "../../src/status.h" #include "../../src/status.h"
7 #include "test.h"
8 9
9 10 TEST(enumeration) TEST(enumeration)
10 11 { {
11 12 const char *prog_cmd; const char *prog_cmd;
12 13
13 set_programs("*.[ch]", "c file", 0, 0);
14 assoc_programs("*.[ch]", "c file", 0, 0);
14 15
15 16 assert_true((prog_cmd = ft_get_program("main.cpp")) == NULL); assert_true((prog_cmd = ft_get_program("main.cpp")) == NULL);
16 17 assert_true((prog_cmd = ft_get_program("main.hpp")) == NULL); assert_true((prog_cmd = ft_get_program("main.hpp")) == NULL);
 
... ... TEST(negation_with_emark)
26 27 { {
27 28 const char *prog_cmd; const char *prog_cmd;
28 29
29 set_programs("*.[!ch]", "not c file", 0, 0);
30 assoc_programs("*.[!ch]", "not c file", 0, 0);
30 31
31 32 assert_false((prog_cmd = ft_get_program("main.c")) != NULL); assert_false((prog_cmd = ft_get_program("main.c")) != NULL);
32 33 assert_false((prog_cmd = ft_get_program("main.h")) != NULL); assert_false((prog_cmd = ft_get_program("main.h")) != NULL);
 
... ... TEST(negation_with_hat)
39 40 { {
40 41 const char *prog_cmd; const char *prog_cmd;
41 42
42 set_programs("*.[^ch]", "not c file", 0, 0);
43 assoc_programs("*.[^ch]", "not c file", 0, 0);
43 44
44 45 assert_false((prog_cmd = ft_get_program("main.c")) != NULL); assert_false((prog_cmd = ft_get_program("main.c")) != NULL);
45 46 assert_false((prog_cmd = ft_get_program("main.h")) != NULL); assert_false((prog_cmd = ft_get_program("main.h")) != NULL);
 
... ... TEST(ranges)
52 53 { {
53 54 const char *prog_cmd; const char *prog_cmd;
54 55
55 set_programs("*.[0-9]", "part file", 0, 0);
56 assoc_programs("*.[0-9]", "part file", 0, 0);
56 57
57 58 assert_false((prog_cmd = ft_get_program("main.A")) != NULL); assert_false((prog_cmd = ft_get_program("main.A")) != NULL);
58 59
File tests/filetype/description.c changed (mode: 100644) (index a8bc08798..e489ee95d)
2 2
3 3 #include <stdlib.h> #include <stdlib.h>
4 4
5 #include <test-utils.h>
6
5 7 #include "../../src/filetype.h" #include "../../src/filetype.h"
6 8 #include "../../src/status.h" #include "../../src/status.h"
7 #include "test.h"
8 9
9 10 TEST(one_pattern) TEST(one_pattern)
10 11 { {
11 12 assoc_records_t ft; assoc_records_t ft;
12 13
13 set_programs("*.tar", "{description} tar prog", 0, 0);
14 assoc_programs("*.tar", "{description} tar prog", 0, 0);
14 15
15 16 ft = ft_get_all_programs("file.version.tar"); ft = ft_get_all_programs("file.version.tar");
16 17 assert_int_equal(1, ft.count); assert_int_equal(1, ft.count);
 
... ... TEST(double_comma_in_description)
25 26 { {
26 27 assoc_records_t ft; assoc_records_t ft;
27 28
28 set_programs("*.tar", "{description,,is,,here} tar prog", 0, 0);
29 assoc_programs("*.tar", "{description,,is,,here} tar prog", 0, 0);
29 30
30 31 ft = ft_get_all_programs("file.version.tar"); ft = ft_get_all_programs("file.version.tar");
31 32 assert_int_equal(1, ft.count); assert_int_equal(1, ft.count);
 
... ... TEST(two_patterns)
38 39 { {
39 40 assoc_records_t ft; assoc_records_t ft;
40 41
41 set_programs("*.tar,*.zip", "{archives} prog", 0, 0);
42 assoc_programs("*.tar,*.zip", "{archives} prog", 0, 0);
42 43
43 44 { {
44 45 ft = ft_get_all_programs("file.version.tar"); ft = ft_get_all_programs("file.version.tar");
 
... ... TEST(two_programs)
65 66 { {
66 67 assoc_records_t ft; assoc_records_t ft;
67 68
68 set_programs("*.tar", "{rar} rarprog, {zip} zipprog", 0, 0);
69 assoc_programs("*.tar", "{rar} rarprog, {zip} zipprog", 0, 0);
69 70
70 71 ft = ft_get_all_programs("a.tar"); ft = ft_get_all_programs("a.tar");
71 72
File tests/filetype/filetype.c changed (mode: 100644) (index 6bb5680d2..116cd35ca)
2 2
3 3 #include <stdlib.h> #include <stdlib.h>
4 4
5 #include <test-utils.h>
6
5 7 #include "../../src/int/file_magic.h" #include "../../src/int/file_magic.h"
6 8 #include "../../src/filetype.h" #include "../../src/filetype.h"
7 9 #include "../../src/status.h" #include "../../src/status.h"
 
... ... TEST(one_pattern)
12 14 { {
13 15 const char *prog_cmd; const char *prog_cmd;
14 16
15 set_programs("*.tar", "tar prog", 0, 0);
17 assoc_programs("*.tar", "tar prog", 0, 0);
16 18
17 19 assert_true((prog_cmd = ft_get_program("file.version.tar")) != NULL); assert_true((prog_cmd = ft_get_program("file.version.tar")) != NULL);
18 20 assert_string_equal("tar prog", prog_cmd); assert_string_equal("tar prog", prog_cmd);
 
... ... TEST(many_pattern)
22 24 { {
23 25 const char *prog_cmd; const char *prog_cmd;
24 26
25 set_programs("*.tar", "tar prog", 0, 0);
26 set_programs("*.tar.gz", "tar.gz prog", 0, 0);
27 assoc_programs("*.tar", "tar prog", 0, 0);
28 assoc_programs("*.tar.gz", "tar.gz prog", 0, 0);
27 29
28 30 assert_true((prog_cmd = ft_get_program("file.version.tar.gz")) != NULL); assert_true((prog_cmd = ft_get_program("file.version.tar.gz")) != NULL);
29 31 assert_string_equal("tar.gz prog", prog_cmd); assert_string_equal("tar.gz prog", prog_cmd);
 
... ... TEST(many_filepattern)
33 35 { {
34 36 const char *prog_cmd; const char *prog_cmd;
35 37
36 set_programs("*.tgz,*.tar.gz", "tar.gz prog", 0, 0);
38 assoc_programs("*.tgz,*.tar.gz", "tar.gz prog", 0, 0);
37 39
38 40 assert_true((prog_cmd = ft_get_program("file.version.tar.gz")) != NULL); assert_true((prog_cmd = ft_get_program("file.version.tar.gz")) != NULL);
39 41 assert_string_equal("tar.gz prog", prog_cmd); assert_string_equal("tar.gz prog", prog_cmd);
 
... ... TEST(many_filepattern)
41 43
42 44 TEST(dont_match_hidden) TEST(dont_match_hidden)
43 45 { {
44 set_programs("*.tgz,*.tar.gz", "tar.gz prog", 0, 0);
46 assoc_programs("*.tgz,*.tar.gz", "tar.gz prog", 0, 0);
45 47
46 48 assert_null(ft_get_program(".file.version.tar.gz")); assert_null(ft_get_program(".file.version.tar.gz"));
47 49 } }
 
... ... TEST(match_empty)
50 52 { {
51 53 const char *prog_cmd; const char *prog_cmd;
52 54
53 set_programs("a*bc", "empty prog", 0, 0);
55 assoc_programs("a*bc", "empty prog", 0, 0);
54 56
55 57 assert_true((prog_cmd = ft_get_program("abc")) != NULL); assert_true((prog_cmd = ft_get_program("abc")) != NULL);
56 58 assert_string_equal("empty prog", prog_cmd); assert_string_equal("empty prog", prog_cmd);
 
... ... TEST(match_full_line)
60 62 { {
61 63 const char *prog_cmd; const char *prog_cmd;
62 64
63 set_programs("abc", "full prog", 0, 0);
65 assoc_programs("abc", "full prog", 0, 0);
64 66
65 67 assert_true((prog_cmd = ft_get_program("abcd")) == NULL); assert_true((prog_cmd = ft_get_program("abcd")) == NULL);
66 68 assert_true((prog_cmd = ft_get_program("0abc")) == NULL); assert_true((prog_cmd = ft_get_program("0abc")) == NULL);
 
... ... TEST(match_qmark)
74 76 { {
75 77 const char *prog_cmd; const char *prog_cmd;
76 78
77 set_programs("a?c", "full prog", 0, 0);
79 assoc_programs("a?c", "full prog", 0, 0);
78 80
79 81 assert_true((prog_cmd = ft_get_program("ac")) == NULL); assert_true((prog_cmd = ft_get_program("ac")) == NULL);
80 82
 
... ... TEST(qmark_escaping)
86 88 { {
87 89 const char *prog_cmd; const char *prog_cmd;
88 90
89 set_programs("a\\?c", "qmark prog", 0, 0);
91 assoc_programs("a\\?c", "qmark prog", 0, 0);
90 92
91 93 assert_true((prog_cmd = ft_get_program("abc")) == NULL); assert_true((prog_cmd = ft_get_program("abc")) == NULL);
92 94
 
... ... TEST(star_escaping)
98 100 { {
99 101 const char *prog_cmd; const char *prog_cmd;
100 102
101 set_programs("a\\*c", "star prog", 0, 0);
103 assoc_programs("a\\*c", "star prog", 0, 0);
102 104
103 105 assert_true((prog_cmd = ft_get_program("abc")) == NULL); assert_true((prog_cmd = ft_get_program("abc")) == NULL);
104 106
 
... ... TEST(star_and_dot)
110 112 { {
111 113 const char *prog_cmd; const char *prog_cmd;
112 114
113 set_programs(".xls,*.doc", "libreoffice", 0, 0);
115 assoc_programs(".xls,*.doc", "libreoffice", 0, 0);
114 116
115 117 assert_true((prog_cmd = ft_get_program("a.doc")) != NULL); assert_true((prog_cmd = ft_get_program("a.doc")) != NULL);
116 118 assert_string_equal("libreoffice", prog_cmd); assert_string_equal("libreoffice", prog_cmd);
 
... ... TEST(star_and_dot)
118 120 assert_true((prog_cmd = ft_get_program(".a.doc")) == NULL); assert_true((prog_cmd = ft_get_program(".a.doc")) == NULL);
119 121 assert_true((prog_cmd = ft_get_program(".doc")) == NULL); assert_true((prog_cmd = ft_get_program(".doc")) == NULL);
120 122
121 set_programs(".*.doc", "hlibreoffice", 0, 0);
123 assoc_programs(".*.doc", "hlibreoffice", 0, 0);
122 124
123 125 assert_true((prog_cmd = ft_get_program(".a.doc")) != NULL); assert_true((prog_cmd = ft_get_program(".a.doc")) != NULL);
124 126 assert_string_equal("hlibreoffice", prog_cmd); assert_string_equal("hlibreoffice", prog_cmd);
 
... ... TEST(double_comma_in_command)
128 130 { {
129 131 const char *prog_cmd; const char *prog_cmd;
130 132
131 set_programs("*.tar", "prog -o opt1,,opt2", 0, 0);
133 assoc_programs("*.tar", "prog -o opt1,,opt2", 0, 0);
132 134
133 135 assert_true((prog_cmd = ft_get_program("file.version.tar")) != NULL); assert_true((prog_cmd = ft_get_program("file.version.tar")) != NULL);
134 136 assert_string_equal("prog -o opt1,opt2", prog_cmd); assert_string_equal("prog -o opt1,opt2", prog_cmd);
135 137
136 set_programs("*.zip", "prog1 -o opt1, prog2", 0, 0);
138 assoc_programs("*.zip", "prog1 -o opt1, prog2", 0, 0);
137 139
138 140 assert_true((prog_cmd = ft_get_program("file.version.zip")) != NULL); assert_true((prog_cmd = ft_get_program("file.version.zip")) != NULL);
139 141 assert_string_equal("prog1 -o opt1", prog_cmd); assert_string_equal("prog1 -o opt1", prog_cmd);
 
... ... TEST(double_comma_in_command)
141 143
142 144 TEST(double_comma_in_pattern) TEST(double_comma_in_pattern)
143 145 { {
144 set_programs("a,,b,*.tar", "prog1", 0, 0);
146 assoc_programs("a,,b,*.tar", "prog1", 0, 0);
145 147 assert_string_equal("prog1", ft_get_program("a,b")); assert_string_equal("prog1", ft_get_program("a,b"));
146 148 assert_string_equal("prog1", ft_get_program("file.version.tar")); assert_string_equal("prog1", ft_get_program("file.version.tar"));
147 149
148 set_programs("{c,,d}", "prog2", 0, 0);
150 assoc_programs("{c,,d}", "prog2", 0, 0);
149 151 assert_string_equal("prog2", ft_get_program("c,d")); assert_string_equal("prog2", ft_get_program("c,d"));
150 152 } }
151 153
 
... ... TEST(zero_length_match)
157 159
158 160 const char *prog_cmd; const char *prog_cmd;
159 161
160 set_programs("*git", "tig", 0, 0);
162 assoc_programs("*git", "tig", 0, 0);
161 163
162 164 assert_null(prog_cmd = ft_get_program("git")); assert_null(prog_cmd = ft_get_program("git"));
163 165 } }
 
... ... TEST(pattern_list, IF(has_mime_type_detection))
168 170
169 171 snprintf(cmd, sizeof(cmd), "<%s>{binary-data}", snprintf(cmd, sizeof(cmd), "<%s>{binary-data}",
170 172 get_mimetype(TEST_DATA_PATH "/read/binary-data", 0)); get_mimetype(TEST_DATA_PATH "/read/binary-data", 0));
171 set_programs(cmd, "prog", 0, 0);
173 assoc_programs(cmd, "prog", 0, 0);
172 174
173 175 assert_string_equal("prog", assert_string_equal("prog",
174 176 ft_get_program(TEST_DATA_PATH "/read/binary-data")); ft_get_program(TEST_DATA_PATH "/read/binary-data"));
File tests/filetype/filextype.c changed (mode: 100644) (index fb8bb0af9..b32dd7213)
2 2
3 3 #include <stdlib.h> #include <stdlib.h>
4 4
5 #include <test-utils.h>
6
5 7 #include "../../src/filetype.h" #include "../../src/filetype.h"
6 8 #include "../../src/status.h" #include "../../src/status.h"
7 #include "test.h"
8 9
9 10 TEST(one_console_prog) TEST(one_console_prog)
10 11 { {
11 12 const char *prog_cmd; const char *prog_cmd;
12 13
13 set_programs("*.tar", "x prog", 1, 0);
14 set_programs("*.tar", "console prog", 0, 0);
14 assoc_programs("*.tar", "x prog", 1, 0);
15 assoc_programs("*.tar", "console prog", 0, 0);
15 16
16 17 assert_true((prog_cmd = ft_get_program("file.version.tar")) != NULL); assert_true((prog_cmd = ft_get_program("file.version.tar")) != NULL);
17 18 assert_string_equal("console prog", prog_cmd); assert_string_equal("console prog", prog_cmd);
 
... ... TEST(one_graphic_prog)
21 22 { {
22 23 const char *prog_cmd; const char *prog_cmd;
23 24
24 set_programs("*.tar", "x prog", 1, 1);
25 set_programs("*.tar", "console prog", 0, 1);
25 assoc_programs("*.tar", "x prog", 1, 1);
26 assoc_programs("*.tar", "console prog", 0, 1);
26 27
27 28 assert_true((prog_cmd = ft_get_program("file.version.tar")) != NULL); assert_true((prog_cmd = ft_get_program("file.version.tar")) != NULL);
28 29 assert_string_equal("x prog", prog_cmd); assert_string_equal("x prog", prog_cmd);
 
... ... TEST(one_graphic_prog)
30 31
31 32 TEST(two_console_prog) TEST(two_console_prog)
32 33 { {
33 set_programs("*.tgz", "2 x prog", 1, 0);
34 assoc_programs("*.tgz", "2 x prog", 1, 0);
34 35
35 36 assert_null(ft_get_program("file.version.tgz")); assert_null(ft_get_program("file.version.tgz"));
36 37 } }
 
... ... TEST(two_graphic_prog)
39 40 { {
40 41 const char *prog_cmd; const char *prog_cmd;
41 42
42 set_programs("*.tgz", "2 x prog", 1, 1);
43 assoc_programs("*.tgz", "2 x prog", 1, 1);
43 44
44 45 assert_true((prog_cmd = ft_get_program("file.version.tgz")) != NULL); assert_true((prog_cmd = ft_get_program("file.version.tgz")) != NULL);
45 46 assert_string_equal("2 x prog", prog_cmd); assert_string_equal("2 x prog", prog_cmd);
 
... ... TEST(three_console_prog)
49 50 { {
50 51 const char *prog_cmd; const char *prog_cmd;
51 52
52 set_programs("*.tar.bz2", "3 console prog", 0, 1);
53 assoc_programs("*.tar.bz2", "3 console prog", 0, 1);
53 54
54 55 assert_true((prog_cmd = ft_get_program("file.version.tar.bz2")) != NULL); assert_true((prog_cmd = ft_get_program("file.version.tar.bz2")) != NULL);
55 56 assert_string_equal("3 console prog", prog_cmd); assert_string_equal("3 console prog", prog_cmd);
 
... ... TEST(three_graphic_prog)
59 60 { {
60 61 const char *prog_cmd; const char *prog_cmd;
61 62
62 set_programs("*.tar.bz2", "3 console prog", 0, 0);
63 assoc_programs("*.tar.bz2", "3 console prog", 0, 0);
63 64
64 65 assert_true((prog_cmd = ft_get_program("file.version.tar.bz2")) != NULL); assert_true((prog_cmd = ft_get_program("file.version.tar.bz2")) != NULL);
65 66 assert_string_equal("3 console prog", prog_cmd); assert_string_equal("3 console prog", prog_cmd);
File tests/filetype/find_program.c changed (mode: 100644) (index bc4c2e1d1..e016ed18a)
3 3 #include <stdlib.h> #include <stdlib.h>
4 4 #include <string.h> #include <string.h>
5 5
6 #include <test-utils.h>
7
6 8 #include "../../src/filetype.h" #include "../../src/filetype.h"
7 9 #include "../../src/utils/str.h" #include "../../src/utils/str.h"
8 #include "test.h"
9 10
10 11 static int prog_exists(const char name[]); static int prog_exists(const char name[]);
11 12
 
... ... TEST(find_program)
15 16
16 17 ft_init(&prog_exists); ft_init(&prog_exists);
17 18
18 set_programs("*.tar.bz2", "no console prog", 0, 0);
19 set_programs("*.tar.bz2", "console prog", 0, 0);
19 assoc_programs("*.tar.bz2", "no console prog", 0, 0);
20 assoc_programs("*.tar.bz2", "console prog", 0, 0);
20 21
21 22 assert_true((prog_cmd = ft_get_program("file.version.tar.bz2")) != NULL); assert_true((prog_cmd = ft_get_program("file.version.tar.bz2")) != NULL);
22 23 assert_string_equal("console prog", prog_cmd); assert_string_equal("console prog", prog_cmd);
File tests/filetype/regexps.c changed (mode: 100644) (index d6c4c47c2..1267f3176)
2 2
3 3 #include <stdlib.h> #include <stdlib.h>
4 4
5 #include <test-utils.h>
6
5 7 #include "../../src/filetype.h" #include "../../src/filetype.h"
6 8 #include "../../src/status.h" #include "../../src/status.h"
7 #include "test.h"
8 9
9 10 TEST(regexp) TEST(regexp)
10 11 { {
11 12 const char *prog_cmd; const char *prog_cmd;
12 13
13 set_programs("/.*\\.[ch]$/", "c file", 0, 0);
14 assoc_programs("/.*\\.[ch]$/", "c file", 0, 0);
14 15
15 16 assert_null(ft_get_program("main.cpp")); assert_null(ft_get_program("main.cpp"));
16 17 assert_null(ft_get_program("main.hpp")); assert_null(ft_get_program("main.hpp"));
File tests/filetype/test.c changed (mode: 100644) (index f8ac9572c..92b4c4f6b)
1 1 #include "test.h" #include "test.h"
2 2
3 3 #include "../../src/int/file_magic.h" #include "../../src/int/file_magic.h"
4 #include "../../src/filetype.h"
5
6 void
7 set_programs(const char pattern[], const char programs[], int for_x, int in_x)
8 {
9 char *error;
10 matchers_group_t mg;
11 assert_success(ft_mg_from_string(pattern, &mg, &error));
12 assert_string_equal(NULL, error);
13
14 ft_set_programs(mg, programs, for_x, in_x);
15 }
16
17 void
18 set_viewers(const char pattern[], const char viewers[])
19 {
20 char *error;
21 matchers_group_t mg;
22 assert_success(ft_mg_from_string(pattern, &mg, &error));
23 assert_string_equal(NULL, error);
24
25 ft_set_viewers(mg, viewers);
26 }
27 4
28 5 int int
29 6 has_mime_type_detection(void) has_mime_type_detection(void)
File tests/filetype/test.h changed (mode: 100644) (index 6a92b5c6d..4eb1b81d0)
1 1 #ifndef VIFM_TESTS__FILETYPE__TEST_H__ #ifndef VIFM_TESTS__FILETYPE__TEST_H__
2 2 #define VIFM_TESTS__FILETYPE__TEST_H__ #define VIFM_TESTS__FILETYPE__TEST_H__
3 3
4 #include "../../src/ui/column_view.h"
5
6 void set_programs(const char pattern[], const char programs[], int for_x,
7 int in_x);
8
9 void set_viewers(const char pattern[], const char viewers[]);
10
11 4 int has_mime_type_detection(void); int has_mime_type_detection(void);
12 5
13 6 #endif /* VIFM_TESTS__FILETYPE__TEST_H__ */ #endif /* VIFM_TESTS__FILETYPE__TEST_H__ */
File tests/filetype/viewers.c changed (mode: 100644) (index 04314d006..59d1143ea)
3 3 #include <stdlib.h> #include <stdlib.h>
4 4 #include <string.h> #include <string.h>
5 5
6 #include <test-utils.h>
7
6 8 #include "../../src/int/file_magic.h" #include "../../src/int/file_magic.h"
7 9 #include "../../src/filetype.h" #include "../../src/filetype.h"
8 10 #include "../../src/status.h" #include "../../src/status.h"
 
... ... TEST(multiple_choice_separated)
37 39 { {
38 40 const char *viewer; const char *viewer;
39 41
40 set_viewers("*.tar.bz2", "prog1");
41 set_viewers("*.tar.bz2", "prog2");
42 assoc_viewers("*.tar.bz2", "prog1");
43 assoc_viewers("*.tar.bz2", "prog2");
42 44
43 45 ft_init(&prog1_available); ft_init(&prog1_available);
44 46 viewer = ft_get_viewer("file.version.tar.bz2"); viewer = ft_get_viewer("file.version.tar.bz2");
 
... ... TEST(multiple_choice_joined)
57 59 { {
58 60 const char *viewer; const char *viewer;
59 61
60 set_viewers("*.tar.bz2", "prog1,prog2");
62 assoc_viewers("*.tar.bz2", "prog1,prog2");
61 63
62 64 ft_init(&prog1_available); ft_init(&prog1_available);
63 65 viewer = ft_get_viewer("file.version.tar.bz2"); viewer = ft_get_viewer("file.version.tar.bz2");
 
... ... TEST(description_is_not_allowed)
76 78 { {
77 79 const char *viewer; const char *viewer;
78 80
79 set_viewers("*.tar.bz2", "{archives} prog1");
81 assoc_viewers("*.tar.bz2", "{archives} prog1");
80 82
81 83 ft_init(&prog1_available); ft_init(&prog1_available);
82 84 viewer = ft_get_viewer("file.version.tar.bz2"); viewer = ft_get_viewer("file.version.tar.bz2");
 
... ... TEST(description_is_not_allowed)
85 87
86 88 TEST(several_patterns) TEST(several_patterns)
87 89 { {
88 set_viewers("*.tbz,*.tbz2,*.tar.bz2", "prog1");
90 assoc_viewers("*.tbz,*.tbz2,*.tar.bz2", "prog1");
89 91
90 92 ft_init(&prog1_available); ft_init(&prog1_available);
91 93
 
... ... TEST(several_patterns)
96 98
97 99 TEST(multiple_viewers) TEST(multiple_viewers)
98 100 { {
99 set_viewers("*.tbz", "prog1 a");
100 set_viewers("*.tba", "prog2 a");
101 set_viewers("*.tbz", "prog2 b");
102 set_viewers("*.tbz", "prog1 b");
101 assoc_viewers("*.tbz", "prog1 a");
102 assoc_viewers("*.tba", "prog2 a");
103 assoc_viewers("*.tbz", "prog2 b");
104 assoc_viewers("*.tbz", "prog1 b");
103 105
104 106 ft_init(&prog1_available); ft_init(&prog1_available);
105 107
 
... ... TEST(pattern_list, IF(has_mime_type_detection))
116 118
117 119 snprintf(cmd, sizeof(cmd), "<%s>{binary-data}", snprintf(cmd, sizeof(cmd), "<%s>{binary-data}",
118 120 get_mimetype(TEST_DATA_PATH "/read/binary-data", 0)); get_mimetype(TEST_DATA_PATH "/read/binary-data", 0));
119 set_viewers(cmd, "prog1");
121 assoc_viewers(cmd, "prog1");
120 122
121 123 ft_init(&prog1_available); ft_init(&prog1_available);
122 124
File tests/test-support/test-utils.c changed (mode: 100644) (index 08d0cf3b3..0f882825e)
39 39 #include "../../src/background.h" #include "../../src/background.h"
40 40 #include "../../src/cmd_completion.h" #include "../../src/cmd_completion.h"
41 41 #include "../../src/filelist.h" #include "../../src/filelist.h"
42 #include "../../src/filetype.h"
42 43 #include "../../src/filtering.h" #include "../../src/filtering.h"
43 44 #include "../../src/opt_handlers.h" #include "../../src/opt_handlers.h"
44 45 #include "../../src/plugins.h" #include "../../src/plugins.h"
 
... ... reset_timestamp(const char path[])
877 878 #endif #endif
878 879 } }
879 880
881 void
882 assoc_programs(const char mg_str[], const char programs[], int for_x, int in_x)
883 {
884 char *error;
885 matchers_group_t mg;
886 assert_success(ft_mg_from_string(mg_str, &mg, &error));
887 assert_string_equal(NULL, error);
888
889 ft_set_programs(mg, programs, for_x, in_x);
890 }
891
892 void
893 assoc_viewers(const char mg_str[], const char viewers[])
894 {
895 char *error;
896 matchers_group_t mg;
897 assert_success(ft_mg_from_string(mg_str, &mg, &error));
898 assert_string_equal(NULL, error);
899
900 ft_set_viewers(mg, viewers);
901 }
902
880 903 void void
881 904 load_plugins(struct plugs_t *plugs, const char cfg_dir[]) load_plugins(struct plugs_t *plugs, const char cfg_dir[])
882 905 { {
File tests/test-support/test-utils.h changed (mode: 100644) (index 8611b1ba4..cb81c40fe)
... ... void stub_colmgr(void);
183 183 /* Changes time attributes of a file to something "long time ago". */ /* Changes time attributes of a file to something "long time ago". */
184 184 void reset_timestamp(const char path[]); void reset_timestamp(const char path[]);
185 185
186 /* Associates matchers group with a comma-separated list of programs. */
187 void assoc_programs(const char mg_str[], const char programs[], int for_x,
188 int in_x);
189
190 /* Associates matchers group with a comma-separated list of viewers. */
191 void assoc_viewers(const char mg_str[], const char viewers[]);
192
186 193 struct plugs_t; struct plugs_t;
187 194
188 195 /* Appends "/plugins" to the passed in directory and loads plugins from /* Appends "/plugins" to the passed in directory and loads plugins from
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