]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0070-fundamental.sh
The twentieth batch
[thirdparty/git.git] / t / t0070-fundamental.sh
CommitLineData
b4285c71
RS
1#!/bin/sh
2
3test_description='check that the most basic functions work
4
5
6Verify wrappers and compatibility functions.
7'
8
03267e86 9TEST_PASSES_SANITIZE_LEAK=true
b4285c71
RS
10. ./test-lib.sh
11
6cf6bb3e 12test_expect_success 'mktemp to nonexistent directory prints filename' '
d9cc2c87 13 test_must_fail test-tool mktemp doesnotexist/testXXXXXX 2>err &&
6cf6bb3e
AE
14 grep "doesnotexist/test" err
15'
16
b3b8ceb4 17test_expect_success POSIXPERM,SANITY 'mktemp to unwritable directory prints filename' '
6cf6bb3e 18 mkdir cannotwrite &&
6cf6bb3e 19 test_when_finished "chmod +w cannotwrite" &&
03771425 20 chmod -w cannotwrite &&
d9cc2c87 21 test_must_fail test-tool mktemp cannotwrite/testXXXXXX 2>err &&
6cf6bb3e
AE
22 grep "cannotwrite/test" err
23'
24
253b27f1
DW
25test_expect_success 'git_mkstemps_mode does not fail if fd 0 is not open' '
26 git commit --allow-empty -m message <&-
27'
28
c9184159
RJ
29test_expect_success 'check for a bug in the regex routines' '
30 # if this test fails, re-build git with NO_REGEX=1
9038531f 31 test-tool regex --bug
c9184159
RJ
32'
33
17e7dbbc
JS
34test_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
38'
39
af22a63c
JK
40test_expect_success 'eof on sideband message is reported' '
41 printf 1234 >input &&
42 test-tool pkt-line receive-sideband <input 2>err &&
6789275d 43 test_grep "unexpected disconnect" err
af22a63c
JK
44'
45
46test_expect_success 'missing sideband designator is reported' '
47 printf 0004 >input &&
48 test-tool pkt-line receive-sideband <input 2>err &&
6789275d 49 test_grep "missing sideband" err
af22a63c
JK
50'
51
eaa82f8e
JX
52test_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
67'
68
69test_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
78'
79
64220dc5 80test_expect_success 'unpack-sideband: packet_reader_read() consumes sideband, no chomp payload' '
eaa82f8e
JX
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
94'
95
7033d547 96test_expect_success 'unpack-sideband: packet_reader_read() consumes sideband, chomp payload' '
eaa82f8e
JX
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
108'
109
b4285c71 110test_done