Add dir_path_task_root

* Specify the root directory of a task

Change-Id: Ib064af9f851d7f657b12e6824220f4bc10e305f5
This commit is contained in:
Dmitry Ilyin 2016-07-12 12:16:09 -05:00
parent 5f690c1460
commit 10c3599d22
4 changed files with 24 additions and 1 deletions

View File

@ -330,6 +330,9 @@ Paths related:
- **SPEC_TASK_DIR** Set the path to the task manifests folder.
- **SPEC_DEPLOYMENT_DIR** Set the path to the *deployment* directory. It's
actually use only to find the scripts to update and reset modules.
- **SPEC_TASK_ROOT_DIR** Set the root path of the RSpec execution.
RSpec command will be run from this directory.
Usually it's the same dir as the **SPEC_ROOT_DIR**.
- **WORKSPACE** This variable is passed by the Jenkins jobs or will default to
the *workspece* folder. Currently used only to store the Ruby gems installed
by the *bundler* if *RVM* is not used.

View File

@ -2,12 +2,16 @@ require 'pathname'
module Noop
module Config
# The root directory of the config sub-module.
# It's being used as the root for the relative paths
# to the other directories.
# @return [Pathname]
def self.dir_path_config
return @dirname if @dirname
@dirname = Pathname.new(__FILE__).dirname.realpath
end
# The root directory of the fixtures module.
# @return [Pathname]
def self.dir_path_root
return @dir_path_root if @dir_path_root
@ -20,6 +24,20 @@ module Noop
end
end
# The directory where the task will chdir before being run.
# Equals to the root dir unless specified.
# @return [Pathname]
def self.dir_path_task_root
return @dir_path_task_root if @dir_path_task_root
@dir_path_task_root = Noop::Utils.path_from_env 'SPEC_TASK_ROOT_DIR'
@dir_path_task_root = dir_path_root unless @dir_path_task_root
begin
@dir_path_task_root = @dir_path_task_root.realpath
rescue
@dir_path_task_root
end
end
# @return [Pathname]
def self.dir_path_task_spec
return @dir_path_task_spec if @dir_path_task_spec

View File

@ -205,6 +205,7 @@ Total tasks to run: <%= task_list.count.to_s.colorize :yellow %>
paths = [
:dir_path_config,
:dir_path_root,
:dir_path_task_root,
:dir_path_task_spec,
:dir_path_modules_local,
:dir_path_tasks_local,

View File

@ -61,6 +61,7 @@ module Noop
'GEM_HOME' => Noop::Config.dir_path_gem_home.to_s,
'SPEC_ROOT_DIR' => Noop::Config.dir_path_root.to_s,
'SPEC_TASK_ROOT_DIR' => Noop::Config.dir_path_task_root.to_s,
'SPEC_DEPLOYMENT_DIR' => Noop::Config.dir_path_deployment.to_s,
'SPEC_HIERA_DIR' => Noop::Config.dir_path_hiera.to_s,
'SPEC_FACTS_DIR' => Noop::Config.dir_path_facts.to_s,
@ -71,7 +72,7 @@ module Noop
}
command = "rspec #{file_path_spec.to_s} #{rspec_options} --format json --out #{file_path_report_json.to_s}"
command = "bundle exec #{command}" if ENV['SPEC_BUNDLE_EXEC']
Dir.chdir Noop::Config.dir_path_root
Dir.chdir Noop::Config.dir_path_task_root
success = Noop::Utils.run environment, command
if success.nil?
debug 'RSpec command is not found!'