summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-11-19 13:40:20 -0800
committerGitHub <noreply@github.com>2018-11-19 13:40:20 -0800
commit44fe94f81d2bb4944d01d5d1054a51e8ce16054b (patch)
tree51ff0b1ed4544671151d04b8b6c9f63d93bfd8e0
parent08a6d9fafe755cd8498953c508aff0eb787e0100 (diff)
parente979ba2ccf10cfa09481e65fd7009bb309247123 (diff)
downloadchef-44fe94f81d2bb4944d01d5d1054a51e8ce16054b.tar.gz
Merge pull request #7954 from chef/lcg/require-libraries
Chef-15: require instead of load libraries
-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