Bug 8752

Summary: Raising subprocess.CalledProcessError in an eventhandler will exit with 0 for the exit code
Product: [Build System, Metadata & Runtime] BitBake Reporter: Randy Witt <randy.e.witt>
Component: bitbakeAssignee: Richard Purdie <richard.purdie>
Status: VERIFIED FIXED QA Contact: Bogdan Alexandru Voiculescu <bogdanx.a.voiculescu>
Severity: normal    
Priority: Medium+ CC: bogdanx.a.voiculescu, poky.bs.watcher, poky.watcher
Version: 2.0   
Target Milestone: 2.1 M1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
Test bbclass none

Description Randy Witt 2015-12-02 23:42:14 UTC
Created attachment 2885 [details]
Test bbclass

If subprocess.CalledProcessError is raised in an eventhandler, bitbake will exit but the exit code will be 0. It is expected that the exitcode should be non-zero.

Steps to reproduce:

1. Add mytest.bbclass to meta/classes
2. Add INHERIT += "mytest" to local.conf
3. bitbake core-image-minimal

You should see:

('__init__() takes at least 3 arguments (1 given)', <class 'subprocess.CalledProcessError'>, ())%


This was originally discovered when using uninative.bbclass and the loader was missing. I just made a simpler testcase.

Also if you look in bitbake/lib/bb/event.py where the exception is handled on line 33, it seems that it really is the "value" parameter being subprocess.CalledProcessError causing the problem.

If you set "value" to None, or even raise a different exception in the event handler the logger message is displayed, and the exit code is non-zero.
Comment 2 Bogdan Alexandru Voiculescu 2016-01-06 16:24:19 UTC
Verified: no errors on master:
bitbake core-image-minimal
Parsing recipes: 100% |##########################################################################################################################################################| Time: 00:00:10
Parsing of 885 .bb files complete (0 cached, 885 parsed). 1314 targets, 57 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION        = "1.28.0"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "Ubuntu-14.04"
TARGET_SYS        = "arm-poky-linux-gnueabi"
MACHINE           = "beaglebone"
DISTRO            = "poky"
DISTRO_VERSION    = "2.0+snapshot-20160106"
TUNE_FEATURES     = "arm armv7a vfp neon callconvention-hard cortexa8"
TARGET_FPU        = "vfp-neon"
meta
meta-yocto
meta-yocto-bsp    = "master:2cd061a29a94fdcdfec86732e6bcbb71c12c4afc"

NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 2215 tasks of which 460 didn't need to be rerun and all succeeded.