[PATCH 1 of 2 STABLE] tests: enhance test-casecollision-i18n with cp932 aware filesystem check

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Nov 24 00:19:19 CST 2011


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1322114366 -32400
# Branch stable
# Node ID 8b3cfad9c07307cabb8a49861563bc57ddf37fbd
# Parent  0c0ed2b3082d21c132a27bc62fe4e991a55e7775
tests: enhance test-casecollision-i18n with cp932 aware filesystem check

this adds cp932 aware filesystem check (cp932fs) to hghave, to prevent
test-casecollision-i18n.t from running on cp932 un-aware filesystem.

this also adds check points to test-casecollision-i18n.t, because it
may success unexpectedly for filesystem/locale specific behavior.

for example of such case, cygwin environment (LC_ALL=C) passes this
test, but:

    - unexpected files are created, and recognized as 'unknown'
    - contents of files are unified by unexpected file name folding

diff -r 0c0ed2b3082d -r 8b3cfad9c073 tests/hghave
--- a/tests/hghave	Tue Nov 22 19:56:26 2011 +0100
+++ b/tests/hghave	Thu Nov 24 14:59:26 2011 +0900
@@ -91,6 +91,33 @@
     finally:
         os.remove(path)
 
+def has_cp932fs():
+    d = tempfile.mkdtemp(prefix=tempprefix, dir=".")
+    try:
+        names = [ "\x83\x41", "\x83\x61" ]
+        for name in names:
+            f = open(os.path.join(d, name), "w")
+            try:
+                f.write(name)
+            finally:
+                f.close()
+        for name in names:
+            f = open(os.path.join(d, name), "r")
+            try:
+                content = f.read()
+                if name != content:
+                    return False
+            finally:
+                f.close()
+        return True
+    finally:
+        for name in names:
+            try:
+                os.remove(os.path.join(d, name))
+            except Exception, e:
+                pass # ignore
+        os.rmdir(d)
+
 def has_inotify():
     try:
         import hgext.inotify.linux.watcher
@@ -224,6 +251,7 @@
     "git": (has_git, "git command line client"),
     "gpg": (has_gpg, "gpg client"),
     "icasefs": (has_icasefs, "case insensitive file system"),
+    "cp932fs": (has_cp932fs, "cp932 encoding aware file system"),
     "inotify": (has_inotify, "inotify extension support"),
     "lsprof": (has_lsprof, "python lsprof module"),
     "mtn": (has_mtn, "monotone client (>= 1.0)"),
diff -r 0c0ed2b3082d -r 8b3cfad9c073 tests/test-casecollision-i18n.t
--- a/tests/test-casecollision-i18n.t	Tue Nov 22 19:56:26 2011 +0100
+++ b/tests/test-casecollision-i18n.t	Thu Nov 24 14:59:26 2011 +0900
@@ -2,6 +2,11 @@
 "hg update" is done only on case-insensitive filesystems
 
   $ "$TESTDIR/hghave" icasefs || exit 80
+  $ LC_ALL=
+  $ export LC_ALL
+  $ LC_CTYPE=ja_JP.cp932
+  $ export LC_CTYPE
+  $ "$TESTDIR/hghave" cp932fs || exit 80
 
 setup repository, and target files
 
@@ -19,7 +24,7 @@
   >     # file for getting target filename of "hg add"
   >     f = file(str(num), 'w'); f.write(name); f.close()
   >     # target file of "hg add"
-  >     f = file(name, 'w'); f.write(name); f.close()
+  >     f = file(name, 'w'); f.write(name); f.write("\n"); f.close()
   > EOF
 
 test filename collison check at "hg add"
@@ -41,3 +46,20 @@
   0 files updated, 0 files merged, 4 files removed, 0 files unresolved
   $ hg update tip
   4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg status -A
+  ? 0
+  ? 1
+  ? 2
+  ? 3
+  C \x83A (esc)
+  C \x83Z (esc)
+  C \x83a (esc)
+  C \x83z (esc)
+  $ cat `cat 0`
+  \x83A (esc)
+  $ cat `cat 1`
+  \x83Z (esc)
+  $ cat `cat 2`
+  \x83a (esc)
+  $ cat `cat 3`
+  \x83z (esc)


More information about the Mercurial-devel mailing list