Mercurial > hg
comparison tests/test-extension.t @ 41047:555215e2b051
tests: convert a test extension to use exthelper
This provides test coverage to uipopulate().
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 30 Nov 2018 21:39:55 -0500 |
parents | e8e2a7656e83 |
children | 0358cca1dccf |
comparison
equal
deleted
inserted
replaced
41046:f5ec93f69171 | 41047:555215e2b051 |
---|---|
11 > f.write(data.replace(b', flush=True', b'')) | 11 > f.write(data.replace(b', flush=True', b'')) |
12 > EOF | 12 > EOF |
13 | 13 |
14 $ cat > foobar.py <<EOF | 14 $ cat > foobar.py <<EOF |
15 > import os | 15 > import os |
16 > from mercurial import commands, registrar | 16 > from mercurial import commands, exthelper, registrar |
17 > cmdtable = {} | 17 > |
18 > command = registrar.command(cmdtable) | 18 > eh = exthelper.exthelper() |
19 > configtable = {} | 19 > eh.configitem(b'tests', b'foo', default=b"Foo") |
20 > configitem = registrar.configitem(configtable) | 20 > |
21 > configitem(b'tests', b'foo', default=b"Foo") | 21 > uisetup = eh.finaluisetup |
22 > def uisetup(ui): | 22 > uipopulate = eh.finaluipopulate |
23 > reposetup = eh.finalreposetup | |
24 > cmdtable = eh.cmdtable | |
25 > configtable = eh.configtable | |
26 > | |
27 > @eh.uisetup | |
28 > def _uisetup(ui): | |
23 > ui.debug(b"uisetup called [debug]\\n") | 29 > ui.debug(b"uisetup called [debug]\\n") |
24 > ui.write(b"uisetup called\\n") | 30 > ui.write(b"uisetup called\\n") |
25 > ui.status(b"uisetup called [status]\\n") | 31 > ui.status(b"uisetup called [status]\\n") |
26 > ui.flush() | 32 > ui.flush() |
27 > def uipopulate(ui): | 33 > @eh.uipopulate |
34 > def _uipopulate(ui): | |
28 > ui._populatecnt = getattr(ui, "_populatecnt", 0) + 1 | 35 > ui._populatecnt = getattr(ui, "_populatecnt", 0) + 1 |
29 > ui.write(b"uipopulate called (%d times)\n" % ui._populatecnt) | 36 > ui.write(b"uipopulate called (%d times)\n" % ui._populatecnt) |
30 > def reposetup(ui, repo): | 37 > @eh.reposetup |
38 > def _reposetup(ui, repo): | |
31 > ui.write(b"reposetup called for %s\\n" % os.path.basename(repo.root)) | 39 > ui.write(b"reposetup called for %s\\n" % os.path.basename(repo.root)) |
32 > ui.write(b"ui %s= repo.ui\\n" % (ui == repo.ui and b"=" or b"!")) | 40 > ui.write(b"ui %s= repo.ui\\n" % (ui == repo.ui and b"=" or b"!")) |
33 > ui.flush() | 41 > ui.flush() |
34 > @command(b'foo', [], b'hg foo') | 42 > @eh.command(b'foo', [], b'hg foo') |
35 > def foo(ui, *args, **kwargs): | 43 > def foo(ui, *args, **kwargs): |
36 > foo = ui.config(b'tests', b'foo') | 44 > foo = ui.config(b'tests', b'foo') |
37 > ui.write(foo) | 45 > ui.write(foo) |
38 > ui.write(b"\\n") | 46 > ui.write(b"\\n") |
39 > @command(b'bar', [], b'hg bar', norepo=True) | 47 > @eh.command(b'bar', [], b'hg bar', norepo=True) |
40 > def bar(ui, *args, **kwargs): | 48 > def bar(ui, *args, **kwargs): |
41 > ui.write(b"Bar\\n") | 49 > ui.write(b"Bar\\n") |
42 > EOF | 50 > EOF |
43 $ abspath=`pwd`/foobar.py | 51 $ abspath=`pwd`/foobar.py |
44 | 52 |