(PUP-2901/PE-4524) Add module dependency validation

Prior to this commit there wasn't much verification for module dependencies.
This commit adds verification the module dependencies have sane names and version
ranges. If verification fails, it will raise an argument exception.
Those two are definitely conflicting specifications.  `1.0.0` satisfies
one, but not the other.  Lauren's rewording makes sense up until (but
excluding) when one specification is in the `metadata.json` and one is in
the `Modulefile`.


On Wed, Jul 30, 2014 at 3:28 PM, Anderson Mills <notifications@github.com>
wrote:

> In lib/puppet/module_tool/metadata.rb:
>
> >
> >        @data.merge!(data)
> >        return self
> >      end
> >
> > +    # Validates the name and version_requirement for a dependency, then creates
> > +    # the Dependency and adds it.
> > +    # Returns the Dependency that was added.
> > +    def add_dependency(name, version_requirement=nil, repository=nil)
> > +      validate_name(name)
> > +      validate_version_range(version_requirement) if version_requirement
> > +      duplicates = @data['dependencies'].select { |d| d.full_module_name == name }
> > +      unless duplicates.empty?
> > +        duplicates.each do |dup|
> > +          if dup.version_requirement != version_requirement
> > +            raise ArgumentError, "Dependency conflict for #{full_module_name}: Dependency #{name} was given conflicting version requirements #{version_requirement} and #{dup.version_requirement}. Verify that there are no duplicates in the metadata.json or the Modulefile."
>
> This occurs when there is any non-equal specification, even when they
> don't "conflict". Example:
>
> cheddar:~/puppet/src/puppet (PE2838)$ bundle exec puppet module build anderson-no1
> Error: Dependency conflict for : Dependency puppetlabs-stdlib was given conflicting version requirements >= 1.0.0 and >= 2.0.0. Verify that there are no duplicates in the metadata.json or the Modulefile.
> Error: Try 'puppet help module build' for usage
>
> @laurenrother <https://github.com/laurenrother> gives alternative
> wording:
> Multiple dependencies specified: Multiple dependencies were given for
> puppetlabs-stdlib (>= 1.0.0 and >=2.0.0).
> Please specify one version_requirement in the metadata.json.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/puppetlabs/puppet/pull/2838/files#r15616858>.
>