Changeset 129

Show
Ignore:
Timestamp:
08/04/06 08:40:20 (2 years ago)
Author:
mk
Message:

Implemented --keep-log command line option.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/mk/CHANGES

    r127 r129  
    1010  * Added lots of missing unit and functional tests. 
    1111  * Major refactoring of Cheesecake class and indices classes. 
     12  * Implemented --keep-log option. 
  • branches/mk/cheesecake/cheesecake_index.py

    r128 r129  
    11851185    def __init__(self, name="", url="", path="", sandbox=None, 
    11861186                 logfile=None, verbose=False, quiet=False, static_only=False, 
    1187                  lite=False): 
     1187                 lite=False, keep_log=False): 
    11881188        """Initialize critical variables, download and unpack package, 
    11891189        walk package tree. 
     
    12111211        self.static_only = static_only 
    12121212        self.lite = lite 
     1213        self.keep_log = keep_log 
    12131214 
    12141215        self.sandbox_pkg_file = "" 
     
    12791280        delete_dir(self.sandbox) 
    12801281 
    1281         if remove_log_file
     1282        if remove_log_file and not self.keep_log
    12821283            os.unlink(os.path.join(self.sandbox, self.logfile)) 
    12831284 
     
    16321633    """ 
    16331634    parser = OptionParser() 
     1635    parser.add_option("--keep-log", action="store_true", dest="keep_log", 
     1636                      default=False, help="don't remove log file even if run was successful") 
    16341637    parser.add_option("--lite", action="store_true", dest="lite", 
    16351638                      default=False, help="don't run time-consuming tests (default=False)") 
     
    16631666    """ 
    16641667    options = process_cmdline_args() 
     1668    keep_log = options.keep_log 
     1669    lite = options.lite 
     1670    logfile = options.logfile 
    16651671    name = options.name 
     1672    path = options.path 
     1673    quiet = options.quiet 
     1674    sandbox = options.sandbox 
     1675    static_only = options.static 
    16661676    url = options.url 
    1667     path = options.path 
    1668     sandbox = options.sandbox 
    1669     logfile = options.logfile 
    16701677    verbose = options.verbose 
    1671     quiet = options.quiet 
    1672     static_only = options.static 
    1673     lite = options.lite 
    16741678    version = options.version 
    16751679 
     
    16851689        c = Cheesecake(name=name, url=url, path=path, sandbox=sandbox, 
    16861690                       logfile=logfile, verbose=verbose, 
    1687                        quiet=quiet, static_only=static_only, lite=lite) 
     1691                       quiet=quiet, static_only=static_only, lite=lite, 
     1692                       keep_log=keep_log) 
    16881693        c.compute_cheesecake_index() 
    16891694        c.cleanup() 
  • branches/mk/tests/functional/test_options.py

    r94 r129  
    11 
    22import os 
     3import tempfile 
    34 
    45from _helper_cheesecake import FunctionalTest, read_file_contents, NOSE_PATH, PACKAGE_PATH 
     
    8788        # Make sure that --quiet generates less information than default operation. 
    8889        assert len(quiet) < len(normal) 
     90 
     91    def test_keep_log(self): 
     92        logfile = tempfile.mktemp(prefix='log') 
     93        self._run_cheesecake('--path %s --logfile %s --keep-log' % (NOSE_PATH, logfile)) 
     94 
     95        self._assert_success() 
     96 
     97        # Make sure that log file was left. 
     98        assert os.path.exists(logfile) 
     99 
     100        # Delete the logfile now. 
     101        os.unlink(logfile)