comparison tests/blackbox-readonly-dispatch.py @ 28406:0767c2f624c6

tests: divorce blackbox test from test-dispatch.py I used test-dispatch.py to demonstrate what would happen if a log file changed from being readonly to writable, by having it replace a directory (proxy for readonly/not-writable) with a log file in between transactions of a running python process (proxy for Mercurial). This commit makes it easier for people to follow what the test is doing, by creating a real file that people can read.
author timeless <timeless@mozdev.org>
date Tue, 08 Mar 2016 20:52:57 +0000
parents tests/test-dispatch.py@1d9d29d4813a
children 853bf7d90804
comparison
equal deleted inserted replaced
28405:1d9d29d4813a 28406:0767c2f624c6
1 from __future__ import absolute_import, print_function
2 import os
3 from mercurial import (
4 dispatch,
5 )
6
7 def testdispatch(cmd):
8 """Simple wrapper around dispatch.dispatch()
9
10 Prints command and result value, but does not handle quoting.
11 """
12 print("running: %s" % (cmd,))
13 req = dispatch.request(cmd.split())
14 result = dispatch.dispatch(req)
15 print("result: %r" % (result,))
16
17 # create file 'foo', add and commit
18 f = open('foo', 'wb')
19 f.write('foo\n')
20 f.close()
21 testdispatch("add foo")
22 testdispatch("commit -m commit1 -d 2000-01-01 foo")
23
24 # append to file 'foo' and commit
25 f = open('foo', 'ab')
26 f.write('bar\n')
27 f.close()
28 # remove blackbox.log directory (proxy for readonly log file)
29 os.rmdir(".hg/blackbox.log")
30 # replace it with the real blackbox.log file
31 os.rename(".hg/blackbox.log-", ".hg/blackbox.log")
32 testdispatch("commit -m commit2 -d 2000-01-02 foo")
33
34 # check 88803a69b24 (fancyopts modified command table)
35 testdispatch("log -r 0")
36 testdispatch("log -r tip")