[PATCH 1 of 2 stable] tests: do not depend on order of os.walk in convert tests

Ross Lagerwall rosslagerwall at gmail.com
Wed Aug 1 02:50:37 CDT 2012


# HG changeset patch
# User Ross Lagerwall <rosslagerwall at gmail.com>
# Date 1343806868 -7200
# Branch stable
# Node ID c9b9d555c54b1a62dea5f6582294987282bb775b
# Parent  3ccb49ed1cc13cf71cd780e998f200ed974ec271
tests: do not depend on order of os.walk in convert tests

The damage repository test would delete the first object file it came
across. However, the order of the directory listing is arbitrary (it seems
to depend on the filesystem). This meant that sometimes a commit object
was deleted, sometimes a blob object and sometimes a tree object.

So, fix by hardcoding which object to delete. Delete a commit object, a
blob object and a tree object in three separate tests.

diff --git a/tests/test-convert-git.t b/tests/test-convert-git.t
--- a/tests/test-convert-git.t
+++ b/tests/test-convert-git.t
@@ -281,20 +281,29 @@
   abort: --sourcesort is not supported by this data source
   [255]
 
-damage git repository and convert again
 
-  $ cat > damage.py <<EOF
-  > import os
-  > import stat
-  > for root, dirs, files in os.walk('git-repo4/.git/objects'):
-  >     if files:
-  >         path = os.path.join(root, files[0])
-  >         if os.name == 'nt':
-  >             os.chmod(path, stat.S_IWUSR)
-  >         os.remove(path)
-  >         break
-  > EOF
-  $ python damage.py
+setup repos for damage tests
+
+  $ cp -a git-repo4 git-repo5
+  $ cp -a git-repo4 git-repo6
+
+damage git repository by deleting a commit object and convert again
+
+  $ rm git-repo4/.git/objects/1c/0ce3c5886f83a1d78a7b517cdff5cf9ca17bdd
   $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | \
   >     grep 'abort:' | sed 's/abort:.*/abort:/g'
   abort:
+
+damage git repository by deleting a blob object and convert again
+
+  $ rm git-repo5/.git/objects/8b/137891791fe96927ad78e64b0aad7bded08bdc
+  $ hg convert git-repo5 git-repo5-broken-hg 2>&1 | \
+  >     grep 'abort:' | sed 's/abort:.*/abort:/g'
+  abort:
+
+damage git repository by deleting a tree object and convert again
+
+  $ rm git-repo6/.git/objects/72/49f083d2a63a41cc737764a86981eb5f3e4635
+  $ hg convert git-repo6 git-repo6-broken-hg 2>&1 | \
+  >     grep 'abort:' | sed 's/abort:.*/abort:/g'
+  abort:


More information about the Mercurial-devel mailing list