101
101
err = err.decode('utf-8')
102
102
self.addDetail('subprocess_stderr',
103
content.text_content(err))
103
content.text_content(err))
106
106
for module_name in forbidden_imports:
115
115
self.fail("command loaded forbidden modules %r"
118
118
def finish_bzr_subprocess_with_import_check(self, process,
119
args, forbidden_imports):
119
args, forbidden_imports):
120
120
"""Finish subprocess and check specific modules have not been
124
124
that should not be loaded while running this command.
126
126
(out, err) = self.finish_bzr_subprocess(process,
127
universal_newlines=False, process_args=args)
127
universal_newlines=False, process_args=args)
128
128
self.check_forbidden_modules(err, forbidden_imports)
150
150
# measuring correctly
151
151
self.make_branch_and_tree('.')
152
152
self.run_command_check_imports(['st'],
153
['nonexistentmodulename', 'anothernonexistentmodule'])
153
['nonexistentmodulename', 'anothernonexistentmodule'])
154
154
self.assertRaises(AssertionError,
155
self.run_command_check_imports,
155
self.run_command_check_imports,
159
159
def test_simple_local(self):
160
160
# 'st' in a default format working tree shouldn't need many modules
217
216
# while the smart client interacts with it.
218
217
stderr_file = open('bzr-serve.stderr', 'w')
219
218
process = self.start_bzr_subprocess_with_import_check(['serve',
220
'--inet', '-d', tree.basedir], stderr_file=stderr_file)
219
'--inet', '-d', tree.basedir], stderr_file=stderr_file)
221
220
url = 'bzr://localhost/'
222
221
self.permit_url(url)
223
222
client_medium = medium.SmartSimplePipesClientMedium(
228
227
# Hide stdin from the subprocess module, so it won't fail to close it.
229
228
process.stdin = None
230
229
(out, err) = self.finish_bzr_subprocess(process,
231
universal_newlines=False)
230
universal_newlines=False)
232
231
stderr_file.close()
233
232
with open('bzr-serve.stderr', 'rb') as stderr_file:
234
233
err = stderr_file.read()
235
234
self.check_forbidden_modules(err,
239
'breezy.bundle.commands',
240
'breezy.cmd_version_info',
241
'breezy.bzr.dirstate',
242
'breezy.bzr._dirstate_helpers_py',
243
'breezy.bzr._dirstate_helpers_pyx',
244
'breezy.externalcommand',
247
# foreign branch plugins import the foreign_vcs_registry from
248
# breezy.foreign so it can't be blacklisted
253
'breezy.merge_directive',
255
'breezy.patiencediff',
258
'breezy.sign_my_commits',
259
'breezy.bzr.smart.client',
261
'breezy.version_info_formats.format_rio',
262
'breezy.bzr.workingtree_4',
263
'breezy.bzr.xml_serializer',
272
] + old_format_modules)
238
'breezy.bundle.commands',
239
'breezy.cmd_version_info',
240
'breezy.bzr.dirstate',
241
'breezy.bzr._dirstate_helpers_py',
242
'breezy.bzr._dirstate_helpers_pyx',
243
'breezy.externalcommand',
246
# foreign branch plugins import the foreign_vcs_registry from
247
# breezy.foreign so it can't be blacklisted
252
'breezy.merge_directive',
256
'breezy.sign_my_commits',
257
'breezy.bzr.smart.client',
259
'breezy.version_info_formats.format_rio',
260
'breezy.bzr.workingtree_4',
261
'breezy.bzr.xml_serializer',
270
] + old_format_modules)