Changeset 61
- Timestamp:
- 06/15/06 13:07:26 (6 years ago)
- Files:
-
- branches/mk/cheesecake/cheesecake_index.py (modified) (2 diffs)
- branches/mk/tests/functional/_helper_cheesecake.py (modified) (1 diff)
- branches/mk/tests/functional/_path_cheesecake.py (deleted)
- branches/mk/tests/functional/test_cleaning_up.py (modified) (1 diff)
- branches/mk/tests/functional/test_options.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/mk/cheesecake/cheesecake_index.py
r60 r61 279 279 yield index.compute_with(self.cheesecake) 280 280 # Print index info after computing. 281 index.print_info() 281 if not self.cheesecake.quiet: 282 index.print_info() 282 283 283 284 def compute_with(self, cheesecake): … … 1136 1137 1137 1138 # Print summary. 1138 print 1139 print pad_line("=") 1140 print pad_msg("OVERALL CHEESECAKE INDEX (ABSOLUTE)", cheesecake_index) 1141 print "%s (%d out of a maximum of %d points is %d%%)" % \ 1142 (pad_msg("OVERALL CHEESECAKE INDEX (RELATIVE)", percentage), 1143 cheesecake_index, 1144 max_cheesecake_index, 1145 percentage) 1139 if self.quiet: 1140 print "Cheesecake index: %d (%d / %d)" % (percentage, 1141 cheesecake_index, 1142 max_cheesecake_index) 1143 else: 1144 print 1145 print pad_line("=") 1146 print pad_msg("OVERALL CHEESECAKE INDEX (ABSOLUTE)", cheesecake_index) 1147 print "%s (%d out of a maximum of %d points is %d%%)" % \ 1148 (pad_msg("OVERALL CHEESECAKE INDEX (RELATIVE)", percentage), 1149 cheesecake_index, 1150 max_cheesecake_index, 1151 percentage) 1146 1152 1147 1153 return cheesecake_index branches/mk/tests/functional/_helper_cheesecake.py
r60 r61 1 import os 2 import sys 3 import tempfile 4 5 current_dir = os.path.dirname(__file__) 6 sys.path.insert(0, os.path.join(current_dir, '../../')) 7 8 try: 9 import subprocess 10 except ImportError, ex: 11 from cheesecake import subprocess 12 13 14 CHEESECAKE_PATH = os.path.abspath(os.path.join(current_dir, 15 '../../cheesecake_index')) 16 DATA_PATH = os.path.abspath(os.path.join(current_dir, '../unit/data/')) 17 NOSE_PATH = os.path.join(DATA_PATH, 'nose-0.8.3.tar.gz') 18 PACKAGE_PATH = os.path.join(DATA_PATH, 'package2.tar.gz') 19 20 21 class FunctionalTest(object): 22 def _run_cheesecake(self, arguments): 23 self.stdout_fd, self.stdout_name = tempfile.mkstemp(prefix='functional') 24 self.stderr_fd, self.stderr_name = tempfile.mkstemp(prefix='functional') 25 self.process = subprocess.Popen('%s %s' % (CHEESECAKE_PATH, arguments), 26 stdout=self.stdout_fd, 27 stderr=self.stderr_fd, 28 shell=True) 29 self.return_code = self.process.wait() 30 31 def _assert_success(self): 32 # Check that Cheesecake exited sucessfully. 33 assert self.return_code == 0 34 35 # Check that Cheesecake didn't wrote anything into stderr. 36 assert read_file_contents(self.stderr_name) == '' 37 38 def tearDown(self): 39 os.unlink(self.stdout_name) 40 os.unlink(self.stderr_name) 41 1 42 2 43 def read_file_contents(filename): branches/mk/tests/functional/test_cleaning_up.py
r60 r61 2 2 import os 3 3 import tempfile 4 from StringIO import StringIO5 4 6 from _path_cheesecake import CHEESECAKE_PATH 7 from _helper_cheesecake import read_file_contents 8 9 try: 10 import subprocess 11 except ImportError, ex: 12 from cheesecake import subprocess 5 from _helper_cheesecake import FunctionalTest, read_file_contents, NOSE_PATH 13 6 14 7 15 class TestCleaningUp( object):8 class TestCleaningUp(FunctionalTest): 16 9 def setUp(self): 17 self.stdout_fd, self.stdout_name = tempfile.mkstemp(prefix='functional')18 self.stderr_fd, self.stderr_name = tempfile.mkstemp(prefix='functional')19 10 self.sandbox = tempfile.mkdtemp() 20 self.process = subprocess.Popen('%s -n ftputil -s %s' % \ 21 (CHEESECAKE_PATH, self.sandbox), 22 stdout=self.stdout_fd, 23 stderr=self.stderr_fd, 24 shell=True) 25 self.return_code = self.process.wait() 26 27 def tearDown(self): 28 os.unlink(self.stdout_name) 29 os.unlink(self.stderr_name) 11 self.logfile = tempfile.mktemp(prefix='log') 12 self._run_cheesecake('-p %s -s %s -l %s' % (NOSE_PATH, self.sandbox, self.logfile)) 30 13 31 14 def test_no_tmp(self): 32 15 "Check that no files are left in temp by Cheesecake." 33 print file(self.stdout_name).read() 34 print file(self.stderr_name).read() 35 36 # Check that Cheesecake exited sucessfully. 37 assert self.return_code == 0 38 39 # Check that Cheesecake didn't wrote anything into stderr. 40 assert read_file_contents(self.stderr_name) == '' 16 self._assert_success() 41 17 42 18 # Check that Cheesecake didn't left sandbox. 43 19 assert not os.path.exists(self.sandbox) 44 20 21 # Check that log file has been removed. 22 assert not os.path.exists(self.logfile) 23 45 24 # Check that Cheesecake didn't left any cheesecake* files. 46 25 assert glob(os.path.join(tempfile.gettempdir(), "cheesecake*")) == [] 47 26 48 # Check that Cheesecake didn't left any tmp* files 27 # Check that Cheesecake didn't left any tmp* files. 49 28 assert glob(os.path.join(tempfile.gettempdir(), tempfile.gettempprefix() + "*")) == []
