sapling/tests/test-fb-hgext-remotefilelog-lfs-prefetch.t
Jun Wu f5924da1d3 tests: improve test compatibility with different zlib
Summary:
When running with a Python runtime with a slightly different zlib module,
some `zlib.compress` outputs are different. Some tests are testing the
length, or the content of `zlib.compress` output, directly or indirectly.
That's causing issues.

This patch adds a `common-zlib` hghave test so it can be used to gate tests
checking zlib output. Some lengths are also changed to glob patterns to be
compatible.

Reviewed By: ryanmce

Differential Revision: D6937735

fbshipit-source-id: 2328a39d7f2022f16d51f61b6178568b26dfe2fb
2018-04-13 21:51:09 -07:00

99 lines
2.2 KiB
Perl

$ LFSPATH=$TESTTMP/lfs
$ export LFSPATH
$ mkdir $LFSPATH
$ . "$TESTDIR/library.sh"
$ hginit master
$ cd master
$ cat >> $HGRCPATH <<EOF
> [extensions]
> lfs=
> [lfs]
> url=file://$LFSPATH
> EOF
$ cat >> .hg/hgrc <<EOF
> [remotefilelog]
> server=True
> EOF
$ echo x > x
$ echo z > z
$ hg commit -qAm x
$ echo x2 > x
$ echo y > y
$ hg commit -qAm y
$ echo large > large
$ hg --config 'lfs.threshold=1' commit -qAm y
$ hg bookmark foo
$ hg debuglfsupload -r tip
$ cd ..
# prefetch a revision
$ hgcloneshallowlfs ssh://user@dummy/master shallow file://$LFSPATH --noupdate
streaming all changes
2 files to transfer, * bytes of data (glob)
transferred * bytes in * seconds (*) (glob)
searching for changes
no changes found
$ cd shallow
$ hg prefetch -r 0
2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob)
$ hg cat -r 0 x
x
# prefetch a range of revisions
$ clearcache
$ hg prefetch -r 0::1
4 files fetched over 1 fetches - (4 misses, 0.00% hit ratio) over *s (glob)
$ hg cat -r 0 x
x
$ hg cat -r 1 x
x2
# prefetch certain files
$ clearcache
$ hg prefetch -r 1 x
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
$ hg cat -r 1 x
x2
$ hg cat -r 1 y
y
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
# prefetch large file
$ hg prefetch -r 2
2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob)
# prefetch on pull when configured
$ printf "[remotefilelog]\npullprefetch=bookmark()\n" >> .hg/hgrc
$ hg strip tip
saved backup bundle to $TESTTMP/shallow/.hg/strip-backup/730e2b7b175c-acada81e-backup.hg (glob)
$ clearcache
$ hg pull
pulling from ssh://user@dummy/master
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 0 changes to 0 files
updating bookmark foo
new changesets 730e2b7b175c
(run 'hg update' to get a working copy)
prefetching file contents
4 files fetched over 1 fetches - (4 misses, 0.00% hit ratio) over *s (glob)
$ hg up tip
4 files updated, 0 files merged, 0 files removed, 0 files unresolved