Patchwork D3030: tests: conditionalize tests based on presence of revlogs for files

login
register
mail settings
Submitter phabricator
Date April 3, 2018, 3:54 a.m.
Message ID <differential-rev-PHID-DREV-y23yio4q4cro45dft2l4-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30153/
State Superseded
Headers show

Comments

phabricator - April 3, 2018, 3:54 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  ~85 tests don't like our non-revlog file store for various reasons.
  
  This commit introduces hghave functionality for declaring and querying
  repository features. By default, we assume repositories have
  revlog-based file storage. But if the HGREPOFEATURES environment
  variable is set, we can override the default set of repository
  features. If you run the test harness with our simplestorerepo
  extension and an environment variable set to the proper value, you
  can override the hghave defaults to agree with simplestorerepo's
  version of reality.
  
  Various tests have been modified so behavior dependent on revlog-based
  file storage is marked as such.
  
  This fixes a handful of test failures with our custom file storage
  extension. But dozens remain. The point of this commit is to demonstrate
  how tests will need to be modified to account for custom storage
  implementations.
  
  TBH, I'm not convinced hghave is the proper layer for repository
  feature detection. I /think/ we'll eventually want something in
  run-tests.py itself. But that would require inventing a new primitive
  in the test harness. This is all very alpha at the moment. So I think
  hghave is an acceptable place to hang this feature detection. I think
  the right time to be thinking about integrating this into run-tests.py
  is *after* we have a stable alternate storage implementation in core.
  For now, let's try to make progress towards the idea of an alternate
  storage backend.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3030

AFFECTED FILES
  tests/hghave.py
  tests/simplestorerepo.py
  tests/test-clone.t
  tests/test-contrib-perf.t
  tests/test-convert.t
  tests/test-copy.t
  tests/test-hardlinks.t
  tests/test-http-proxy.t
  tests/test-push-warn.t
  tests/test-relink.t
  tests/test-strip.t
  tests/test-subrepo-deep-nested-change.t
  tests/test-upgrade-repo.t

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel
phabricator - April 3, 2018, 9:19 p.m.
indygreg planned changes to this revision.
indygreg added a comment.


  After porting several more tests, I plan to make some tweaks to this.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3030

To: indygreg, #hg-reviewers
Cc: mercurial-devel
phabricator - April 4, 2018, 6:04 p.m.
durin42 accepted this revision.
durin42 added a comment.
This revision is now accepted and ready to land.


  Seems fine for now, we may need to revisit it later if we get too many stores.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3030

To: indygreg, #hg-reviewers, durin42
Cc: durin42, mercurial-devel

Patch

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -1,3 +1,5 @@ 
+#require no-reposimplestore
+
   $ cat >> $HGRCPATH << EOF
   > [extensions]
   > share =
diff --git a/tests/test-subrepo-deep-nested-change.t b/tests/test-subrepo-deep-nested-change.t
--- a/tests/test-subrepo-deep-nested-change.t
+++ b/tests/test-subrepo-deep-nested-change.t
@@ -34,6 +34,7 @@ 
   linking [    <=>                                        ] 4\r (no-eol) (esc)
   linking [     <=>                                       ] 5\r (no-eol) (esc)
   linking [      <=>                                      ] 6\r (no-eol) (esc)
+  linking [       <=>                                     ] 7\r (no-eol) (esc) (reposimplestore !)
                                                               \r (no-eol) (esc)
   \r (no-eol) (esc)
   updating [===========================================>] 1/1\r (no-eol) (esc)
@@ -60,6 +61,9 @@ 
   linking [      <=>                                      ] 6\r (no-eol) (esc)
   linking [       <=>                                     ] 7\r (no-eol) (esc)
   linking [        <=>                                    ] 8\r (no-eol) (esc)
+  linking [         <=>                                   ] 9\r (no-eol) (esc) (reposimplestore !)
+  linking [          <=>                                 ] 10\r (no-eol) (esc) (reposimplestore !)
+  linking [           <=>                                ] 11\r (no-eol) (esc) (reposimplestore !)
                                                               \r (no-eol) (esc)
   \r (no-eol) (esc)
   updating [===========================================>] 3/3\r (no-eol) (esc)
@@ -71,6 +75,7 @@ 
   linking [    <=>                                        ] 4\r (no-eol) (esc)
   linking [     <=>                                       ] 5\r (no-eol) (esc)
   linking [      <=>                                      ] 6\r (no-eol) (esc)
+  linking [       <=>                                     ] 7\r (no-eol) (esc) (reposimplestore !)
   updating [===========================================>] 1/1\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
   updating to branch default
@@ -161,6 +166,9 @@ 
   linking [      <=>                                      ] 6\r (no-eol) (esc)
   linking [       <=>                                     ] 7\r (no-eol) (esc)
   linking [        <=>                                    ] 8\r (no-eol) (esc)
+  linking [         <=>                                   ] 9\r (no-eol) (esc) (reposimplestore !)
+  linking [          <=>                                 ] 10\r (no-eol) (esc) (reposimplestore !)
+  linking [           <=>                                ] 11\r (no-eol) (esc) (reposimplestore !)
                                                               \r (no-eol) (esc)
   \r (no-eol) (esc)
   updating [===========================================>] 3/3\r (no-eol) (esc)
@@ -174,15 +182,25 @@ 
   linking [      <=>                                      ] 6\r (no-eol) (esc)
   linking [       <=>                                     ] 7\r (no-eol) (esc)
   linking [        <=>                                    ] 8\r (no-eol) (esc)
+  linking [         <=>                                   ] 9\r (no-eol) (esc) (reposimplestore !)
+  linking [          <=>                                 ] 10\r (no-eol) (esc) (reposimplestore !)
+  linking [           <=>                                ] 11\r (no-eol) (esc) (reposimplestore !)
   updating [===========================================>] 3/3\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
   \r (no-eol) (esc)
-  linking [         <=>                                   ] 1\r (no-eol) (esc)
-  linking [          <=>                                  ] 2\r (no-eol) (esc)
-  linking [           <=>                                 ] 3\r (no-eol) (esc)
-  linking [            <=>                                ] 4\r (no-eol) (esc)
-  linking [             <=>                               ] 5\r (no-eol) (esc)
-  linking [              <=>                              ] 6\r (no-eol) (esc)
+  linking [         <=>                                   ] 1\r (no-eol) (esc) (no-reposimplestore !)
+  linking [          <=>                                  ] 2\r (no-eol) (esc) (no-reposimplestore !)
+  linking [           <=>                                 ] 3\r (no-eol) (esc) (no-reposimplestore !)
+  linking [            <=>                                ] 4\r (no-eol) (esc) (no-reposimplestore !)
+  linking [             <=>                               ] 5\r (no-eol) (esc) (no-reposimplestore !)
+  linking [              <=>                              ] 6\r (no-eol) (esc) (no-reposimplestore !)
+  linking [            <=>                                ] 1\r (no-eol) (esc) (reposimplestore !)
+  linking [             <=>                               ] 2\r (no-eol) (esc) (reposimplestore !)
+  linking [              <=>                              ] 3\r (no-eol) (esc) (reposimplestore !)
+  linking [               <=>                             ] 4\r (no-eol) (esc) (reposimplestore !)
+  linking [                <=>                            ] 5\r (no-eol) (esc) (reposimplestore !)
+  linking [                 <=>                           ] 6\r (no-eol) (esc) (reposimplestore !)
+  linking [                  <=>                          ] 7\r (no-eol) (esc) (reposimplestore !)
   updating [===========================================>] 1/1\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
   updating to branch default
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -452,6 +452,7 @@ 
   $ cat .hg/store/fncache | sort
   data/a.i
   data/bar.i
+
   $ hg strip tip
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
diff --git a/tests/test-relink.t b/tests/test-relink.t
--- a/tests/test-relink.t
+++ b/tests/test-relink.t
@@ -73,6 +73,8 @@ 
 
 relink
 
+#if no-reposimplestore
+
   $ hg relink --debug --config progress.debug=true | fix_path
   relinking $TESTTMP/repo/.hg/store to $TESTTMP/clone/.hg/store
   tip has 2 files, estimated total number of files: 3
@@ -101,3 +103,4 @@ 
   $ $PYTHON arelinked.py repo/.hg/store/data/b.i clone/.hg/store/data/b.i
   repo/.hg/store/data/b.i != clone/.hg/store/data/b.i
 
+#endif
diff --git a/tests/test-push-warn.t b/tests/test-push-warn.t
--- a/tests/test-push-warn.t
+++ b/tests/test-push-warn.t
@@ -153,7 +153,7 @@ 
   uncompressed size of bundle content:
        352 (changelog)
        326 (manifests)
-       253  foo
+       25\d  foo (re)
   adding changesets
   adding manifests
   adding file changes
diff --git a/tests/test-http-proxy.t b/tests/test-http-proxy.t
--- a/tests/test-http-proxy.t
+++ b/tests/test-http-proxy.t
@@ -16,7 +16,8 @@ 
 
   $ http_proxy=http://localhost:$HGPORT1/ hg --config http_proxy.always=True clone --stream http://localhost:$HGPORT/ b
   streaming all changes
-  3 files to transfer, 303 bytes of data
+  3 files to transfer, 303 bytes of data (repodefaultstore !)
+  4 files to transfer, 330 bytes of data (reposimplestore !)
   transferred * bytes in * seconds (*/sec) (glob)
   searching for changes
   no changes found
diff --git a/tests/test-hardlinks.t b/tests/test-hardlinks.t
--- a/tests/test-hardlinks.t
+++ b/tests/test-hardlinks.t
@@ -1,4 +1,4 @@ 
-#require hardlink
+#require hardlink repodefaultstore
 
   $ cat > nlinks.py <<EOF
   > from __future__ import print_function
diff --git a/tests/test-copy.t b/tests/test-copy.t
--- a/tests/test-copy.t
+++ b/tests/test-copy.t
@@ -93,8 +93,10 @@ 
   copy: a
   copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
 
+#if repofilerevlogs
   $ md5sum.py .hg/store/data/b.i
   44913824c8f5890ae218f9829535922e  .hg/store/data/b.i
+#endif
   $ hg cat b > bsum
   $ md5sum.py bsum
   60b725f10c9c85c70d97880dfe8191b3  bsum
diff --git a/tests/test-convert.t b/tests/test-convert.t
--- a/tests/test-convert.t
+++ b/tests/test-convert.t
@@ -516,8 +516,14 @@ 
 contents of fncache file:
 
   $ cat b/.hg/store/fncache | sort
-  data/a.i
-  data/b.i
+  data/a.i (repodefaultstore !)
+  data/b.i (repodefaultstore !)
+  data/a/0f3078c2d7345d887b54f7c9dab0d91bfa57fd07 (reposimplestore !)
+  data/a/4271c3e84237016935a176b6f282fde2128458b0 (reposimplestore !)
+  data/a/b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 (reposimplestore !)
+  data/a/index (reposimplestore !)
+  data/b/37d9b5d994eab34eda9c16b195ace52c7b129980 (reposimplestore !)
+  data/b/index (reposimplestore !)
 
 test bogus URL
 
diff --git a/tests/test-contrib-perf.t b/tests/test-contrib-perf.t
--- a/tests/test-contrib-perf.t
+++ b/tests/test-contrib-perf.t
@@ -158,7 +158,9 @@ 
   $ hg perfpathcopies 1 2
   $ hg perfrawfiles 2
   $ hg perfrevlogindex -c
+#if repofilerevlogs
   $ hg perfrevlogrevisions .hg/store/data/a.i
+#endif
   $ hg perfrevlogrevision -m 0
   $ hg perfrevlogchunks -c
   $ hg perfrevrange
diff --git a/tests/test-clone.t b/tests/test-clone.t
--- a/tests/test-clone.t
+++ b/tests/test-clone.t
@@ -28,12 +28,14 @@ 
 
 List files in store/data (should show a 'b.d'):
 
+#if repodefaultstore
   $ for i in .hg/store/data/*; do
   >   echo $i
   > done
   .hg/store/data/a.i
   .hg/store/data/b.d
   .hg/store/data/b.i
+#endif
 
 Trigger branchcache creation:
 
diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -5,6 +5,11 @@ 
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
+# To use this with the test suite:
+#
+#   $ HGREPOFEATURES="simplestore" ./run-tests.py \
+#       --extra-config-opt extensions.simplestore=`pwd`/simplestorerepo.py
+
 from __future__ import absolute_import
 
 from mercurial.i18n import _
diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -717,3 +717,52 @@ 
         return bdiff.xdiffblocks(b'', b'') == [(0, 0, 0, 0)]
     except (ImportError, AttributeError):
         return False
+
+def getrepofeatures():
+    """Obtain set of repository features in use.
+
+    HGREPOFEATURES can be used to define or remove features. It contains
+    a space-delimited list of feature strings. Strings beginning with ``-``
+    mean to remove.
+    """
+    # Default list provided by core.
+    features = {
+        'defaultstore',
+        'filerevlogs',
+    }
+
+    # Features that imply other features.
+    implies = {
+        'simplestore': ['-defaultstore', '-filerevlogs'],
+    }
+
+    for override in os.environ.get('HGREPOFEATURES', '').split(' '):
+        if not override:
+            continue
+
+        if override.startswith('-'):
+            if override[1:] in features:
+                features.remove(override[1:])
+        else:
+            features.add(override)
+
+            for imply in implies.get(override, []):
+                if imply.startswith('-'):
+                    if imply[1:] in features:
+                        features.remove(imply[1:])
+                else:
+                    features.add(imply)
+
+    return features
+
+@check('repofilerevlogs', 'repository using revlogs for file storage')
+def has_repofilerevlogs():
+    return 'filerevlogs' in getrepofeatures()
+
+@check('repodefaultstore', 'repository using the default revlog store')
+def has_repodefaultstore():
+    return 'defaultstore' in getrepofeatures()
+
+@check('reposimplestore', 'repository using simple storage extension')
+def has_reposimplestore():
+    return 'simplestore' in getrepofeatures()