changeset 37338:cbc4425e81b5

tests: conditionalize tests based on presence of revlogs for files ~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. Differential Revision: https://phab.mercurial-scm.org/D3030
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 03 Apr 2018 18:15:24 -0700
parents d257c5f2a940
children 5859800edfc5
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-subrepo-recursion.t tests/test-upgrade-repo.t
diffstat 14 files changed, 112 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/tests/hghave.py	Wed Apr 04 11:37:07 2018 -0700
+++ b/tests/hghave.py	Tue Apr 03 18:15:24 2018 -0700
@@ -717,3 +717,47 @@
         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 = {
+        'revlogstore',
+    }
+
+    # Features that imply other features.
+    implies = {
+        'simplestore': ['-revlogstore'],
+    }
+
+    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('reporevlogstore', 'repository using the default revlog store')
+def has_reporevlogstore():
+    return 'revlogstore' in getrepofeatures()
+
+@check('reposimplestore', 'repository using simple storage extension')
+def has_reposimplestore():
+    return 'simplestore' in getrepofeatures()
--- a/tests/simplestorerepo.py	Wed Apr 04 11:37:07 2018 -0700
+++ b/tests/simplestorerepo.py	Tue Apr 03 18:15:24 2018 -0700
@@ -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 _
--- a/tests/test-clone.t	Wed Apr 04 11:37:07 2018 -0700
+++ b/tests/test-clone.t	Tue Apr 03 18:15:24 2018 -0700
@@ -28,12 +28,14 @@
 
 List files in store/data (should show a 'b.d'):
 
+#if reporevlogstore
   $ 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:
 
--- a/tests/test-contrib-perf.t	Wed Apr 04 11:37:07 2018 -0700
+++ b/tests/test-contrib-perf.t	Tue Apr 03 18:15:24 2018 -0700
@@ -158,7 +158,9 @@
   $ hg perfpathcopies 1 2
   $ hg perfrawfiles 2
   $ hg perfrevlogindex -c
+#if reporevlogstore
   $ hg perfrevlogrevisions .hg/store/data/a.i
+#endif
   $ hg perfrevlogrevision -m 0
   $ hg perfrevlogchunks -c
   $ hg perfrevrange
--- a/tests/test-convert.t	Wed Apr 04 11:37:07 2018 -0700
+++ b/tests/test-convert.t	Tue Apr 03 18:15:24 2018 -0700
@@ -516,8 +516,14 @@
 contents of fncache file:
 
   $ cat b/.hg/store/fncache | sort
-  data/a.i
-  data/b.i
+  data/a.i (reporevlogstore !)
+  data/b.i (reporevlogstore !)
+  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
 
--- a/tests/test-copy.t	Wed Apr 04 11:37:07 2018 -0700
+++ b/tests/test-copy.t	Tue Apr 03 18:15:24 2018 -0700
@@ -86,8 +86,10 @@
   copy: a
   copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
 
+#if reporevlogstore
   $ md5sum.py .hg/store/data/b.i
   44913824c8f5890ae218f9829535922e  .hg/store/data/b.i
+#endif
   $ hg cat b > bsum
   $ md5sum.py bsum
   60b725f10c9c85c70d97880dfe8191b3  bsum
--- a/tests/test-hardlinks.t	Wed Apr 04 11:37:07 2018 -0700
+++ b/tests/test-hardlinks.t	Tue Apr 03 18:15:24 2018 -0700
@@ -1,4 +1,4 @@
-#require hardlink
+#require hardlink reporevlogstore
 
   $ cat > nlinks.py <<EOF
   > from __future__ import print_function
--- a/tests/test-http-proxy.t	Wed Apr 04 11:37:07 2018 -0700
+++ b/tests/test-http-proxy.t	Tue Apr 03 18:15:24 2018 -0700
@@ -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 (reporevlogstore !)
+  4 files to transfer, 330 bytes of data (reposimplestore !)
   transferred * bytes in * seconds (*/sec) (glob)
   searching for changes
   no changes found
--- a/tests/test-push-warn.t	Wed Apr 04 11:37:07 2018 -0700
+++ b/tests/test-push-warn.t	Tue Apr 03 18:15:24 2018 -0700
@@ -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
--- a/tests/test-relink.t	Wed Apr 04 11:37:07 2018 -0700
+++ b/tests/test-relink.t	Tue Apr 03 18:15:24 2018 -0700
@@ -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
--- a/tests/test-strip.t	Wed Apr 04 11:37:07 2018 -0700
+++ b/tests/test-strip.t	Tue Apr 03 18:15:24 2018 -0700
@@ -448,6 +448,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)
--- a/tests/test-subrepo-deep-nested-change.t	Wed Apr 04 11:37:07 2018 -0700
+++ b/tests/test-subrepo-deep-nested-change.t	Tue Apr 03 18:15:24 2018 -0700
@@ -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
--- a/tests/test-subrepo-recursion.t	Wed Apr 04 11:37:07 2018 -0700
+++ b/tests/test-subrepo-recursion.t	Tue Apr 03 18:15:24 2018 -0700
@@ -462,6 +462,11 @@
   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 !)
+  linking [            <=>                               ] 12\r (no-eol) (esc) (reposimplestore !)
+  linking [             <=>                              ] 13\r (no-eol) (esc) (reposimplestore !)
                                                               \r (no-eol) (esc)
 #else
   $ hg clone -U . ../empty
@@ -487,6 +492,13 @@
   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 !)
+  linking [            <=>                               ] 12\r (no-eol) (esc) (reposimplestore !)
+  linking [             <=>                              ] 13\r (no-eol) (esc) (reposimplestore !)
+  linking [              <=>                             ] 14\r (no-eol) (esc) (reposimplestore !)
+  linking [               <=>                            ] 15\r (no-eol) (esc) (reposimplestore !)
                                                               \r (no-eol) (esc)
   \r (no-eol) (esc)
   archiving (foo) [                                     ] 0/3\r (no-eol) (esc)
@@ -501,6 +513,9 @@
   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 !)
+  linking [        <=>                                    ] 8\r (no-eol) (esc) (reposimplestore !)
+  linking [         <=>                                   ] 9\r (no-eol) (esc) (reposimplestore !)
                                                               \r (no-eol) (esc)
   \r (no-eol) (esc)
   archiving (foo/bar) [                                 ] 0/1\r (no-eol) (esc)
--- a/tests/test-upgrade-repo.t	Wed Apr 04 11:37:07 2018 -0700
+++ b/tests/test-upgrade-repo.t	Tue Apr 03 18:15:24 2018 -0700
@@ -1,3 +1,5 @@
+#require no-reposimplestore
+
   $ cat >> $HGRCPATH << EOF
   > [extensions]
   > share =