--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/mho73o%24dv8%242%40ger.gmane.org.
For more options, visit https://groups.google.com/d/optout.
On 2015-30-04 18:10, Joshua Hoblitt wrote:
> The core v4 function unit tests appear to be using Puppet::Pops::Loaders
> to find the function method. E.g.
>
> Puppet.lookup(:loaders).puppet_system_loader.load(:function,
> 'regsubst').call({}, *args)
>
> From:
>
> https://github.com/puppetlabs/puppet/blob/master/spec/unit/functions/regsubst_spec.rb
>
There is some unused and experimental "gem-loader" code (GemBased
ModuleLoader). The loading of things from the $RUBYLIB path in general
opened a lot of questions about the visibility - are those system
functions (like the ones shipped in puppet with the same privileges,
what are the rules for name-spacing them, if they are in a namespace,
are they in a module, what is the name of that module - the gem they are
in, what if it is not a gem, but just some random files pointed to? How
is the "pointing" done (or should it search all of the paths on the
$RUBYLIB path - which is very expensive) etc. etc. Also, gems are not
available everywhere.
Also note that the 4.x function API does not use ruby "require file", it
explicitly reads and evaluates the code to enable hot-reloading.
So, for the time being 4.x. functions can only be shipped in puppet modules.
I also want to learn more about use cases where it is wanted to ship
functions (or indeed puppet modules as gems).
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/mhubrn%24u77%241%40ger.gmane.org.
The core v4 function unit tests appear to be using Puppet::Pops::Loaders
to find the function method. E.g.
Puppet.lookup(:loaders).puppet_system_loader.load(:function,
'regsubst').call({}, *args)
From:
https://github.com/puppetlabs/puppet/blob/master/spec/unit/functions/regsubst_spec.rb
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/554253D8.1060303%40hoblitt.com.
On 2015-28-04 15:16, Erik Dalén wrote:
> Do any of you have any tips in regards to unit testing function using
> the v4 API in modules?
>
> I would like to do something like this:
> https://github.com/puppetlabs/puppet/blob/master/spec/unit/functions/scanf_spec.rb
>
> But PuppetSpec::Compiler & Matchers::Resource are in the spec/lib
> directory of puppet which I can't depend on from a module AFAIK.
>
> Is there something equivalent in puppetlabs_spec_helper that works for
> v4 API functions?
>
There is an updated version of puppet-rspec that will help with this. (I
heard about this yesterday). Hunner knows more.
https://github.com/DavidS/puppetlabs-stdlib/commits/modules-1882-rspec-puppet-migration
> Is there something equivalent in puppetlabs_spec_helper that works for
> v4 API functions?
>
There is an updated version of puppet-rspec that will help with this. (I
heard about this yesterday). Hunner knows more.
rspec-puppet 2.1.0 should have all that work. There are a few more patches and bug fixes in the pipeline, but 2.1.0 should already get you far.
Some examples of rspec-puppet only function testing can be found in the upcoming refresh of stdlib's function specs, currently in my WIP branch here:https://github.com/DavidS/puppetlabs-stdlib/commits/modules-1882-rspec-puppet-migrationIt seems like you only have one function using the v4 API (type_of), and the unit test for that is only run on Puppet 4.0, but the travis matrix doesn't specify puppet 4.0 at all. So the test for that doesn't run. Does it work if you try it locally with Puppet 4.0?To demonstrate the issue I created a minimal test module (https://github.com/dalen/puppet-v4functiontest), and it still doesn't work with rspec-puppet 2.1.0: https://travis-ci.org/dalen/puppet-v4functiontest/builds/60517933Do you have any idea what is wrong with that code?
Thanks a lot for looking into it and solving it. I'm traveling a bit ATM, but will give it a try once I'm back.
--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/e2dd083a-3171-40dc-9510-cde40ba938a9%40googlegroups.com.