tests: convert some 'hghave execbit' to #if
authorMads Kiilerich <mads@kiilerich.com>
Sun, 10 Jun 2012 14:14:05 +0200
changeset 16899 8149ff405c78
parent 16898 bb91c602d4ad
child 16900 3f1a153daadb
tests: convert some 'hghave execbit' to #if This enables some new tests for running on windows.
tests/test-convert-bzr.t
tests/test-convert-hg-source.t
tests/test-convert-svn-sink.t
tests/test-diff-color.t
tests/test-extdiff.t
tests/test-git-export.t
tests/test-import-bypass.t
tests/test-mq.t
tests/test-record.t
--- a/tests/test-convert-bzr.t	Sun Jun 10 13:01:40 2012 +0200
+++ b/tests/test-convert-bzr.t	Sun Jun 10 14:14:05 2012 +0200
@@ -1,5 +1,3 @@
-  $ "$TESTDIR/hghave" symlink execbit || exit 80
-
   $ . "$TESTDIR/bzr-definitions"
 
 create and rename on the same file in the same step
@@ -157,6 +155,8 @@
   
   $ cd ..
 
+#if symlink execbit
+
 symlinks and executable files
 
   $ mkdir test-symlinks
@@ -199,14 +199,17 @@
   755 * newprog
   644   program
   644 @ syma
-  $ cd source-hg
 
 test the symlinks can be recreated
 
+  $ cd source-hg
   $ hg up
   5 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg cat syma; echo
   a
+  $ cd ../..
+
+#endif
 
 Multiple branches
 
--- a/tests/test-convert-hg-source.t	Sun Jun 10 13:01:40 2012 +0200
+++ b/tests/test-convert-hg-source.t	Sun Jun 10 14:14:05 2012 +0200
@@ -1,5 +1,3 @@
-  $ "$TESTDIR/hghave" execbit || exit 80
-
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
   > convert=
@@ -33,7 +31,11 @@
   (branch merge, don't forget to commit)
   $ hg ci -m 'merge remote copy' -d '4 0'
   created new head
+#if execbit
   $ chmod +x baz
+#else
+  $ echo some other change to make sure we get a rev 5 > baz
+#endif
   $ hg ci -m 'mark baz executable' -d '5 0'
   $ cd ..
   $ hg convert --datesort orig new 2>&1 | grep -v 'subversion python bindings could not be loaded'
@@ -54,9 +56,16 @@
   searching for changes
   no changes found
   [1]
+#if execbit
   $ hg bookmarks
      premerge1                 3:973ef48a98a4
      premerge2                 5:13d9b87cf8f8
+#else
+Different hash because no x bit
+  $ hg bookmarks
+     premerge1                 3:973ef48a98a4
+     premerge2                 5:df0779bcf33c
+#endif
   $ cd ..
 
 check shamap LF and CRLF handling
--- a/tests/test-convert-svn-sink.t	Sun Jun 10 13:01:40 2012 +0200
+++ b/tests/test-convert-svn-sink.t	Sun Jun 10 14:14:05 2012 +0200
@@ -1,4 +1,4 @@
-  $ "$TESTDIR/hghave" svn13 no-outer-repo symlink execbit || exit 80
+  $ "$TESTDIR/hghave" svn13 no-outer-repo symlink || exit 80
 
   $ fixpath()
   > {
@@ -202,12 +202,21 @@
   d1
   newlink
 
-Exectutable
+Executable
 
+#if execbit
   $ chmod +x a/c
+#else
+  $ echo fake >> a/c
+#endif
   $ hg --cwd a ci -d '5 0' -m 'make a file executable'
+#if execbit
   $ hg --cwd a tip -q
   5:31093672760b
+#else
+  $ hg --cwd a tip -q
+  5:034971d37224
+#endif
 
   $ hg convert -d svn a
   assuming destination a-hg
@@ -227,16 +236,22 @@
   author: test
   msg: make a file executable
    M /c
+#if execbit
   $ test -x a-hg-wc/c
+#endif
+  $ rm -rf a a-hg a-hg-wc
 
 Executable in new directory
 
-  $ rm -rf a a-hg a-hg-wc
   $ hg init a
 
   $ mkdir a/d1
   $ echo a > a/d1/a
+#if execbit
   $ chmod +x a/d1/a
+#else
+  $ echo fake >> a/d1/a
+#endif
   $ hg --cwd a ci -d '0 0' -A -m 'add executable file in new directory'
   adding d1/a
 
@@ -257,7 +272,9 @@
   msg: add executable file in new directory
    A /d1
    A /d1/a
+#if execbit
   $ test -x a-hg-wc/d1/a
+#endif
 
 Copy to new directory
 
--- a/tests/test-diff-color.t	Sun Jun 10 13:01:40 2012 +0200
+++ b/tests/test-diff-color.t	Sun Jun 10 14:14:05 2012 +0200
@@ -1,5 +1,3 @@
-  $ "$TESTDIR/hghave" execbit || exit 80
-
 Setup
 
   $ echo "[color]" >> $HGRCPATH
@@ -74,6 +72,8 @@
   $ echo "[diff]" >> $HGRCPATH
   $ echo "git=True" >> $HGRCPATH
 
+#if execbit
+
 record
 
   $ chmod +x a
@@ -124,3 +124,5 @@
    a
    c
   \x1b[0;33mrecord this change to 'a'? [Ynesfdaq?]\x1b[0m  (esc)
+
+#endif
--- a/tests/test-extdiff.t	Sun Jun 10 13:01:40 2012 +0200
+++ b/tests/test-extdiff.t	Sun Jun 10 14:14:05 2012 +0200
@@ -1,5 +1,3 @@
-  $ "$TESTDIR/hghave" symlink execbit || exit 80
-
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "extdiff=" >> $HGRCPATH
 
@@ -94,6 +92,8 @@
   diffing */extdiff.*/a.2a13a4d2da36/a a.46c0e4daeb72/a (glob)
   diff-like tools yield a non-zero exit code
 
+#if execbit
+
 Test extdiff of multiple files in tmp dir:
 
   $ hg update -C 0 > /dev/null
@@ -182,6 +182,10 @@
 
   $ cd ..
 
+#endif
+
+#if symlink
+
 Test symlinks handling (issue1909)
 
   $ hg init testsymlinks
@@ -196,3 +200,5 @@
   diffing testsymlinks.07f494440405 testsymlinks
   [1]
   $ cd ..
+
+#endif
--- a/tests/test-git-export.t	Sun Jun 10 13:01:40 2012 +0200
+++ b/tests/test-git-export.t	Sun Jun 10 14:14:05 2012 +0200
@@ -1,5 +1,3 @@
-  $ "$TESTDIR/hghave" execbit || exit 80
-
   $ hg init
   $ echo start > start
   $ hg ci -Amstart
@@ -58,6 +56,8 @@
   $ hg ci -Amsrc
   adding src
 
+#if execbit
+
 chmod 644:
 
   $ chmod +x src
@@ -94,6 +94,17 @@
   old mode 100644
   new mode 100755
 
+#else
+
+Dummy changes when no exec bit, mocking the execbit commit structure
+
+  $ echo change >> src
+  $ hg ci -munexec
+  $ hg mv src dst
+  $ hg ci -mrenamemod
+
+#endif
+
 Binary diff:
 
   $ cp "$TESTDIR/binfile.bin" .
--- a/tests/test-import-bypass.t	Sun Jun 10 13:01:40 2012 +0200
+++ b/tests/test-import-bypass.t	Sun Jun 10 14:14:05 2012 +0200
@@ -1,5 +1,3 @@
-  $ "$TESTDIR/hghave" symlink execbit || exit 80
-
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "purge=" >> $HGRCPATH
   $ echo "graphlog=" >> $HGRCPATH
@@ -218,6 +216,8 @@
 
   $ cd ..
 
+#if symlink execbit
+
 Test complicated patch with --exact
 
   $ hg init repo-exact
@@ -265,3 +265,4 @@
   |
   o  0:a0e19e636a43 test 0 0 - default - t
   
+#endif
--- a/tests/test-mq.t	Sun Jun 10 13:01:40 2012 +0200
+++ b/tests/test-mq.t	Sun Jun 10 14:14:05 2012 +0200
@@ -1,5 +1,3 @@
-  $ "$TESTDIR/hghave" execbit || exit 80
-
   $ checkundo()
   > {
   >     if [ -f .hg/store/undo ]; then
@@ -918,9 +916,12 @@
 
   $ hg qnew -m'new file' new
   $ echo foo > new
+#if execbit
   $ chmod +x new
+#endif
   $ hg add new
   $ hg qrefresh
+#if execbit
   $ cat .hg/patches/new
   new file
   
@@ -930,6 +931,17 @@
   +++ b/new
   @@ -0,0 +1,1 @@
   +foo
+#else
+  $ cat .hg/patches/new
+  new file
+  
+  diff --git a/new b/new
+  new file mode 100644
+  --- /dev/null
+  +++ b/new
+  @@ -0,0 +1,1 @@
+  +foo
+#endif
 
   $ hg qnew -m'copy file' copy
   $ hg cp new copy
--- a/tests/test-record.t	Sun Jun 10 13:01:40 2012 +0200
+++ b/tests/test-record.t	Sun Jun 10 14:14:05 2012 +0200
@@ -772,6 +772,8 @@
   +a
   
 
+#if execbit
+
 Preserve chmod +x
 
   $ chmod +x f1
@@ -885,8 +887,120 @@
   +c
   
 
+#else
+
+Slightly bogus tests to get almost same repo structure as when x bit is used
+- but with different hashes.
+
+Mock "Preserve chmod +x"
+
+  $ echo a >> f1
+  $ hg record -d '20 0' -mz <<EOF
+  > y
+  > y
+  > y
+  > EOF
+  diff --git a/subdir/f1 b/subdir/f1
+  1 hunks, 1 lines changed
+  examine changes to 'subdir/f1'? [Ynesfdaq?] 
+  @@ -1,2 +1,3 @@
+   a
+   a
+  +a
+  record this change to 'subdir/f1'? [Ynesfdaq?] 
+
+  $ hg tip --config diff.git=True -p
+  changeset:   22:0d463bd428f5
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:20 1970 +0000
+  summary:     z
+  
+  diff --git a/subdir/f1 b/subdir/f1
+  --- a/subdir/f1
+  +++ b/subdir/f1
+  @@ -1,2 +1,3 @@
+   a
+   a
+  +a
+  
+
+Mock "Preserve execute permission on original"
+
+  $ echo b >> f1
+  $ hg record -d '21 0' -maa <<EOF
+  > y
+  > y
+  > y
+  > EOF
+  diff --git a/subdir/f1 b/subdir/f1
+  1 hunks, 1 lines changed
+  examine changes to 'subdir/f1'? [Ynesfdaq?] 
+  @@ -1,3 +1,4 @@
+   a
+   a
+   a
+  +b
+  record this change to 'subdir/f1'? [Ynesfdaq?] 
+
+  $ hg tip --config diff.git=True -p
+  changeset:   23:0eab41a3e524
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:21 1970 +0000
+  summary:     aa
+  
+  diff --git a/subdir/f1 b/subdir/f1
+  --- a/subdir/f1
+  +++ b/subdir/f1
+  @@ -1,3 +1,4 @@
+   a
+   a
+   a
+  +b
+  
+
+Mock "Preserve chmod -x"
+
+  $ chmod -x f1
+  $ echo c >> f1
+  $ hg record -d '22 0' -mab <<EOF
+  > y
+  > y
+  > y
+  > EOF
+  diff --git a/subdir/f1 b/subdir/f1
+  1 hunks, 1 lines changed
+  examine changes to 'subdir/f1'? [Ynesfdaq?] 
+  @@ -2,3 +2,4 @@
+   a
+   a
+   b
+  +c
+  record this change to 'subdir/f1'? [Ynesfdaq?] 
+
+  $ hg tip --config diff.git=True -p
+  changeset:   24:f4f718f27b7c
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:22 1970 +0000
+  summary:     ab
+  
+  diff --git a/subdir/f1 b/subdir/f1
+  --- a/subdir/f1
+  +++ b/subdir/f1
+  @@ -2,3 +2,4 @@
+   a
+   a
+   b
+  +c
+  
+
+#endif
+
   $ cd ..
 
+
 Abort early when a merge is in progress
 
   $ hg up 4
@@ -1096,13 +1210,13 @@
   record this change to 'subdir/f1'? [Ynesfdaq?] 
 
   $ hg tip -p
-  changeset:   28:287ad1f41a72
+  changeset:   28:* (glob)
   tag:         tip
   user:        test
   date:        Thu Jan 01 00:00:24 1970 +0000
   summary:     w1
   
-  diff -r 65ce23a81197 -r 287ad1f41a72 subdir/f1
+  diff -r ???????????? -r ???????????? subdir/f1 (glob)
   --- a/subdir/f1	Thu Jan 01 00:00:23 1970 +0000
   +++ b/subdir/f1	Thu Jan 01 00:00:24 1970 +0000
   @@ -3,3 +3,4 @@