Proper exit code for buildout generated scripts

I recently ran into the issue that our Hudson installation didn’t report test failures. After digging for a bit, I discovered, that scripts installed by zc.recipe.egg don’t return the exit code for some cases. There is a bugreport at https://bugs.launchpad.net/zc.buildout/+bug/164629. In our case the generated coverage script depended on this and because the sys.exit was missing, the test failures were masked.

The following is a way to fix this in your buildouts now until it’s fixed in zc.buildout:

[buildout]
extensions = buildout.extensionscripts
extension-scripts =
    ${buildout:directory}/src/buildout-utils.py:patchScriptGeneration

The patchScriptGeneration function in src/buildout-utils.py looks like this:

def patchScriptGeneration(buildout):
    from zc.buildout import easy_install
    if not 'sys.exit(' in easy_install.script_template:
        easy_install.script_template = easy_install.script_template.replace(
            "%(module_name)s.%(attrs)s(%(arguments)s)",
            "sys.exit(%(module_name)s.%(attrs)s(%(arguments)s))")
Advertisements
Published in: on September 24, 2010 at 4:30 pm  Comments (1)  

One CommentLeave a comment

  1. Thanks for this post, still it doesn’t seems to work for me:

    $bin/develop rb; echo “Exit code: ” $?
    Last used buildout arguments: -c alin.cfg
    INFO: Running buildout.
    Getting distribution for ‘buildout.extensionscripts’.
    ….

    mr.developer: git remote of ‘p4a.common’ failed.
    mr.developer: fatal: Not a git repository (or any parent up to mount parent )
    mr.developer: Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
    mr.developer:
    mr.developer: Updated ‘eea.translations’ with subversion.
    mr.developer: Updated ‘eea.versions’ with subversion.
    mr.developer: Updated ‘eea.vocab’ with subversion.
    mr.developer: Updated ‘eea.workflow’ with subversion.
    mr.developer: There have been errors, see messages above.

    Exit code: 0


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: