Add error checking for calling CreateVariations with no variants

Calling CreateVariations with no variants will corrupt the
modules list with a module with nil logicModule, panic early
with a useful message instead.

Change-Id: Ic5c921efcba70c54efb5bb21a9626b2999376a69
This commit is contained in:
Colin Cross 2015-03-18 17:43:15 -07:00
parent bc21793f6c
commit f4d18a685d

View file

@ -718,6 +718,11 @@ func (c *Context) processSubdirs(
func (c *Context) createVariations(origModule *moduleInfo, mutatorName string,
variationNames []string) ([]*moduleInfo, []error) {
if len(variationNames) == 0 {
panic(fmt.Errorf("mutator %q passed zero-length variation list for module %q",
mutatorName, origModule.properties.Name))
}
newModules := []*moduleInfo{}
var errs []error