~ubuntu-branches/ubuntu/trusty/puppet/trusty

« back to all changes in this revision

Viewing changes to spec/spec_helper.rb

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2011-10-22 14:08:22 UTC
  • mfrom: (1.1.25) (3.1.32 sid)
  • Revision ID: package-import@ubuntu.com-20111022140822-odxde5lohc45yhuz
Tags: 2.7.6-1
* New upstream release (CVE-2011-3872)
* Remove cherry-picked "groupadd_aix_warning" patch
* Install all new manpages

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
unless defined? SPEC_HELPER_IS_LOADED
2
 
SPEC_HELPER_IS_LOADED = 1
3
 
 
4
1
dir = File.expand_path(File.dirname(__FILE__))
5
2
$LOAD_PATH.unshift File.join(dir, 'lib')
6
3
 
39
36
  config.before :each do
40
37
    GC.disable
41
38
 
 
39
    # We need to preserve the current state of all our indirection cache and
 
40
    # terminus classes.  This is pretty important, because changes to these
 
41
    # are global and lead to order dependencies in our testing.
 
42
    #
 
43
    # We go direct to the implementation because there is no safe, sane public
 
44
    # API to manage restoration of these to their default values.  This
 
45
    # should, once the value is proved, be moved to a standard API on the
 
46
    # indirector.
 
47
    #
 
48
    # To make things worse, a number of the tests stub parts of the
 
49
    # indirector.  These stubs have very specific expectations that what
 
50
    # little of the public API we could use is, well, likely to explode
 
51
    # randomly in some tests.  So, direct access.  --daniel 2011-08-30
 
52
    $saved_indirection_state = {}
 
53
    indirections = Puppet::Indirector::Indirection.send(:class_variable_get, :@@indirections)
 
54
    indirections.each do |indirector|
 
55
      $saved_indirection_state[indirector.name] = {
 
56
        :@terminus_class => indirector.instance_variable_get(:@terminus_class),
 
57
        :@cache_class    => indirector.instance_variable_get(:@cache_class)
 
58
      }
 
59
    end
 
60
 
42
61
    # these globals are set by Application
43
62
    $puppet_application_mode = nil
44
63
    $puppet_application_name = nil
74
93
    Puppet::Util::Log.close_all
75
94
    Puppet::Util::Log.level = @log_level
76
95
 
 
96
    # Restore the indirector configuration.  See before hook.
 
97
    indirections = Puppet::Indirector::Indirection.send(:class_variable_get, :@@indirections)
 
98
    indirections.each do |indirector|
 
99
      $saved_indirection_state.fetch(indirector.name, {}).each do |variable, value|
 
100
        indirector.instance_variable_set(variable, value)
 
101
      end
 
102
    end
 
103
    $saved_indirection_state = nil
 
104
 
77
105
    GC.enable
78
106
  end
79
107
end
80
 
 
81
 
end