Git 2.45
[git/gitster.git] / t / t0070-fundamental.sh
blob0ecec2ba71116959fd2efceac7fc46683d1a3e91
1 #!/bin/sh
3 test_description='check that the most basic functions work
6 Verify wrappers and compatibility functions.
9 TEST_PASSES_SANITIZE_LEAK=true
10 . ./test-lib.sh
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' '
18 mkdir cannotwrite &&
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
31 test-tool regex --bug
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' '
41 printf 1234 >input &&
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' '
47 printf 0004 >input &&
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
59 EOF
60 cat >expect-err <<-EOF &&
61 Foo.
62 Bar.
63 Hello, world!
64 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
88 EOF
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
110 test_done