3 test_description
='check that the most basic functions work
6 Verify wrappers and compatibility functions.
9 TEST_PASSES_SANITIZE_LEAK
=true
12 test_expect_success
'mktemp to nonexistent directory prints filename' '
13 test_must_fail test-tool mktemp doesnotexist/testXXXXXX 2>err &&
14 grep "doesnotexist/test" err
17 test_expect_success POSIXPERM
,SANITY
'mktemp to unwritable directory prints filename' '
19 test_when_finished "chmod +w cannotwrite" &&
20 chmod -w cannotwrite &&
21 test_must_fail test-tool mktemp cannotwrite/testXXXXXX 2>err &&
22 grep "cannotwrite/test" err
25 test_expect_success
'git_mkstemps_mode does not fail if fd 0 is not open' '
26 git commit --allow-empty -m message <&-
29 test_expect_success
'check for a bug in the regex routines' '
30 # if this test fails, re-build git with NO_REGEX=1
34 test_expect_success
'incomplete sideband messages are reassembled' '
35 test-tool pkt-line send-split-sideband >split-sideband &&
36 test-tool pkt-line receive-sideband <split-sideband 2>err &&
37 grep "Hello, world" err
40 test_expect_success
'eof on sideband message is reported' '
42 test-tool pkt-line receive-sideband <input 2>err &&
43 test_grep "unexpected disconnect" err
46 test_expect_success
'missing sideband designator is reported' '
48 test-tool pkt-line receive-sideband <input 2>err &&
49 test_grep "missing sideband" err
52 test_expect_success
'unpack-sideband: --no-chomp-newline' '
53 test_when_finished "rm -f expect-out expect-err" &&
54 test-tool pkt-line send-split-sideband >split-sideband &&
55 test-tool pkt-line unpack-sideband \
56 --no-chomp-newline <split-sideband >out 2>err &&
57 cat >expect-out <<-EOF &&
58 primary: regular output
60 cat >expect-err <<-EOF &&
65 test_cmp expect-out out &&
66 test_cmp expect-err err
69 test_expect_success
'unpack-sideband: --chomp-newline (default)' '
70 test_when_finished "rm -f expect-out expect-err" &&
71 test-tool pkt-line send-split-sideband >split-sideband &&
72 test-tool pkt-line unpack-sideband \
73 --chomp-newline <split-sideband >out 2>err &&
74 printf "primary: regular output" >expect-out &&
75 printf "Foo.Bar.Hello, world!" >expect-err &&
76 test_cmp expect-out out &&
77 test_cmp expect-err err
80 test_expect_success
'unpack-sideband: packet_reader_read() consumes sideband, no chomp payload' '
81 test_when_finished "rm -f expect-out expect-err" &&
82 test-tool pkt-line send-split-sideband >split-sideband &&
83 test-tool pkt-line unpack-sideband \
84 --reader-use-sideband \
85 --no-chomp-newline <split-sideband >out 2>err &&
86 cat >expect-out <<-EOF &&
87 primary: regular output
89 printf "remote: Foo. \n" >expect-err &&
90 printf "remote: Bar. \n" >>expect-err &&
91 printf "remote: Hello, world! \n" >>expect-err &&
92 test_cmp expect-out out &&
93 test_cmp expect-err err
96 test_expect_success
'unpack-sideband: packet_reader_read() consumes sideband, chomp payload' '
97 test_when_finished "rm -f expect-out expect-err" &&
98 test-tool pkt-line send-split-sideband >split-sideband &&
99 test-tool pkt-line unpack-sideband \
100 --reader-use-sideband \
101 --chomp-newline <split-sideband >out 2>err &&
102 printf "primary: regular output" >expect-out &&
103 printf "remote: Foo. \n" >expect-err &&
104 printf "remote: Bar. \n" >>expect-err &&
105 printf "remote: Hello, world! \n" >>expect-err &&
106 test_cmp expect-out out &&
107 test_cmp expect-err err