File: run-test

package info (click to toggle)
patchutils 0.4.3-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 3,976 kB
  • sloc: ansic: 20,804; sh: 11,956; xml: 2,831; perl: 419; makefile: 300; python: 23
file content (54 lines) | stat: -rwxr-xr-x 893 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh

# This is a combinediff(1) testcase for the /dev/null issue.
# Issue: https://github.com/twaugh/patchutils/issues/23

. ${top_srcdir-.}/tests/common.sh

# Create the first patch that creates a new file
cat << EOF > patch1
--- /dev/null
+++ b/txt
@@ -0,0 +1,3 @@
+a
+b
+c
EOF

# Create the second patch that modifies the same file
cat << EOF > patch2
--- a/txt
+++ b/txt
@@ -1,3 +1,2 @@
 a
 b
-c
EOF

# Expected combined output should be:
cat << EOF > expected
diff -u /dev/null b/txt
--- /dev/null
+++ b/txt
@@ -0,0 +1,2 @@
+a
+b
EOF

# Run combinediff
${COMBINEDIFF} patch1 patch2 2>errors >actual || exit 1
[ -s errors ] && exit 1

# Compare the actual output with expected
diff -u expected actual || exit 1

# Test that the combined patch actually works
rm -f txt
${PATCH} -p1 < actual || exit 1
cat << EOF > expected_result
a
b
EOF
diff -u expected_result txt || exit 1

exit 0