aboutsummaryrefslogtreecommitdiff
path: root/tests/patch.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/patch.test')
-rwxr-xr-xtests/patch.test30
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/patch.test b/tests/patch.test
index 5cc60014..9f44e07c 100755
--- a/tests/patch.test
+++ b/tests/patch.test
@@ -4,6 +4,14 @@
#testing "name" "command" "result" "infile" "stdin"
+testing "dry run doesn't create file" \
+ "patch --dry-run >/dev/null && [ ! -e bork ] && echo yes" "yes\n" "" "
+--- /dev/null
++++ bork
+@@ -0,0 +1,1 @@
++one
+"
+
testing "create file" "patch >/dev/null && cat bork" "one\ntwo\nthree\n" "" "
--- /dev/null
+++ bork
@@ -12,6 +20,7 @@ testing "create file" "patch >/dev/null && cat bork" "one\ntwo\nthree\n" "" "
+two
+three
"
+
testing "insert in middle" "patch > /dev/null && cat bork" \
"one\nfour\ntwo\nthree\n" "" "
--- bork
@@ -81,10 +90,29 @@ testing "filter timestamps" "patch > /dev/null && cat bork" \
testing "quoted name" "patch > /dev/null && cat 'fruit bat'" \
"hello\n" "" '
--- /dev/null
-+++ "fruit bat"
++++ "fruit ba\164"
@@ -0,0 +1 @@
+hello
'
+
+testing "bad quote" "patch 2>&1" $'patch: bad "filename\n' "" '--- "filename'
+
+testing "dry run doesn't delete file" \
+ "patch --dry-run > /dev/null && [ -e 'fruit bat' ] && echo yes" "yes\n" "" '
+--- "fruit bat"
++++ /dev/null
+@@ -1 +0,0 @@
+-hello
+'
+
+testing "delete file" \
+ "patch > /dev/null && [ ! -e 'fruit bat' ] && echo yes" "yes\n" "" '
+--- "fruit bat"
++++ /dev/null
+@@ -1 +0,0 @@
+-hello
+'
+
# todo bork bork2
# We hit a bug, test the bugfix.