Debian Codegraph @

tests/combine-devnull/run-test

raw
1 #!/bin/sh
2
3 # This is a combinediff(1) testcase for the /dev/null issue.
4 # Issue: https://github.com/twaugh/patchutils/issues/23
5
6 . ${top_srcdir-.}/tests/common.sh
7
8 # Create the first patch that creates a new file
9 cat << EOF > patch1
10 --- /dev/null
11 +++ b/txt
12 @@ -0,0 +1,3 @@
13 +a
14 +b
15 +c
16 EOF
17
18 # Create the second patch that modifies the same file
19 cat << EOF > patch2
20 --- a/txt
21 +++ b/txt
22 @@ -1,3 +1,2 @@
23 a
24 b
25 -c
26 EOF
27
28 # Expected combined output should be:
29 cat << EOF > expected
30 diff -u /dev/null b/txt
31 --- /dev/null
32 +++ b/txt
33 @@ -0,0 +1,2 @@
34 +a
35 +b
36 EOF
37
38 # Run combinediff
39 ${COMBINEDIFF} patch1 patch2 2>errors >actual || exit 1
40 [ -s errors ] && exit 1
41
42 # Compare the actual output with expected
43 diff -u expected actual || exit 1
44
45 # Test that the combined patch actually works
46 rm -f txt
47 ${PATCH} -p1 < actual || exit 1
48 cat << EOF > expected_result
49 a
50 b
51 EOF
52 diff -u expected_result txt || exit 1
53
54 exit 0