diff --git a/README.md b/README.md index 86373996..030087ad 100644 --- a/README.md +++ b/README.md @@ -107,11 +107,10 @@ Why an array of hashes? Well, that is so that we can refer to the same node or n In the example below we have referred to `centos6a` and `centos7b` in all of our tests as they are in `all_nodes`, `non_windows_servers` and `centos_severs`. However we have *left the more specific references to last*. This is because entries in the test_matrix will override entries above them if applicable. Meaning that we are still only testing each class on the two Centos servers once (Because the gem does de-duplication before running the tests), but also making sure we run `roles::frontend_webserver` twice before checking for idempotency. -**functions** In this section we can add functions that we want to mock when running spec tests. Each function takes the following arguments: +**functions:** In this section we can add functions that we want to mock when running spec tests. Each function takes the following arguments: + - **returns** *Optional: A value to return* -- **returns** *Optional: A value to return* - -**before and after conditions** We can set `before` and `after` blocks before each spec test. These are usually used when the functions to stub are conditional: stub functionx if the OS is windows, stub functiony if the fact java_installed is true. The facts are available through the `node_facts` hash and the trusted facts as `trusted_facts`. +**before and after conditions:** We can set `before` and `after` blocks before each spec test. These are usually used when the functions to stub are conditional: stub functionx if the OS is windows, stub functiony if the fact java_installed is true. The facts are available through the `node_facts` hash and the trusted facts as `trusted_facts`. ```yaml before: @@ -121,7 +120,7 @@ after: - "puts 'Test finished running'" ``` -**opts** The `opts` section overrides defaults for the `Onceover::Controlrepo` class' `opts` hash. +**opts:** The `opts` section overrides defaults for the `Onceover::Controlrepo` class' `opts` hash. ```yaml opts: @@ -140,7 +139,15 @@ opts: - 'spec/factsets/*.facts' ``` -A full example: +**excluded_dirs:** `excluded_dirs` are not copied during the onceover cache folder creation; adding big folder that are not required by the puppet code to this list will speed up test executions. +```yaml +excluded_dirs: + - .git + - .vagrant + - .venv +``` + +**A full example:** ```yaml classes: @@ -203,6 +210,9 @@ functions: opts: :facts_dirs: - spec/factsets + +excluded_dirs: + - .git ``` **Include/Exclude syntax:** This can be used with either `node_groups` or `class_groups` and allows us to save some time by using existing groups to create new ones e.g. diff --git a/lib/onceover/cli/run.rb b/lib/onceover/cli/run.rb index 4048b5ce..0b51e170 100644 --- a/lib/onceover/cli/run.rb +++ b/lib/onceover/cli/run.rb @@ -45,8 +45,9 @@ def self.command run do |opts, args, cmd| repo = Onceover::Controlrepo.new(opts) - Onceover::Deploy.new.deploy_local(repo, opts) - runner = Onceover::Runner.new(repo,Onceover::TestConfig.new(repo.onceover_yaml, opts), :spec) + config = Onceover::TestConfig.new(repo.onceover_yaml, opts) + Onceover::Deploy.new.deploy_local(repo, config, opts) + runner = Onceover::Runner.new(repo, config, :spec) runner.prepare! runner.run_spec! end diff --git a/lib/onceover/deploy.rb b/lib/onceover/deploy.rb index 6e0087f5..17e98542 100644 --- a/lib/onceover/deploy.rb +++ b/lib/onceover/deploy.rb @@ -1,7 +1,7 @@ # handle local deployments (run r10k in .onceover dir) class Onceover class Deploy - def deploy_local(repo = Onceover::Controlrepo.new, opts = {}) + def deploy_local(repo, config, opts = {}) require 'onceover/controlrepo' require 'pathname' @@ -28,7 +28,7 @@ def deploy_local(repo = Onceover::Controlrepo.new, opts = {}) # # If there are more situations like this we can add them to this array as # full paths - excluded_dirs = [] + excluded_dirs = config.additional_excluded_dirs.map { |excluded_dir| Pathname.new("#{repo.root}/#{excluded_dir}") } excluded_dirs << Pathname.new("#{repo.root}/.onceover") excluded_dirs << Pathname.new(ENV['GEM_HOME']) if ENV['GEM_HOME'] diff --git a/lib/onceover/testconfig.rb b/lib/onceover/testconfig.rb index 8ba28f6f..f3bf246b 100644 --- a/lib/onceover/testconfig.rb +++ b/lib/onceover/testconfig.rb @@ -26,6 +26,7 @@ class TestConfig attr_accessor :before_conditions attr_accessor :after_conditions attr_accessor :skip_r10k + attr_accessor :additional_excluded_dirs attr_accessor :force attr_accessor :strict_variables attr_accessor :formatters @@ -72,6 +73,7 @@ def initialize(file, opts = {}) # Initialise all of the groups config['node_groups'].each { |name, members| @node_groups << Onceover::Group.new(name, members) } unless config['node_groups'] == nil config['class_groups'].each { |name, members| @class_groups << Onceover::Group.new(name, members) } unless config['class_groups'] == nil + @additional_excluded_dirs = config['excluded_dirs'] || [] @filter_tags = opts[:tags] ? [opts[:tags].split(',')].flatten : nil @filter_classes = opts[:classes] ? [opts[:classes].split(',')].flatten.map {|x| Onceover::Class.find(x)} : nil