]>
Commit | Line | Data |
---|---|---|
d0d0a357 AM |
1 | #!/bin/sh |
2 | ||
3 | test_description='Test parse_pathspec_file()' | |
4 | ||
fdc8f79f | 5 | TEST_PASSES_SANITIZE_LEAK=true |
d0d0a357 AM |
6 | . ./test-lib.sh |
7 | ||
8 | test_expect_success 'one item from stdin' ' | |
9 | cat >expect <<-\EOF && | |
10 | fileA.t | |
11 | EOF | |
12 | ||
13 | echo fileA.t | | |
14 | test-tool parse-pathspec-file --pathspec-from-file=- >actual && | |
15 | ||
16 | test_cmp expect actual | |
17 | ' | |
18 | ||
19 | test_expect_success 'one item from file' ' | |
20 | cat >expect <<-\EOF && | |
21 | fileA.t | |
22 | EOF | |
23 | ||
24 | echo fileA.t >list && | |
25 | test-tool parse-pathspec-file --pathspec-from-file=list >actual && | |
26 | ||
27 | test_cmp expect actual | |
28 | ' | |
29 | ||
30 | test_expect_success 'NUL delimiters' ' | |
31 | cat >expect <<-\EOF && | |
32 | fileA.t | |
33 | fileB.t | |
34 | EOF | |
35 | ||
36 | printf "fileA.t\0fileB.t\0" | | |
37 | test-tool parse-pathspec-file --pathspec-from-file=- --pathspec-file-nul >actual && | |
38 | ||
39 | test_cmp expect actual | |
40 | ' | |
41 | ||
42 | test_expect_success 'LF delimiters' ' | |
43 | cat >expect <<-\EOF && | |
44 | fileA.t | |
45 | fileB.t | |
46 | EOF | |
47 | ||
48 | printf "fileA.t\nfileB.t\n" | | |
49 | test-tool parse-pathspec-file --pathspec-from-file=- >actual && | |
50 | ||
51 | test_cmp expect actual | |
52 | ' | |
53 | ||
54 | test_expect_success 'no trailing delimiter' ' | |
55 | cat >expect <<-\EOF && | |
56 | fileA.t | |
57 | fileB.t | |
58 | EOF | |
59 | ||
60 | printf "fileA.t\nfileB.t" | | |
61 | test-tool parse-pathspec-file --pathspec-from-file=- >actual && | |
62 | ||
63 | test_cmp expect actual | |
64 | ' | |
65 | ||
66 | test_expect_success 'CRLF delimiters' ' | |
67 | cat >expect <<-\EOF && | |
68 | fileA.t | |
69 | fileB.t | |
70 | EOF | |
71 | ||
72 | printf "fileA.t\r\nfileB.t\r\n" | | |
73 | test-tool parse-pathspec-file --pathspec-from-file=- >actual && | |
74 | ||
75 | test_cmp expect actual | |
76 | ' | |
77 | ||
78 | test_expect_success 'quotes' ' | |
79 | cat >expect <<-\EOF && | |
80 | fileA.t | |
81 | EOF | |
82 | ||
83 | cat >list <<-\EOF && | |
84 | "file\101.t" | |
85 | EOF | |
86 | ||
87 | test-tool parse-pathspec-file --pathspec-from-file=list >actual && | |
88 | ||
89 | test_cmp expect actual | |
90 | ' | |
91 | ||
92 | test_expect_success '--pathspec-file-nul takes quotes literally' ' | |
93 | # Note: there is an extra newline because --pathspec-file-nul takes | |
94 | # input \n literally, too | |
95 | cat >expect <<-\EOF && | |
96 | "file\101.t" | |
97 | ||
98 | EOF | |
99 | ||
100 | cat >list <<-\EOF && | |
101 | "file\101.t" | |
102 | EOF | |
103 | ||
104 | test-tool parse-pathspec-file --pathspec-from-file=list --pathspec-file-nul >actual && | |
105 | ||
106 | test_cmp expect actual | |
107 | ' | |
108 | ||
109 | test_done |