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 (59 lines) | stat: -rwxr-xr-x 1,438 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
55
56
57
58
59
#!/bin/sh

# This is a rediff(1) testcase.
# Test: Preserve diff command headers in multi-file patches (GitHub issue #48)

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

cat << "EOF" > patch.orig
diff -rpU 3 old/a.c new/a.c
--- old/a.c	2021-01-07 13:58:44.000000000 +0000
+++ new/a.c	2021-01-07 13:55:34.000000000 +0000
@@ -1,3 +1,4 @@
 line1
 line2
+added_line
 line3
diff -rpU 3 old/b.c new/b.c
--- old/b.c	2021-01-07 14:01:32.000000000 +0000
+++ new/b.c	2021-01-07 13:57:02.000000000 +0000
@@ -1,3 +1,4 @@
 another1
 another2
+another_added
 another3
diff -rpU 3 old/c.c new/c.c
--- old/c.c	2021-01-07 14:01:40.000000000 +0000
+++ new/c.c	2021-01-07 13:57:30.000000000 +0000
@@ -1,3 +1,6 @@
+#include <stdio.h>
+
 int main() {
     return 0;
 }
EOF

# Test with identical files (no changes) - this was the failing case
${REDIFF} patch.orig patch.orig > patch-rediffed 2>errors || exit 1
[ -s errors ] && exit 1

# Verify all diff command headers are preserved
if ! grep -q "^diff -rpU 3 old/a.c new/a.c$" patch-rediffed; then
    echo "Missing diff header for a.c" >&2
    exit 1
fi

if ! grep -q "^diff -rpU 3 old/b.c new/b.c$" patch-rediffed; then
    echo "Missing diff header for b.c" >&2
    exit 1
fi

if ! grep -q "^diff -rpU 3 old/c.c new/c.c$" patch-rediffed; then
    echo "Missing diff header for c.c" >&2
    exit 1
fi

# Verify the output is identical to input when no changes are made
cmp patch.orig patch-rediffed || exit 1

exit 0