summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Ilyin <dilyin@mirantis.com>2016-07-12 12:16:09 -0500
committerDmitry Ilyin <dilyin@mirantis.com>2016-07-14 13:39:18 -0500
commit10c3599d227d4510f77da06bf1dff0e6d37e1c63 (patch)
tree1e6a7acc864d2894f3e674a0436a2eb49275575d
parent5f690c1460d881846ae859f52bd46e2772959894 (diff)
Add dir_path_task_root
* Specify the root directory of a task Change-Id: Ib064af9f851d7f657b12e6824220f4bc10e305f5
Notes
Notes (review): Verified+1: Fuel CI <fuel-ci-bot@mirantis.com> Code-Review+2: Dmitry Ilyin <dilyin@mirantis.com> Workflow+1: Dmitry Ilyin <dilyin@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Thu, 14 Jul 2016 21:22:10 +0000 Reviewed-on: https://review.openstack.org/341101 Project: openstack/fuel-noop-fixtures Branch: refs/heads/master
-rw-r--r--doc/usage.rst3
-rw-r--r--lib/noop/config/base.rb18
-rw-r--r--lib/noop/manager/report.rb1
-rw-r--r--lib/noop/task/run.rb3
4 files changed, 24 insertions, 1 deletions
diff --git a/doc/usage.rst b/doc/usage.rst
index 958eac6..3055d25 100644
--- a/doc/usage.rst
+++ b/doc/usage.rst
@@ -330,6 +330,9 @@ Paths related:
330- **SPEC_TASK_DIR** Set the path to the task manifests folder. 330- **SPEC_TASK_DIR** Set the path to the task manifests folder.
331- **SPEC_DEPLOYMENT_DIR** Set the path to the *deployment* directory. It's 331- **SPEC_DEPLOYMENT_DIR** Set the path to the *deployment* directory. It's
332 actually use only to find the scripts to update and reset modules. 332 actually use only to find the scripts to update and reset modules.
333- **SPEC_TASK_ROOT_DIR** Set the root path of the RSpec execution.
334 RSpec command will be run from this directory.
335 Usually it's the same dir as the **SPEC_ROOT_DIR**.
333- **WORKSPACE** This variable is passed by the Jenkins jobs or will default to 336- **WORKSPACE** This variable is passed by the Jenkins jobs or will default to
334 the *workspece* folder. Currently used only to store the Ruby gems installed 337 the *workspece* folder. Currently used only to store the Ruby gems installed
335 by the *bundler* if *RVM* is not used. 338 by the *bundler* if *RVM* is not used.
diff --git a/lib/noop/config/base.rb b/lib/noop/config/base.rb
index aa43e91..cf493e3 100644
--- a/lib/noop/config/base.rb
+++ b/lib/noop/config/base.rb
@@ -2,12 +2,16 @@ require 'pathname'
2 2
3module Noop 3module Noop
4 module Config 4 module Config
5 # The root directory of the config sub-module.
6 # It's being used as the root for the relative paths
7 # to the other directories.
5 # @return [Pathname] 8 # @return [Pathname]
6 def self.dir_path_config 9 def self.dir_path_config
7 return @dirname if @dirname 10 return @dirname if @dirname
8 @dirname = Pathname.new(__FILE__).dirname.realpath 11 @dirname = Pathname.new(__FILE__).dirname.realpath
9 end 12 end
10 13
14 # The root directory of the fixtures module.
11 # @return [Pathname] 15 # @return [Pathname]
12 def self.dir_path_root 16 def self.dir_path_root
13 return @dir_path_root if @dir_path_root 17 return @dir_path_root if @dir_path_root
@@ -20,6 +24,20 @@ module Noop
20 end 24 end
21 end 25 end
22 26
27 # The directory where the task will chdir before being run.
28 # Equals to the root dir unless specified.
29 # @return [Pathname]
30 def self.dir_path_task_root
31 return @dir_path_task_root if @dir_path_task_root
32 @dir_path_task_root = Noop::Utils.path_from_env 'SPEC_TASK_ROOT_DIR'
33 @dir_path_task_root = dir_path_root unless @dir_path_task_root
34 begin
35 @dir_path_task_root = @dir_path_task_root.realpath
36 rescue
37 @dir_path_task_root
38 end
39 end
40
23 # @return [Pathname] 41 # @return [Pathname]
24 def self.dir_path_task_spec 42 def self.dir_path_task_spec
25 return @dir_path_task_spec if @dir_path_task_spec 43 return @dir_path_task_spec if @dir_path_task_spec
diff --git a/lib/noop/manager/report.rb b/lib/noop/manager/report.rb
index 8e09746..7978f42 100644
--- a/lib/noop/manager/report.rb
+++ b/lib/noop/manager/report.rb
@@ -205,6 +205,7 @@ Total tasks to run: <%= task_list.count.to_s.colorize :yellow %>
205 paths = [ 205 paths = [
206 :dir_path_config, 206 :dir_path_config,
207 :dir_path_root, 207 :dir_path_root,
208 :dir_path_task_root,
208 :dir_path_task_spec, 209 :dir_path_task_spec,
209 :dir_path_modules_local, 210 :dir_path_modules_local,
210 :dir_path_tasks_local, 211 :dir_path_tasks_local,
diff --git a/lib/noop/task/run.rb b/lib/noop/task/run.rb
index 56ab03c..7acea0e 100644
--- a/lib/noop/task/run.rb
+++ b/lib/noop/task/run.rb
@@ -61,6 +61,7 @@ module Noop
61 'GEM_HOME' => Noop::Config.dir_path_gem_home.to_s, 61 'GEM_HOME' => Noop::Config.dir_path_gem_home.to_s,
62 62
63 'SPEC_ROOT_DIR' => Noop::Config.dir_path_root.to_s, 63 'SPEC_ROOT_DIR' => Noop::Config.dir_path_root.to_s,
64 'SPEC_TASK_ROOT_DIR' => Noop::Config.dir_path_task_root.to_s,
64 'SPEC_DEPLOYMENT_DIR' => Noop::Config.dir_path_deployment.to_s, 65 'SPEC_DEPLOYMENT_DIR' => Noop::Config.dir_path_deployment.to_s,
65 'SPEC_HIERA_DIR' => Noop::Config.dir_path_hiera.to_s, 66 'SPEC_HIERA_DIR' => Noop::Config.dir_path_hiera.to_s,
66 'SPEC_FACTS_DIR' => Noop::Config.dir_path_facts.to_s, 67 'SPEC_FACTS_DIR' => Noop::Config.dir_path_facts.to_s,
@@ -71,7 +72,7 @@ module Noop
71 } 72 }
72 command = "rspec #{file_path_spec.to_s} #{rspec_options} --format json --out #{file_path_report_json.to_s}" 73 command = "rspec #{file_path_spec.to_s} #{rspec_options} --format json --out #{file_path_report_json.to_s}"
73 command = "bundle exec #{command}" if ENV['SPEC_BUNDLE_EXEC'] 74 command = "bundle exec #{command}" if ENV['SPEC_BUNDLE_EXEC']
74 Dir.chdir Noop::Config.dir_path_root 75 Dir.chdir Noop::Config.dir_path_task_root
75 success = Noop::Utils.run environment, command 76 success = Noop::Utils.run environment, command
76 if success.nil? 77 if success.nil?
77 debug 'RSpec command is not found!' 78 debug 'RSpec command is not found!'