exchange: automate the testing process too
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 03 Mar 2014 14:03:41 -0800
changeset 831 a6af6919888d
parent 830 f3b3a09ba312
child 832 46e81a5d2d94
exchange: automate the testing process too we now have: dotest TESTNAME [TARGETNODE]
tests/_exc-util.sh
tests/test-exchange-A1.t
tests/test-exchange-A2.t
--- a/tests/_exc-util.sh	Mon Mar 03 13:27:53 2014 -0800
+++ b/tests/_exc-util.sh	Mon Mar 03 14:03:41 2014 -0800
@@ -38,3 +38,58 @@
     hg clone -q main pulldest
     echo 'cd into `main` and proceed with env setup'
 }
+
+dotest() {
+# dotest TESTNAME [TARGETNODE]
+
+    testcase=$1
+    target="$2"
+    targetnode=""
+    desccall=""
+    cd $testcase
+    echo "## Running testcase $testcase"
+    if [ -n "$target" ]; then
+        desccall="desc("\'"$target"\'")"
+        targetnode="`hg -R main id -qr \"$desccall\"`"
+        echo "# testing echange of \"$target\" ($targetnode)"
+    fi
+    echo "## initial state"
+    echo "# obstore: main"
+    hg -R main     debugobsolete
+    echo "# obstore: pushdest"
+    hg -R pushdest debugobsolete
+    echo "# obstore: pulldest"
+    hg -R pulldest debugobsolete
+
+    if [ -n "$target" ]; then
+        echo "## pushing \"$target\"" from main to pushdest
+        hg -R main push -r "$desccall" pushdest
+    else
+        echo "## pushing from main to pushdest"
+        hg -R main push pushdest
+    fi
+    echo "## post push state"
+    echo "# obstore: main"
+    hg -R main     debugobsolete
+    echo "# obstore: pushdest"
+    hg -R pushdest debugobsolete
+    echo "# obstore: pulldest"
+    hg -R pulldest debugobsolete
+    if [ -n "$target" ]; then
+        echo "## pulling \"$targetnode\"" from main into pulldest
+        hg -R pulldest pull -r $targetnode main
+    else
+        echo "## pulling from main into pulldest"
+        hg -R pulldest pull main
+    fi
+    echo "## post pull state"
+    echo "# obstore: main"
+    hg -R main     debugobsolete
+    echo "# obstore: pushdest"
+    hg -R pushdest debugobsolete
+    echo "# obstore: pulldest"
+    hg -R pulldest debugobsolete
+
+    cd ..
+
+}
--- a/tests/test-exchange-A1.t	Mon Mar 03 13:27:53 2014 -0800
+++ b/tests/test-exchange-A1.t	Mon Mar 03 14:03:41 2014 -0800
@@ -29,16 +29,13 @@
 
 initial
 
-  $ mkdir A.1.1
-  $ cd A.1.1
-  $ hg init source
-  $ hg init dest
-  $ hg init other
-  $ cd source
-  $ mkcommit O
-  $ hg phase --public .
-  $ hg push -q ../dest
-  $ hg push -q ../other
+  $ setuprepos A.1.1
+  creating test repo for test case A.1.1
+  - pulldest
+  - main
+  - pushdest
+  cd into `main` and proceed with env setup
+  $ cd main
   $ mkcommit A
   $ hg debugobsolete aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa `getid 'desc(A)'`
   $ hg log -G
@@ -60,16 +57,16 @@
 Variante a: push -r A
 ---------------------
 
-  $ cd A.1.1.a
-  $ hg -R source id -r 'desc(A)'
-  f5bc6836db60 tip
-  $ hg -R source debugobsolete
+  $ dotest A.1.1.a A
+  ## Running testcase A.1.1.a
+  # testing echange of "A" (f5bc6836db60)
+  ## initial state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R dest   debugobsolete
-  $ hg -R other  debugobsolete
-
-  $ hg -R source push -r 'desc(A)' dest
-  pushing to dest
+  # obstore: pushdest
+  # obstore: pulldest
+  ## pushing "A" from main to pushdest
+  pushing to pushdest
   searching for changes
   adding changesets
   adding manifests
@@ -80,14 +77,14 @@
   OBSEXC: encoding 1 markers
   OBSEXC: sending 1 pushkey payload (78 bytes)
   OBSEXC: DONE
-  $ hg -R source debugobsolete
-  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R dest   debugobsolete
+  ## post push state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R other  debugobsolete
-
-  $ hg -R other pull -r 'f5bc6836db60' dest
-  pulling from dest
+  # obstore: pushdest
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
+  # obstore: pulldest
+  ## pulling "f5bc6836db60" from main into pulldest
+  pulling from main
   searching for changes
   adding changesets
   adding manifests
@@ -98,28 +95,29 @@
   OBSEXC: 1 markers added
   OBSEXC: DONE
   (run 'hg update' to get a working copy)
-  $ hg -R source debugobsolete
+  ## post pull state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R dest   debugobsolete
+  # obstore: pushdest
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R other  debugobsolete
+  # obstore: pulldest
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
 
-  $ cd ..
+
+
 
 Variante b: push
 ---------------------
 
-  $ cd A.1.1.b
-  $ hg -R source id -r 'desc(A)'
-  f5bc6836db60 tip
-  $ hg -R source debugobsolete
+  $ dotest A.1.1.b
+  ## Running testcase A.1.1.b
+  ## initial state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R dest   debugobsolete
-  $ hg -R other  debugobsolete
-
-  $ hg -R source push dest
-  pushing to dest
+  # obstore: pushdest
+  # obstore: pulldest
+  ## pushing from main to pushdest
+  pushing to pushdest
   searching for changes
   adding changesets
   adding manifests
@@ -130,14 +128,14 @@
   OBSEXC: encoding 1 markers
   OBSEXC: sending 1 pushkey payload (78 bytes)
   OBSEXC: DONE
-  $ hg -R source debugobsolete
-  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R dest   debugobsolete
+  ## post push state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R other  debugobsolete
-
-  $ hg -R other pull dest
-  pulling from dest
+  # obstore: pushdest
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
+  # obstore: pulldest
+  ## pulling from main into pulldest
+  pulling from main
   searching for changes
   adding changesets
   adding manifests
@@ -148,14 +146,16 @@
   OBSEXC: 1 markers added
   OBSEXC: DONE
   (run 'hg update' to get a working copy)
-  $ hg -R source debugobsolete
+  ## post pull state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R dest   debugobsolete
+  # obstore: pushdest
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R other  debugobsolete
+  # obstore: pulldest
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
 
-  $ cd ..
+
+
 
 
 
@@ -187,16 +187,13 @@
 
 initial
 
-  $ mkdir A.1.2
-  $ cd A.1.2
-  $ hg init source
-  $ hg init dest
-  $ hg init other
-  $ cd source
-  $ mkcommit O
-  $ hg phase --public .
-  $ hg push -q ../dest
-  $ hg push -q ../other
+  $ setuprepos A.1.2
+  creating test repo for test case A.1.2
+  - pulldest
+  - main
+  - pushdest
+  cd into `main` and proceed with env setup
+  $ cd main
   $ mkcommit A
   $ mkcommit B
   $ hg log -G
@@ -221,16 +218,16 @@
 Variante a: push -r A
 ---------------------
 
-  $ cd A.1.2.a
-  $ hg -R source id -r 'desc(B)'
-  f6fbb35d8ac9 tip
-  $ hg -R source debugobsolete
+  $ dotest A.1.2.a B
+  ## Running testcase A.1.2.a
+  # testing echange of "B" (f6fbb35d8ac9)
+  ## initial state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R dest   debugobsolete
-  $ hg -R other  debugobsolete
-
-  $ hg -R source push -r 'desc(B)' dest
-  pushing to dest
+  # obstore: pushdest
+  # obstore: pulldest
+  ## pushing "B" from main to pushdest
+  pushing to pushdest
   searching for changes
   adding changesets
   adding manifests
@@ -241,14 +238,14 @@
   OBSEXC: encoding 1 markers
   OBSEXC: sending 1 pushkey payload (78 bytes)
   OBSEXC: DONE
-  $ hg -R source debugobsolete
-  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R dest   debugobsolete
+  ## post push state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R other  debugobsolete
-
-  $ hg -R other pull -r 'f6fbb35d8ac9' dest
-  pulling from dest
+  # obstore: pushdest
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
+  # obstore: pulldest
+  ## pulling "f6fbb35d8ac9" from main into pulldest
+  pulling from main
   searching for changes
   adding changesets
   adding manifests
@@ -259,28 +256,26 @@
   OBSEXC: 1 markers added
   OBSEXC: DONE
   (run 'hg update' to get a working copy)
-  $ hg -R source debugobsolete
-  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R dest   debugobsolete
+  ## post pull state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R other  debugobsolete
+  # obstore: pushdest
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-
-  $ cd ..
+  # obstore: pulldest
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
 
 Variante b: push
 ---------------------
 
-  $ cd A.1.2.b
-  $ hg -R source id -r 'desc(B)'
-  f6fbb35d8ac9 tip
-  $ hg -R source debugobsolete
+  $ dotest A.1.2.b
+  ## Running testcase A.1.2.b
+  ## initial state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R dest   debugobsolete
-  $ hg -R other  debugobsolete
-
-  $ hg -R source push dest
-  pushing to dest
+  # obstore: pushdest
+  # obstore: pulldest
+  ## pushing from main to pushdest
+  pushing to pushdest
   searching for changes
   adding changesets
   adding manifests
@@ -291,14 +286,14 @@
   OBSEXC: encoding 1 markers
   OBSEXC: sending 1 pushkey payload (78 bytes)
   OBSEXC: DONE
-  $ hg -R source debugobsolete
-  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R dest   debugobsolete
+  ## post push state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R other  debugobsolete
-
-  $ hg -R other pull dest
-  pulling from dest
+  # obstore: pushdest
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
+  # obstore: pulldest
+  ## pulling from main into pulldest
+  pulling from main
   searching for changes
   adding changesets
   adding manifests
@@ -309,11 +304,10 @@
   OBSEXC: 1 markers added
   OBSEXC: DONE
   (run 'hg update' to get a working copy)
-  $ hg -R source debugobsolete
-  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R dest   debugobsolete
+  ## post pull state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R other  debugobsolete
+  # obstore: pushdest
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-
-  $ cd ..
+  # obstore: pulldest
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
--- a/tests/test-exchange-A2.t	Mon Mar 03 13:27:53 2014 -0800
+++ b/tests/test-exchange-A2.t	Mon Mar 03 14:03:41 2014 -0800
@@ -64,16 +64,16 @@
 Actual Test
 ---------------
 
-  $ cd A.2
-  $ hg -R main id -r 'desc(A)'
-  f5bc6836db60
-  $ hg -R main     debugobsolete
+  $ dotest A.2 A
+  ## Running testcase A.2
+  # testing echange of "A" (f5bc6836db60)
+  ## initial state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
   bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 35b1839966785d5703a01607229eea932db42f87 0 {'date': '', 'user': 'test'}
-  $ hg -R pushdest debugobsolete
-  $ hg -R pulldest debugobsolete
-
-  $ hg -R main push -r 'desc(A)' pushdest
+  # obstore: pushdest
+  # obstore: pulldest
+  ## pushing "A" from main to pushdest
   pushing to pushdest
   searching for changes
   adding changesets
@@ -85,13 +85,14 @@
   OBSEXC: encoding 1 markers
   OBSEXC: sending 1 pushkey payload (78 bytes)
   OBSEXC: DONE
-  $ hg -R main     debugobsolete
+  ## post push state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
   bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 35b1839966785d5703a01607229eea932db42f87 0 {'date': '', 'user': 'test'}
-  $ hg -R pushdest debugobsolete
+  # obstore: pushdest
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R pulldest debugobsolete
-  $ hg -R pulldest pull -r 'f5bc6836db60' main
+  # obstore: pulldest
+  ## pulling "f5bc6836db60" from main into pulldest
   pulling from main
   searching for changes
   adding changesets
@@ -103,12 +104,14 @@
   OBSEXC: 1 markers added
   OBSEXC: DONE
   (run 'hg update' to get a working copy)
-  $ hg -R main     debugobsolete
+  ## post pull state
+  # obstore: main
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
   bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 35b1839966785d5703a01607229eea932db42f87 0 {'date': '', 'user': 'test'}
-  $ hg -R pushdest debugobsolete
+  # obstore: pushdest
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
-  $ hg -R pulldest debugobsolete
+  # obstore: pulldest
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa f5bc6836db60e308a17ba08bf050154ba9c4fad7 0 {'date': '', 'user': 'test'}
 
+
   $ cd ..