Mercurial > hgsubversion
annotate tests/test_util.py @ 491:b71507d7becc
svn_swig_wrapper: minor code cleanup.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Tue, 15 Sep 2009 21:34:14 -0400 |
parents | 6b481331c355 |
children | 50d77547c218 |
rev | line source |
---|---|
486
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
1 import gettext |
78
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
2 import errno |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
342
diff
changeset
|
3 import imp |
14
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 import os |
78
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
5 import subprocess |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
6 import shutil |
91
7d10165cf3d9
tests: Mock the mercurial.ui.ui class like we really should to capture output.
Augie Fackler <durin42@gmail.com>
parents:
84
diff
changeset
|
7 import StringIO |
78
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
8 import stat |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
9 import tempfile |
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
10 import unittest |
78
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
11 import urllib |
14
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
342
diff
changeset
|
13 import __init__ |
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
342
diff
changeset
|
14 |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
15 from mercurial import context |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
16 from mercurial import commands |
22
95d0109e495e
Refactor tests so I can reuse code more.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
17 from mercurial import hg |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
18 from mercurial import node |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
19 from mercurial import ui |
486
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
20 from mercurial import i18n |
22
95d0109e495e
Refactor tests so I can reuse code more.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
21 |
337
46e69be8e2c8
Reorganize to have a more conventional module structure.
Augie Fackler <durin42@gmail.com>
parents:
334
diff
changeset
|
22 from hgsubversion import util |
333
a59ab58969d9
test_util: normalize path in svnls()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
331
diff
changeset
|
23 |
479
83fcb1cf6d8f
Avoid 'ValueError: close_fds is not supported on Windows platforms' exception
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
355
diff
changeset
|
24 import sys |
83fcb1cf6d8f
Avoid 'ValueError: close_fds is not supported on Windows platforms' exception
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
355
diff
changeset
|
25 # Documentation for Subprocess.Popen() says: |
83fcb1cf6d8f
Avoid 'ValueError: close_fds is not supported on Windows platforms' exception
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
355
diff
changeset
|
26 # "Note that on Windows, you cannot set close_fds to true and |
83fcb1cf6d8f
Avoid 'ValueError: close_fds is not supported on Windows platforms' exception
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
355
diff
changeset
|
27 # also redirect the standard handles by setting stdin, stdout or |
83fcb1cf6d8f
Avoid 'ValueError: close_fds is not supported on Windows platforms' exception
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
355
diff
changeset
|
28 # stderr." |
83fcb1cf6d8f
Avoid 'ValueError: close_fds is not supported on Windows platforms' exception
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
355
diff
changeset
|
29 canCloseFds='win32' not in sys.platform |
83fcb1cf6d8f
Avoid 'ValueError: close_fds is not supported on Windows platforms' exception
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
355
diff
changeset
|
30 |
483
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
31 if not 'win32' in sys.platform: |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
32 def kill_process(popen_obj): |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
33 os.kill(popen_obj.pid, 9) |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
34 else: |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
35 import ctypes |
487
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
36 from ctypes.wintypes import BOOL, DWORD, HANDLE, UINT |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
37 |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
38 def win_status_check(result, func, args): |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
39 if result == 0: |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
40 raise ctypes.WinError() |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
41 return args |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
42 |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
43 def WINAPI(returns, func, *params): |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
44 assert len(params) % 2 == 0 |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
45 |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
46 func.argtypes = tuple(params[0::2]) |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
47 func.resvalue = returns |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
48 func.errcheck = win_status_check |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
49 |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
50 return func |
483
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
51 |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
52 # dwDesiredAccess |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
53 PROCESS_TERMINATE = 0x0001 |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
54 |
487
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
55 OpenProcess = WINAPI(HANDLE, ctypes.windll.kernel32.OpenProcess, |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
56 DWORD, 'dwDesiredAccess', |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
57 BOOL, 'bInheritHandle', |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
58 DWORD, 'dwProcessId', |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
59 ) |
483
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
60 |
487
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
61 CloseHandle = WINAPI(BOOL, ctypes.windll.kernel32.CloseHandle, |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
62 HANDLE, 'hObject' |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
63 ) |
483
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
64 |
487
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
65 TerminateProcess = WINAPI(BOOL, ctypes.windll.kernel32.TerminateProcess, |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
66 HANDLE, 'hProcess', |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
67 UINT, 'uExitCode' |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
68 ) |
483
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
69 |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
70 def kill_process(popen_obj): |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
71 phnd = OpenProcess(PROCESS_TERMINATE, False, popen_obj.pid) |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
72 TerminateProcess(phnd, 1) |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
73 CloseHandle(phnd) |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
74 |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
170
diff
changeset
|
75 # Fixtures that need to be pulled at a subdirectory of the repo path |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
170
diff
changeset
|
76 subdir = {'truncatedhistory.svndump': '/project2', |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
170
diff
changeset
|
77 'fetch_missing_files_subdir.svndump': '/foo', |
270
2848d17eae71
Fix rebuildmeta tests for empty_dir_in_trunk_not_repo_root
Augie Fackler <durin42@gmail.com>
parents:
257
diff
changeset
|
78 'empty_dir_in_trunk_not_repo_root.svndump': '/project', |
351
3d5c4352a6c8
test_util: Add another missing project root.
Augie Fackler <durin42@gmail.com>
parents:
347
diff
changeset
|
79 'project_root_not_repo_root.svndump': '/dummyproj', |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
170
diff
changeset
|
80 } |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
170
diff
changeset
|
81 |
14
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
82 FIXTURES = os.path.join(os.path.abspath(os.path.dirname(__file__)), |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
83 'fixtures') |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
84 |
91
7d10165cf3d9
tests: Mock the mercurial.ui.ui class like we really should to capture output.
Augie Fackler <durin42@gmail.com>
parents:
84
diff
changeset
|
85 def fileurl(path): |
78
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
86 path = os.path.abspath(path) |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
87 drive, path = os.path.splitdrive(path) |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
88 path = urllib.pathname2url(path) |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
89 if drive: |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
90 drive = '/' + drive |
342
76c833526fbc
Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
91 url = 'file://%s%s' % (drive, path) |
78
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
92 return url |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
93 |
14
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
94 def load_svndump_fixture(path, fixture_name): |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
95 '''Loads an svnadmin dump into a fresh repo at path, which should not |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
96 already exist. |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
97 ''' |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
98 if os.path.exists(path): rmtree(path) |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
99 subprocess.call(['svnadmin', 'create', path,], |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
100 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
14
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
101 inp = open(os.path.join(FIXTURES, fixture_name)) |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
102 proc = subprocess.Popen(['svnadmin', 'load', path,], stdin=inp, |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
103 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
78
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
104 proc.communicate() |
22
95d0109e495e
Refactor tests so I can reuse code more.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
105 |
278
60acc38eac96
clone: prefer tip of default to overall tip when updating
Martijn Pieters <mj@zopatista.com>
parents:
277
diff
changeset
|
106 def load_fixture_and_fetch(fixture_name, repo_path, wc_path, stupid=False, subdir='', noupdate=True): |
22
95d0109e495e
Refactor tests so I can reuse code more.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
107 load_svndump_fixture(repo_path, fixture_name) |
112
e58c2f1de059
Fix a regression in converting repositories with files copied in from outside
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
108 if subdir: |
e58c2f1de059
Fix a regression in converting repositories with files copied in from outside
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
109 repo_path += '/' + subdir |
337
46e69be8e2c8
Reorganize to have a more conventional module structure.
Augie Fackler <durin42@gmail.com>
parents:
334
diff
changeset
|
110 |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
111 _ui = ui.ui() |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
112 _ui.setconfig('hgsubversion', 'stupid', str(stupid)) |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
113 commands.clone(_ui, fileurl(repo_path), wc_path, noupdate=noupdate) |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
114 _ui = ui.ui() |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
115 _ui.setconfig('hgsubversion', 'stupid', str(stupid)) |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
116 return hg.repository(_ui, wc_path) |
78
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
117 |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
118 def rmtree(path): |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
119 # Read-only files cannot be removed under Windows |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
120 for root, dirs, files in os.walk(path): |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
121 for f in files: |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
122 f = os.path.join(root, f) |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
123 try: |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
124 s = os.stat(f) |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
125 except OSError, e: |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
126 if e.errno == errno.ENOENT: |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
127 continue |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
128 raise |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
129 if (s.st_mode & stat.S_IWRITE) == 0: |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
130 os.chmod(f, s.st_mode | stat.S_IWRITE) |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
131 shutil.rmtree(path) |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
132 |
486
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
133 |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
134 class TestBase(unittest.TestCase): |
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
135 def setUp(self): |
486
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
136 self.oldenv = dict([(k, os.environ.get(k, None), ) for k in |
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
137 ('LANG', 'LC_ALL', 'HGRCPATH', )]) |
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
138 self.oldt = i18n.t |
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
139 os.environ['LANG'] = os.environ['LC_ALL'] = 'C' |
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
140 i18n.t = gettext.translation('hg', i18n.localedir, fallback=True) |
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
141 |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
142 self.oldwd = os.getcwd() |
148
0c5f6420a8b5
tests: Add an environment variable (HGSUBVERSION_TEST_TEMP) which allows
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
143 self.tmpdir = tempfile.mkdtemp( |
0c5f6420a8b5
tests: Add an environment variable (HGSUBVERSION_TEST_TEMP) which allows
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
144 'svnwrap_test', dir=os.environ.get('HGSUBVERSION_TEST_TEMP', None)) |
231
b1543f243910
tests: Start providing our own custom hgrc for testing purposes.
Augie Fackler <durin42@gmail.com>
parents:
194
diff
changeset
|
145 self.hgrc = os.path.join(self.tmpdir, '.hgrc') |
b1543f243910
tests: Start providing our own custom hgrc for testing purposes.
Augie Fackler <durin42@gmail.com>
parents:
194
diff
changeset
|
146 os.environ['HGRCPATH'] = self.hgrc |
b1543f243910
tests: Start providing our own custom hgrc for testing purposes.
Augie Fackler <durin42@gmail.com>
parents:
194
diff
changeset
|
147 rc = open(self.hgrc, 'w') |
334
3c3c3264c362
test_util: Make the patching of ui.ui.write_err() slightly more reusable.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
333
diff
changeset
|
148 for l in '[extensions]', 'hgsubversion=': |
3c3c3264c362
test_util: Make the patching of ui.ui.write_err() slightly more reusable.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
333
diff
changeset
|
149 print >> rc, l |
148
0c5f6420a8b5
tests: Add an environment variable (HGSUBVERSION_TEST_TEMP) which allows
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
150 |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
151 self.repo_path = '%s/testrepo' % self.tmpdir |
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
152 self.wc_path = '%s/testrepo_wc' % self.tmpdir |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
153 |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
154 # Previously, we had a MockUI class that wrapped ui, and giving access |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
155 # to the stream. The ui.pushbuffer() and ui.popbuffer() can be used |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
156 # instead. Using the regular UI class, with all stderr redirected to |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
157 # stdout ensures that the test setup is much more similar to usage |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
158 # setups. |
334
3c3c3264c362
test_util: Make the patching of ui.ui.write_err() slightly more reusable.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
333
diff
changeset
|
159 self.patch = (ui.ui.write_err, ui.ui.write) |
3c3c3264c362
test_util: Make the patching of ui.ui.write_err() slightly more reusable.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
333
diff
changeset
|
160 setattr(ui.ui, self.patch[0].func_name, self.patch[1]) |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
161 |
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
162 def tearDown(self): |
486
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
163 for var, val in self.oldenv.iteritems(): |
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
164 if val is None: |
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
165 del os.environ[var] |
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
166 else: |
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
167 os.environ[var] = val |
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
168 i18n.t = self.oldt |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
169 rmtree(self.tmpdir) |
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
170 os.chdir(self.oldwd) |
334
3c3c3264c362
test_util: Make the patching of ui.ui.write_err() slightly more reusable.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
333
diff
changeset
|
171 setattr(ui.ui, self.patch[0].func_name, self.patch[0]) |
91
7d10165cf3d9
tests: Mock the mercurial.ui.ui class like we really should to capture output.
Augie Fackler <durin42@gmail.com>
parents:
84
diff
changeset
|
172 |
138
40474f6c1f84
diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
112
diff
changeset
|
173 def _load_fixture_and_fetch(self, fixture_name, subdir='', stupid=False): |
40474f6c1f84
diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
112
diff
changeset
|
174 return load_fixture_and_fetch(fixture_name, self.repo_path, |
40474f6c1f84
diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
112
diff
changeset
|
175 self.wc_path, subdir=subdir, |
40474f6c1f84
diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
112
diff
changeset
|
176 stupid=stupid) |
40474f6c1f84
diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
112
diff
changeset
|
177 |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
178 # define this as a property so that it reloads anytime we need it |
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
179 @property |
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
180 def repo(self): |
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
181 return hg.repository(ui.ui(), self.wc_path) |
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
182 |
355
256863a65141
test_util: make it easier to test odd push cases
Augie Fackler <durin42@gmail.com>
parents:
351
diff
changeset
|
183 def pushrevisions(self, stupid=False, expected_extra_back=0): |
170
d046bef502d7
test_util: check all committed revisions are pushed
Patrick Mezard <pmezard@gmail.com>
parents:
148
diff
changeset
|
184 before = len(self.repo) |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
185 self.repo.ui.setconfig('hgsubversion', 'stupid', str(stupid)) |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
186 commands.push(self.repo.ui, self.repo) |
170
d046bef502d7
test_util: check all committed revisions are pushed
Patrick Mezard <pmezard@gmail.com>
parents:
148
diff
changeset
|
187 after = len(self.repo) |
355
256863a65141
test_util: make it easier to test odd push cases
Augie Fackler <durin42@gmail.com>
parents:
351
diff
changeset
|
188 self.assertEqual(expected_extra_back, after - before) |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
82
diff
changeset
|
189 |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
82
diff
changeset
|
190 def svnls(self, path, rev='HEAD'): |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
82
diff
changeset
|
191 path = self.repo_path + '/' + path |
333
a59ab58969d9
test_util: normalize path in svnls()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
331
diff
changeset
|
192 path = util.normalize_url(fileurl(path)) |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
82
diff
changeset
|
193 args = ['svn', 'ls', '-r', rev, '-R', path] |
91
7d10165cf3d9
tests: Mock the mercurial.ui.ui class like we really should to capture output.
Augie Fackler <durin42@gmail.com>
parents:
84
diff
changeset
|
194 p = subprocess.Popen(args, |
7d10165cf3d9
tests: Mock the mercurial.ui.ui class like we really should to capture output.
Augie Fackler <durin42@gmail.com>
parents:
84
diff
changeset
|
195 stdout=subprocess.PIPE, |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
196 stderr=subprocess.STDOUT) |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
82
diff
changeset
|
197 stdout, stderr = p.communicate() |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
82
diff
changeset
|
198 if p.returncode: |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
82
diff
changeset
|
199 raise Exception('svn ls failed on %s: %r' % (path, stderr)) |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
82
diff
changeset
|
200 entries = [e.strip('/') for e in stdout.splitlines()] |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
82
diff
changeset
|
201 entries.sort() |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
82
diff
changeset
|
202 return entries |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
203 |
355
256863a65141
test_util: make it easier to test odd push cases
Augie Fackler <durin42@gmail.com>
parents:
351
diff
changeset
|
204 def commitchanges(self, changes, parent='tip', message='automated test'): |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
205 """Commit changes to mercurial directory |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
206 |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
207 'changes' is a sequence of tuples (source, dest, data). It can look |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
208 like: |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
209 - (source, source, data) to set source content to data |
91
7d10165cf3d9
tests: Mock the mercurial.ui.ui class like we really should to capture output.
Augie Fackler <durin42@gmail.com>
parents:
84
diff
changeset
|
210 - (source, dest, None) to set dest content to source one, and mark it as |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
211 copied from source. |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
212 - (source, dest, data) to set dest content to data, and mark it as copied |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
213 from source. |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
214 - (source, None, None) to remove source. |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
215 """ |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
216 repo = self.repo |
277
3848a7f9b983
push: Add a test that demonstrates base-text detection works
Augie Fackler <durin42@gmail.com>
parents:
270
diff
changeset
|
217 parentctx = repo[parent] |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
218 |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
219 changed, removed = [], [] |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
220 for source, dest, newdata in changes: |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
221 if dest is None: |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
222 removed.append(source) |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
223 else: |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
224 changed.append(dest) |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
225 |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
226 def filectxfn(repo, memctx, path): |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
227 if path in removed: |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
228 raise IOError() |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
229 entry = [e for e in changes if path == e[1]][0] |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
230 source, dest, newdata = entry |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
231 if newdata is None: |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
232 newdata = parentctx[source].data() |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
233 copied = None |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
234 if source != dest: |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
235 copied = source |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
236 return context.memfilectx(path=dest, |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
237 data=newdata, |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
238 islink=False, |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
239 isexec=False, |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
240 copied=copied) |
91
7d10165cf3d9
tests: Mock the mercurial.ui.ui class like we really should to capture output.
Augie Fackler <durin42@gmail.com>
parents:
84
diff
changeset
|
241 |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
242 ctx = context.memctx(repo, |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
243 (parentctx.node(), node.nullid), |
355
256863a65141
test_util: make it easier to test odd push cases
Augie Fackler <durin42@gmail.com>
parents:
351
diff
changeset
|
244 message, |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
245 changed + removed, |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
246 filectxfn, |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
247 'an_author', |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
248 '2008-10-07 20:59:48 -0500') |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
249 nodeid = repo.commitctx(ctx) |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
250 repo = self.repo |
277
3848a7f9b983
push: Add a test that demonstrates base-text detection works
Augie Fackler <durin42@gmail.com>
parents:
270
diff
changeset
|
251 hg.clean(repo, nodeid) |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
252 return nodeid |
96
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
253 |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
254 def assertchanges(self, changes, ctx): |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
255 """Assert that all 'changes' (as in defined in commitchanged()) |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
256 went into ctx. |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
257 """ |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
258 for source, dest, data in changes: |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
259 if dest is None: |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
260 self.assertTrue(source not in ctx) |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
261 continue |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
262 self.assertTrue(dest in ctx) |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
263 if data is None: |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
264 data = ctx.parents()[0][source].data() |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
265 self.assertEqual(ctx[dest].data(), data) |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
266 if dest != source: |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
267 copy = ctx[dest].renamed() |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
268 self.assertEqual(copy[0], source) |