Changeset 585

Show
Ignore:
Timestamp:
03/27/08 21:50:38 (10 months ago)
Author:
warner@lothar.com
Message:

add 'buildbot checkconfig' command from Ben Hearsum

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ChangeLog

    r584 r585  
     12008-03-27  Brian Warner  <warner@lothar.com> 
     2 
     3        * buildbot/scripts/runner.py (doCheckConfig): patch from Ben 
     4        Hearsum to implement 'buildbot checkconfig': validate that your 
     5        master.cfg is good without actually touching the buildmaster. 
     6        Closes #37. Thanks! 
     7        * buildbot/scripts/checkconfig.py: same 
     8        * docs/buildbot.texinfo (Testing the Config File): document it 
     9 
    1102008-03-22  Brian Warner  <warner@lothar.com> 
    211 
  • buildbot/scripts/runner.py

    r471 r585  
    44# subcommands want to load modules that need the gtk reactor. 
    55import os, sys, stat, re, time 
     6import traceback 
    67from twisted.python import usage, util, runtime 
    78 
     
    810811 
    811812 
     813class CheckConfigOptions(usage.Options): 
     814    optFlags = [ 
     815        ['quiet', 'q', "Don't display error messages or tracebacks"], 
     816    ] 
     817 
     818    def getSynopsis(self): 
     819        return "Usage           :buildbot checkconfig [configFile]\n" + \ 
     820         "              If not specified, 'master.cfg' will be used as 'configFile'" 
     821 
     822    def parseArgs(self, *args): 
     823        if len(args) >= 1: 
     824            self['configFile'] = args[0] 
     825        else: 
     826            self['configFile'] = 'master.cfg' 
     827 
     828 
     829def doCheckConfig(config): 
     830    quiet = config.get('quiet') 
     831    configFile = config.get('configFile') 
     832    try: 
     833        from buildbot.scripts.checkconfig import ConfigLoader 
     834        ConfigLoader(configFile) 
     835    except: 
     836        if not quiet: 
     837            # Print out the traceback in a nice format 
     838            t, v, tb = sys.exc_info() 
     839            traceback.print_exception(t, v, tb) 
     840        sys.exit(1) 
     841 
     842    if not quiet: 
     843        print "Config file is good!" 
     844 
     845 
    812846class Options(usage.Options): 
    813847    synopsis = "Usage:    buildbot <command> [command options]" 
     
    847881        ['tryserver', None, TryServerOptions, 
    848882         "buildmaster-side 'try' support function, not for users"], 
     883 
     884        ['checkconfig', None, CheckConfigOptions, 
     885         "test the validity of a master.cfg config file"], 
    849886 
    850887        # TODO: 'watch' 
     
    907944    elif command == "tryserver": 
    908945        doTryServer(so) 
    909  
    910  
     946    elif command == "checkconfig": 
     947        doCheckConfig(so) 
     948 
     949 
  • docs/buildbot.texinfo

    r580 r585  
    129129* Config File Format::           
    130130* Loading the Config File::      
     131* Testing the Config File::      
    131132* Defining the Project::         
    132133* Listing Change Sources and Schedulers::   
     
    19231924* Config File Format::           
    19241925* Loading the Config File::      
     1926* Testing the Config File::      
    19251927* Defining the Project::         
    19261928* Listing Change Sources and Schedulers::   
     
    19951997 
    19961998 
    1997 @node Loading the Config File, Defining the Project, Config File Format, Configuration 
     1999@node Loading the Config File, Testing the Config File, Config File Format, Configuration 
    19982000@section Loading the Config File 
    19992001 
     
    20292031which get queued after the reconfig) will use the new process. 
    20302032 
    2031 @node Defining the Project, Listing Change Sources and Schedulers, Loading the Config File, Configuration 
     2033@node Testing the Config File, Defining the Project, Loading the Config File, Configuration 
     2034@section Testing the Config File 
     2035 
     2036To verify that the config file is well-formed and contains no 
     2037deprecated or invalid elements, use the ``checkconfig'' command: 
     2038 
     2039@example 
     2040% buildbot checkconfig master.cfg 
     2041Config file is good! 
     2042@end example 
     2043 
     2044If the config file has deprecated features (perhaps because you've 
     2045upgraded the buildmaster and need to update the config file to match), 
     2046they will be announced by checkconfig. In this case, the config file 
     2047will work, but you should really remove the deprecated items and use 
     2048the recommended replacements instead: 
     2049 
     2050@example 
     2051% buildbot checkconfig master.cfg 
     2052/usr/lib/python2.4/site-packages/buildbot/master.py:559: DeprecationWarning: c['sources'] is deprecated as of 0.7.6 and will be removed by 0.8.0 . Please use c['change_source'] instead. 
     2053  warnings.warn(m, DeprecationWarning) 
     2054Config file is good! 
     2055@end example 
     2056 
     2057If the config file is simply broken, that will be caught too: 
     2058 
     2059@example 
     2060% buildbot checkconfig master.cfg 
     2061Traceback (most recent call last): 
     2062  File "/usr/lib/python2.4/site-packages/buildbot/scripts/runner.py", line 834, in doCheckConfig 
     2063    ConfigLoader(configFile) 
     2064  File "/usr/lib/python2.4/site-packages/buildbot/scripts/checkconfig.py", line 31, in __init__ 
     2065    self.loadConfig(configFile) 
     2066  File "/usr/lib/python2.4/site-packages/buildbot/master.py", line 480, in loadConfig 
     2067    exec f in localDict 
     2068  File "/home/warner/BuildBot/master/foolscap/master.cfg", line 90, in ? 
     2069    c[bogus] = "stuff" 
     2070NameError: name 'bogus' is not defined 
     2071@end example 
     2072 
     2073 
     2074@node Defining the Project, Listing Change Sources and Schedulers, Testing the Config File, Configuration 
    20322075@section Defining the Project 
    20332076