Debian Codegraph @

tests/flipdiff-devnull/run-test

raw
1 #!/bin/sh
2
3 # Test flipdiff with /dev/null automatic -p detection
4 # This tests that flipdiff can auto-detect -p values when dealing with /dev/null
5
6 . ${top_srcdir-.}/tests/common.sh
7
8 # Create first patch (creates a file)
9 cat << EOF > patch1
10 --- /dev/null
11 +++ b/testfile.c
12 @@ -0,0 +1,2 @@
13 +#include <stdio.h>
14 +int main() { return 0; }
15 EOF
16
17 # Create second patch (modifies the same file)
18 cat << EOF > patch2
19 --- a/testfile.c
20 +++ b/testfile.c
21 @@ -1,2 +1,3 @@
22 #include <stdio.h>
23 +#include <stdlib.h>
24 int main() { return 0; }
25 EOF
26
27 # Expected flipdiff output (should auto-detect -p1)
28 cat << EOF > expected
29 --- a/testfile.c
30 +++ b/testfile.c
31 @@ -0,0 +1 @@
32 +#include <stdlib.h>
33
34 === 8< === cut here === 8< ===
35
36 --- /dev/null
37 +++ b/testfile.c
38 @@ -1 +1,3 @@
39 +#include <stdio.h>
40 #include <stdlib.h>
41 +int main() { return 0; }
42 EOF
43
44 # Run flipdiff - should auto-detect -p1 and produce flipped patches
45 ${FLIPDIFF} patch1 patch2 2>errors >actual || exit 1
46 [ -s errors ] && exit 1
47
48 # Compare the actual output with expected
49 diff -u expected actual || exit 1
50
51 exit 0