1
# Copyright (C) 2005 by Canonical Ltd
1
# Copyright (C) 2005 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License version 2 as published by
5
# the Free Software Foundation.
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
8
# This program is distributed in the hope that it will be useful,
8
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
173
175
TestCaseWithMemoryTransport.TEST_ROOT = old_root
174
176
self.assertContainsRe(out, 'Ran 0 tests.*\n\nOK')
175
177
self.assertEqual(
176
'running tests...\ntests passed\n',
178
180
benchfile = open(".perf_history", "rt")
359
361
self.assertEqual(cwd, osutils.getcwd())
364
class _DontSpawnProcess(Exception):
365
"""A simple exception which just allows us to skip unnecessary steps"""
368
class TestRunBzrSubprocessCommands(TestCaseWithTransport):
370
def _popen(self, *args, **kwargs):
371
"""Record the command that is run, so that we can ensure it is correct"""
372
self._popen_args = args
373
self._popen_kwargs = kwargs
374
raise _DontSpawnProcess()
376
def test_run_bzr_subprocess_no_plugins(self):
377
self.assertRaises(_DontSpawnProcess, self.run_bzr_subprocess)
378
command = self._popen_args[0]
379
self.assertEqual(sys.executable, command[0])
380
self.assertEqual(self.get_bzr_path(), command[1])
381
self.assertEqual(['--no-plugins'], command[2:])
383
def test_allow_plugins(self):
384
self.assertRaises(_DontSpawnProcess,
385
self.run_bzr_subprocess, allow_plugins=True)
386
command = self._popen_args[0]
387
self.assertEqual([], command[2:])
362
390
class TestBzrSubprocess(TestCaseWithTransport):
364
392
def test_start_and_stop_bzr_subprocess(self):
411
439
self.make_branch_and_tree('one')
413
441
process = self.start_bzr_subprocess(['root'], working_dir='one')
414
result = self.finish_bzr_subprocess(process)
442
result = self.finish_bzr_subprocess(process, universal_newlines=True)
415
443
self.assertEndsWith(result[0], 'one\n')
416
444
self.assertEqual('', result[1])
419
447
class TestRunBzrError(ExternalBase):
422
450
out, err = self.run_bzr_error(['^$'], 'rocks', retcode=0)
423
451
self.assertEqual(out, 'it sure does!\n')
425
out, err = self.run_bzr_error(["'foobarbaz' is not a versioned file"],
453
out, err = self.run_bzr_error(["bzr: ERROR: foobarbaz is not versioned"],
426
454
'file-id', 'foobarbaz')
457
class TestSelftestCleanOutput(TestCaseInTempDir):
459
def test_clean_output(self):
460
# check that 'bzr selftest --clean-output' works correct
461
dirs = ('test0000.tmp', 'test0001.tmp', 'bzrlib', 'tests')
462
files = ('bzr', 'setup.py', 'test9999.tmp')
467
f.write('content of ')
472
before = os.listdir(root)
474
self.assertEquals(['bzr','bzrlib','setup.py',
475
'test0000.tmp','test0001.tmp',
476
'test9999.tmp','tests'],
479
out,err = self.run_bzr_captured(['selftest','--clean-output'],
482
self.assertEquals(['delete directory: test0000.tmp',
483
'delete directory: test0001.tmp'],
484
sorted(out.splitlines()))
485
self.assertEquals('', err)
487
after = os.listdir(root)
489
self.assertEquals(['bzr','bzrlib','setup.py',
490
'test9999.tmp','tests'],