interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t0070-fundamental.sh

109 lines · 3509 bytes Raw Blame History
1#!/bin/sh
2
3test_description='check that the most basic functions work
4
5
6Verify wrappers and compatibility functions.
7'
8
9. ./test-lib.sh
10
11test_expect_success 'mktemp to nonexistent directory prints filename' '
12 test_must_fail test-tool mktemp doesnotexist/testXXXXXX 2>err &&
13 test_grep "doesnotexist/test" err
14'
15
16test_expect_success POSIXPERM,SANITY 'mktemp to unwritable directory prints filename' '
17 mkdir cannotwrite &&
18 test_when_finished "chmod +w cannotwrite" &&
19 chmod -w cannotwrite &&
20 test_must_fail test-tool mktemp cannotwrite/testXXXXXX 2>err &&
21 test_grep "cannotwrite/test" err
22'
23
24test_expect_success 'git_mkstemps_mode does not fail if fd 0 is not open' '
25 git commit --allow-empty -m message <&-
26'
27
28test_expect_success 'check for a bug in the regex routines' '
29 # if this test fails, re-build git with NO_REGEX=1
30 test-tool regex --bug
31'
32
33test_expect_success 'incomplete sideband messages are reassembled' '
34 test-tool pkt-line send-split-sideband >split-sideband &&
35 test-tool pkt-line receive-sideband <split-sideband 2>err &&
36 test_grep "Hello, world" err
37'
38
39test_expect_success 'eof on sideband message is reported' '
40 printf 1234 >input &&
41 test-tool pkt-line receive-sideband <input 2>err &&
42 test_grep "unexpected disconnect" err
43'
44
45test_expect_success 'missing sideband designator is reported' '
46 printf 0004 >input &&
47 test-tool pkt-line receive-sideband <input 2>err &&
48 test_grep "missing sideband" err
49'
50
51test_expect_success 'unpack-sideband: --no-chomp-newline' '
52 test_when_finished "rm -f expect-out expect-err" &&
53 test-tool pkt-line send-split-sideband >split-sideband &&
54 test-tool pkt-line unpack-sideband \
55 --no-chomp-newline <split-sideband >out 2>err &&
56 cat >expect-out <<-EOF &&
57 primary: regular output
58 EOF
59 cat >expect-err <<-EOF &&
60 Foo.
61 Bar.
62 Hello, world!
63 EOF
64 test_cmp expect-out out &&
65 test_cmp expect-err err
66'
67
68test_expect_success 'unpack-sideband: --chomp-newline (default)' '
69 test_when_finished "rm -f expect-out expect-err" &&
70 test-tool pkt-line send-split-sideband >split-sideband &&
71 test-tool pkt-line unpack-sideband \
72 --chomp-newline <split-sideband >out 2>err &&
73 printf "primary: regular output" >expect-out &&
74 printf "Foo.Bar.Hello, world!" >expect-err &&
75 test_cmp expect-out out &&
76 test_cmp expect-err err
77'
78
79test_expect_success 'unpack-sideband: packet_reader_read() consumes sideband, no chomp payload' '
80 test_when_finished "rm -f expect-out expect-err" &&
81 test-tool pkt-line send-split-sideband >split-sideband &&
82 test-tool pkt-line unpack-sideband \
83 --reader-use-sideband \
84 --no-chomp-newline <split-sideband >out 2>err &&
85 cat >expect-out <<-EOF &&
86 primary: regular output
87 EOF
88 printf "remote: Foo. \n" >expect-err &&
89 printf "remote: Bar. \n" >>expect-err &&
90 printf "remote: Hello, world! \n" >>expect-err &&
91 test_cmp expect-out out &&
92 test_cmp expect-err err
93'
94
95test_expect_success 'unpack-sideband: packet_reader_read() consumes sideband, chomp payload' '
96 test_when_finished "rm -f expect-out expect-err" &&
97 test-tool pkt-line send-split-sideband >split-sideband &&
98 test-tool pkt-line unpack-sideband \
99 --reader-use-sideband \
100 --chomp-newline <split-sideband >out 2>err &&
101 printf "primary: regular output" >expect-out &&
102 printf "remote: Foo. \n" >expect-err &&
103 printf "remote: Bar. \n" >>expect-err &&
104 printf "remote: Hello, world! \n" >>expect-err &&
105 test_cmp expect-out out &&
106 test_cmp expect-err err
107'
108
109test_done