Please review pull request #584: Fix order-dependent failures in spec/unit/parser/functions/split_spec.rb opened by (nicklewis)

Description:

These were happening when this file was run after
spec/unit/resource/type_spec.rb. The issue is that type_spec.rb was creating an
environment called 'env', which made that the 'current' (thread-local)
environment. This caused functions to be loaded onto it, rather than onto the
root environment. However, in split_spec.rb, a scope was created with the
default environment ('production'). This caused functions to be found and thus
not loaded (as they are on the current environment 'env'), but not actually
available to the scope, which has functions from 'production' and root.

This is a degenerate state, as ordinarily scope objects are created during a
compilation, using the environment of the compiler, which is always the current
environment.

This change clears the current environment whenever known environments are
cleared. This solve the problem because we clear environments between tests.
It should be safe because the only place we do it in code is when setting the
value of settings, which doesn't happen during a compilation.

  • Opened: Fri Mar 16 18:26:59 UTC 2012
  • Based on: puppetlabs:master (0a96a8ec5cb74ab661b690988fb72c9aae725499)
  • Requested merge: nicklewis:split_spec_order_dependent_failures (e2fb04d1d09d1791bf55fd87d0da991d2815b8b6)

Diff follows:

diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb
index fc36c35..be04a90 100644
--- a/lib/puppet/node/environment.rb
+++ b/lib/puppet/node/environment.rb
@@ -57,6 +57,7 @@ def self.root
 
   def self.clear
     @seen.clear
+    self.current = nil
   end
 
   attr_reader :name

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to