sapling/eden/scm/tests/test-ext-logginghelper.t
Muir Manders 72c1ae759b sampling: use Rust to log samples
Summary: Expose sampling-category-for-key and append-sampling-event methods from Rust to Python to replace relevant logic in ui.py. This consolidates things, and may fix the issue where corrupted keys like "foo{" were getting into the sampled data.

Reviewed By: zzl0

Differential Revision: D44645798

fbshipit-source-id: e158ed7434435e1d29222cda2fc1cf0ee345010a
2023-04-04 17:57:02 -07:00

58 lines
1.1 KiB
Perl

#debugruntest-compatible
#inprocess-hg-incompatible
$ . "$TESTDIR/library.sh"
$ eagerepo
$ enable logginghelper
$ enable sampling
$ setconfig sampling.key.logginghelper=logginghelper
$ hg init repo123
$ cd repo123
$ export SCM_SAMPLING_FILEPATH="$TESTTMP/sample"
>>> def get_repo():
... import json, sys, os
... path = os.getenv("SCM_SAMPLING_FILEPATH")
... with open(path, "rb") as f:
... content = f.read()
... os.unlink(path)
... for line in content.split(b"\0"):
... obj = json.loads(line.decode())
... repo = obj.get("data", {}).get("repo")
... if repo:
... return repo
Check we got the repository name from the local path
$ hg addremove
>>> get_repo()
'repo123'
Check that it doesn't matter where we are in the repo
$ mkdir foobar
$ cd foobar
$ hg addremove
$ hg status
>>> get_repo()
'repo123'
$ cd ..
Check we got the repository name from the remote path
$ setconfig paths.default=ssh://foo.com//bar/repo456
$ hg addremove
>>> get_repo()
'repo456'