# HG changeset patch # User Gregory Szorc # Date 2018-04-04 01:15:24 # Node ID cbc4425e81b54aa803aae51f3aa2ed2cc5c7595b # Parent d257c5f2a940d9e411ceb5fa2f7d60e283be12d9 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 diff --git a/tests/hghave.py b/tests/hghave.py --- a/tests/hghave.py +++ b/tests/hghave.py @@ -717,3 +717,47 @@ def has_xdiff(): 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() 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/test-clone.t b/tests/test-clone.t --- a/tests/test-clone.t +++ b/tests/test-clone.t @@ -28,12 +28,14 @@ Create a non-inlined filelog: 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: 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 @@ perfstatus $ 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 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 @@ testing: convert must not produce duplic 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 diff --git a/tests/test-copy.t b/tests/test-copy.t --- a/tests/test-copy.t +++ b/tests/test-copy.t @@ -86,8 +86,10 @@ this should show the rename information 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 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 reporevlogstore $ cat > nlinks.py < from __future__ import print_function 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 @@ url for proxy, stream $ 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 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 @@ Specifying a revset that evaluates to nu 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-relink.t b/tests/test-relink.t --- a/tests/test-relink.t +++ b/tests/test-relink.t @@ -73,6 +73,8 @@ clone and pull to break links 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 @@ check hardlinks $ $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-strip.t b/tests/test-strip.t --- a/tests/test-strip.t +++ b/tests/test-strip.t @@ -448,6 +448,7 @@ verify fncache is kept up-to-date $ 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-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 @@ Preparing the 'sub1' repo which depends 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 @@ Preparing the 'main' repo which depends 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 @@ Preparing the 'main' repo which depends 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 @@ Clone main 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 @@ Clone main 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-subrepo-recursion.t b/tests/test-subrepo-recursion.t --- a/tests/test-subrepo-recursion.t +++ b/tests/test-subrepo-recursion.t @@ -462,6 +462,11 @@ cloned: 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 @@ cloned: 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 @@ cloned: 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) 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 =