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).

Regards

- henrik

-Josh

--
On 04/30/2015 05:17 AM, Erik Dalén wrote:
I'm not even getting the custom functions to load if I set $RUBYLIB,
set libdir or copy them manually to the default libdir (emulating
pluginsync). If I build and install this module it works as expected,
but at the moment I can't find any good way to test v4 functions
without installing them first.

Has anyone verified that pluginsync with v4 functions works at all?

On Wed, 29 Apr 2015 at 12:49 Erik Dalén <erik.gustav.da...@gmail.com
<mailto:erik.gustav.da...@gmail.com>> wrote:

     I'm not getting it to work. Here's a minimal example project with
     a simple max function: https://github.com/dalen/puppet-v4functiontest

     And here is the failing travis build for it:
     https://travis-ci.org/dalen/puppet-v4functiontest/builds/60517933

     This is requiring the latest rspec-puppet (2.1.0) and puppet
     4.0.0. What am I doing wrong?

     On Tue, 28 Apr 2015 at 17:00 Henrik Lindberg
     <henrik.lindb...@cloudsmith.com
     <mailto:henrik.lindb...@cloudsmith.com>> wrote:

         On 2015-28-04 16:53, Henrik Lindberg wrote:
         > 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/rodjek/rspec-puppet/commit/a66f9654671f8cd935599209b56eee2768c7c8c1#diff-2374d7eefa56aafa2b25c2914973fecbR14


         - henrik
         --

         Visit my Blog "Puppet on the Edge"
         http://puppet-on-the-edge.blogspot.se/

         --
         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+unsubscr...@googlegroups.com
         <mailto:puppet-dev%2bunsubscr...@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.

--
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+unsubscr...@googlegroups.com
<mailto:puppet-dev+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-dev/CAAAzDLcnh-ha1s72tJwLBUkH%2BZDmnqAAN5uowz9n03R1afeU-A%40mail.gmail.com
<https://groups.google.com/d/msgid/puppet-dev/CAAAzDLcnh-ha1s72tJwLBUkH%2BZDmnqAAN5uowz9n03R1afeU-A%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.




--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/mhubrn%24u77%241%40ger.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to