summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-11-19 13:13:46 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2018-11-19 13:13:46 -0800
commite979ba2ccf10cfa09481e65fd7009bb309247123 (patch)
tree69fdb882face04af8022928367df4a237d0de32b
parent7f79a630893ad4aa64cd9507f16ac7008364ea0f (diff)
downloadchef-e979ba2ccf10cfa09481e65fd7009bb309247123.tar.gz
Chef-15: require instead of load libraries
This reverts a change which was working around problems caused by unforked interval runs. Fixes issues with chefspec, should make it faster and reduce warning spam. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/run_context/cookbook_compiler.rb4
-rw-r--r--spec/unit/run_context/cookbook_compiler_spec.rb6
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/chef/run_context/cookbook_compiler.rb b/lib/chef/run_context/cookbook_compiler.rb
index 4edf175824..c3cee5841f 100644
--- a/lib/chef/run_context/cookbook_compiler.rb
+++ b/lib/chef/run_context/cookbook_compiler.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2012-2016, Chef Software Inc.
+# Copyright:: Copyright 2012-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -226,7 +226,7 @@ class Chef
begin
# FIXME(log): should be trace
logger.debug("Loading cookbook #{cookbook_name}'s library file: #{filename}")
- Kernel.load(filename)
+ Kernel.require(filename)
@events.library_file_loaded(filename)
rescue Exception => e
@events.library_file_load_failed(filename, e)
diff --git a/spec/unit/run_context/cookbook_compiler_spec.rb b/spec/unit/run_context/cookbook_compiler_spec.rb
index e93088cd5f..c3a4c1b98f 100644
--- a/spec/unit/run_context/cookbook_compiler_spec.rb
+++ b/spec/unit/run_context/cookbook_compiler_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2012-2016, Chef Software Inc.
+# Copyright:: Copyright 2012-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -108,6 +108,10 @@ describe Chef::RunContext::CookbookCompiler do
compiler.compile_libraries
expect(LibraryLoadOrder.load_order).to eq(["dependency1", "dependency2", "test-with-deps", "circular-dep2", "circular-dep1", "test-with-circular-deps"])
+
+ # additionally test that we only load them once
+ compiler.compile_libraries
+ expect(LibraryLoadOrder.load_order).to eq(["dependency1", "dependency2", "test-with-deps", "circular-dep2", "circular-dep1", "test-with-circular-deps"])
end
end