chiark / gitweb /
New test: Try "stg push" in a subdirectory
authorKarl Hasselström <kha@treskal.com>
Sun, 7 Oct 2007 17:36:59 +0000 (19:36 +0200)
committerKarl Hasselström <kha@treskal.com>
Sun, 7 Oct 2007 22:14:11 +0000 (00:14 +0200)
This currently fails for the non-fast-forward cases.

Signed-off-by: Karl Hasselström <kha@treskal.com>
t/t1205-push-subdir.sh [new file with mode: 0755]

diff --git a/t/t1205-push-subdir.sh b/t/t1205-push-subdir.sh
new file mode 100755 (executable)
index 0000000..6502c20
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh
+test_description='Test the push command from a subdirectory'
+. ./test-lib.sh
+stg init
+
+test_expect_success 'Create some patches' '
+    mkdir foo
+    for i in 0 1 2; do
+        stg new p$i -m p$i &&
+        echo x$i >> x.txt &&
+        echo y$i >> foo/y.txt &&
+        stg add x.txt foo/y.txt &&
+        stg refresh
+    done &&
+    [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
+    [ "$(echo $(stg unapplied))" = "" ]
+'
+
+test_expect_success 'Fast-forward push from a subdir' '
+    stg pop &&
+    [ "$(echo $(cat x.txt))" = "x0 x1" ] &&
+    [ "$(echo $(cat foo/y.txt))" = "y0 y1" ] &&
+    cd foo &&
+    stg push &&
+    cd .. &&
+    [ "$(echo $(cat x.txt))" = "x0 x1 x2" ] &&
+    [ "$(echo $(cat foo/y.txt))" = "y0 y1 y2" ]
+'
+
+test_expect_failure 'Modifying push from a subdir' '
+    stg pop &&
+    [ "$(echo $(cat x.txt))" = "x0 x1" ] &&
+    [ "$(echo $(cat foo/y.txt))" = "y0 y1" ] &&
+    stg new extra -m extra &&
+    echo extra >> extra.txt &&
+    stg add extra.txt &&
+    stg refresh &&
+    cd foo &&
+    stg push &&
+    cd .. &&
+    [ "$(echo $(cat x.txt))" = "x0 x1 x2" ] &&
+    [ "$(echo $(cat foo/y.txt))" = "y0 y1 y2" ]
+'
+
+test_expect_failure 'Conflicting push from subdir' '
+    stg pop p1 p2 &&
+    [ "$(echo $(cat x.txt))" = "x0" ] &&
+    [ "$(echo $(cat foo/y.txt))" = "y0" ] &&
+    cd foo &&
+    ! stg push p2 &&
+    cd .. &&
+    [ "$(echo $(stg status --conflict))" = "foo/y.txt x.txt" ]
+'
+
+test_done