thrust 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 978a630b927682d5514cf9ce5b71ce2bc2c9a9ff
4
- data.tar.gz: ca9c565b330db40e39c02a7ca6ee600ae1a1a682
3
+ metadata.gz: cb3c733a86a1d3a7d7aec4521cc0c746713b8225
4
+ data.tar.gz: e9b1773c0d258a7aa9409b6cb0e07fd72eda7157
5
5
  SHA512:
6
- metadata.gz: 483178b25da64bc6d343d3032fc60b4d0bf12fdf5380794564a4bec13f2dc0e97dd6424f4111ff06c83ce891d71d5ce5e30c48ae784b0ecb8824f91142edcbe8
7
- data.tar.gz: 79ea4ddc3b9ad3879d0572a354922b7a1d2ac4450f1134ee2cdf53103a916e6c3414487d6801458165adc573924c530c0c6ceb467a38f57586a722ca35d9123d
6
+ metadata.gz: b498bcb659a91cbfd17fabef26e3a7b26e109a034e86475526d5255321ff049395e75675dc76212c43afbb1a9092ea33c5b6ef42445eb3476c14e863ef96d486
7
+ data.tar.gz: 6579b916c3db7a727960a744147773d10e438ff97f20ec940837f33e24db7868f9529b515166379e1a2efda12ba92feec5a6dc6a2404bb66b171cf80f7571de0
@@ -1,4 +1,4 @@
1
- thrust_version: 0.3
1
+ thrust_version: 0.4
2
2
  project_name: My Great Project
3
3
  app_name: My Great App
4
4
 
@@ -1,6 +1,7 @@
1
- thrust_version: 0.3
1
+ thrust_version: 0.4
2
2
  project_name: My Great Project # do not use if building with an xcode workspace
3
3
  # workspace_name: My Workspace # use if building with an xcode workspace
4
+ # path_to_xcodeproj: 'App/MyApp.xcodeproj' # use if xcodeproj is not in the same directory as this yaml file. Optional.
4
5
  app_name: My Great App
5
6
  ios_distribution_certificate: 'Name of Distribution Signing Certificate'
6
7
  ios_sim_binary: 'ios-sim' # or wax-sim. iOS only.
@@ -17,6 +18,7 @@ deployment_targets:
17
18
  ios_target: MyGreatAppTarget # Name of the build target. Optional, defaults to app name. iOS only.
18
19
  ios_build_configuration: Release # iOS only
19
20
  ios_provisioning_search_query: 'query to find Provisioning Profile' # iOS only. Optional.
21
+ versioning_method: 'none' # Optional. Leave blank to use Git commit sha's for build numbers.
20
22
 
21
23
  demo:
22
24
  distribution_list: Beta Testers
@@ -26,10 +28,12 @@ ios_spec_targets:
26
28
  specs: # This is the name of the rake task: `rake specs`
27
29
  target: UISpecs # name of the build target
28
30
  # scheme: Specs (My Great App) # use in addition to target when you want to use a scheme (necessary if you are building with an xcode workspace)
31
+ type: app # Spec target type: app or bundle. Optional, defaults to app.
29
32
  build_configuration: Debug # name of the build configuration
30
33
  build_sdk: iphonesimulator7.0 # SDK used to build the target. Optional, defaults to latest iphonesimulator.
31
34
  runtime_sdk: 7.0 # SDK used to run the target. Not optional.
32
- device: ipad # Device to run the specs on. Optional, defaults to iPhone.
35
+ # device: ipad # Device to run the specs on. Deprecated in ios-sim 3.0+, use device_type_id instead.
36
+ device_type_id: com.apple.CoreSimulator.SimDeviceType.iPad-Retina, 7.0 # required if using ios-sim 3.0
33
37
 
34
38
  integration:
35
39
  target: IntegrationSpecs
@@ -0,0 +1,14 @@
1
+ require_relative '../thrust'
2
+
3
+ @thrust = Thrust::Config.make(Dir.getwd, File.join(Dir.getwd, 'thrust.yml'))
4
+
5
+ namespace :autotag do
6
+ task :create, :stage do |_, args|
7
+ Thrust::Tasks::Autotag::Create.new.run(args[:stage])
8
+ end
9
+
10
+ desc 'Show the commit that is currently deployed to each environment'
11
+ task :list do
12
+ Thrust::Tasks::Autotag::List.new.run(@thrust)
13
+ end
14
+ end
data/lib/tasks/cedar.rake CHANGED
@@ -1,74 +1,33 @@
1
- require 'yaml'
2
- require 'tmpdir'
3
- require File.expand_path('../../thrust', __FILE__)
1
+ require_relative '../thrust'
4
2
 
5
3
  @thrust = Thrust::Config.make(Dir.getwd, File.join(Dir.getwd, 'thrust.yml'))
6
- @xcode_tools_provider = Thrust::IOS::XCodeToolsProvider.new
7
- @executor = Thrust::Executor.new
8
4
 
9
5
  desc 'Trim whitespace'
10
6
  task :trim do
11
- awk_statement = <<-AWK
12
- {
13
- if ($1 == "RM" || $1 == "R")
14
- print $4;
15
- else if ($1 != "D")
16
- print $2;
17
- }
18
- AWK
19
- awk_statement.gsub!(%r{\s+}, " ")
20
-
21
- @executor.system_or_exit %Q[git status --porcelain | awk '#{awk_statement}' | grep -e '.*\.[cmh]$' | xargs sed -i '' -e 's/ / /g;s/ *$//g;']
7
+ Thrust::Tasks::Trim.new.run
22
8
  end
23
9
 
24
10
  desc 'Remove any focus from specs'
25
11
  task :nof do
26
- substitutions = focused_methods.map do |method|
27
- unfocused_method = method.sub(/^f/, '')
28
- "-e 's/#{method}/#{unfocused_method}/g;'"
29
- end
30
-
31
- @executor.system_or_exit %Q[ rake focused_specs | xargs -I filename sed -i '' #{substitutions.join(' ')} "filename" ]
12
+ Thrust::Tasks::Nof.new.run
32
13
  end
33
14
 
34
15
  desc 'Print out names of files containing focused specs'
35
16
  task :focused_specs do
36
- pattern = focused_methods.join("\\|")
37
- directories = @thrust.app_config['ios_spec_targets'].values.map {|h| h['target']}.join(' ')
38
- @executor.system_or_exit %Q[ grep -l -r -e "\\(#{pattern}\\)" #{directories} | grep -v 'Frameworks' ; exit 0 ]
17
+ Thrust::Tasks::FocusedSpecs.new.run(@thrust)
39
18
  end
40
19
 
41
20
  desc 'Clean all targets'
42
21
  task :clean do
43
- xcode_tools_instance(nil).clean_build
22
+ Thrust::Tasks::Clean.new.run(@thrust)
44
23
  end
45
24
 
46
25
  desc 'Clean all targets (deprecated, use "clean")'
47
26
  task :clean_build => :clean
48
27
 
49
- (@thrust.app_config['ios_spec_targets'] || []).each do |task_name, target_info|
50
- desc target_info['scheme'] ? "Run the #{target_info['scheme'].inspect} scheme" : "Run the #{target_info['target'].inspect} target"
51
- task task_name, :runtime_sdk do |_, args|
52
- build_configuration = target_info['build_configuration']
53
- target = target_info['target']
54
- scheme = target_info['scheme']
55
- build_sdk = target_info['build_sdk'] || 'iphonesimulator' #build sdk - version you compile the code with
56
- runtime_sdk = args[:runtime_sdk] || target_info['runtime_sdk'] #runtime sdk
57
-
58
- xcode_tools = xcode_tools_instance(build_configuration)
59
- xcode_tools.build_scheme_or_target(scheme || target, build_sdk, 'i386')
60
-
61
- cedar_success = Thrust::IOS::Cedar.new.run($stdout, build_configuration, target, runtime_sdk, build_sdk, target_info['device'], @thrust.build_dir, @thrust.app_config['ios_sim_binary'])
62
-
63
- exit(1) unless cedar_success
28
+ @thrust.app_config.ios_spec_targets.each do |target_name, target_info|
29
+ desc target_info.scheme ? "Run the #{target_info.scheme} scheme" : "Run the #{target_info.target} target"
30
+ task target_name, :runtime_sdk do |_, args|
31
+ exit(1) unless Thrust::Tasks::IOSSpecs.new.run(@thrust, target_info, args)
64
32
  end
65
33
  end
66
-
67
- def focused_methods
68
- %w(fit fcontext fdescribe).map { |method| "#{method}(@" }
69
- end
70
-
71
- def xcode_tools_instance(build_configuration)
72
- tools_options = { project_name: @thrust.app_config['project_name'], workspace_name: @thrust.app_config['workspace_name'] }
73
- @xcode_tools_provider.instance($stdout, build_configuration, @thrust.build_dir, tools_options)
74
- end
@@ -1,13 +1,11 @@
1
- require 'yaml'
2
- require 'tempfile'
3
- require File.expand_path('../../thrust', __FILE__)
1
+ require_relative '../thrust'
4
2
 
5
3
  @thrust = Thrust::Config.make(Dir.getwd, File.join(Dir.getwd, 'thrust.yml'))
6
4
 
7
5
  namespace :testflight do
8
6
  android_project = File.exists?('AndroidManifest.xml')
9
7
 
10
- @thrust.app_config['deployment_targets'].each do |task_name, deployment_config|
8
+ @thrust.app_config.deployment_targets.each do |task_name, deployment_config|
11
9
  if android_project
12
10
  desc "Deploy Android build to #{task_name} (use NOTIFY=false to prevent team notification)"
13
11
  task task_name do |_, _|
@@ -25,16 +23,3 @@ namespace :testflight do
25
23
  end
26
24
  end
27
25
  end
28
-
29
- namespace :autotag do
30
- task :create, :stage do |_, args|
31
- `autotag create #{args[:stage]}`
32
- end
33
-
34
- desc 'Show the commit that is currently deployed to each environment'
35
- task :list do
36
- @thrust.app_config['deployment_targets'].each do |deployment_target, _|
37
- puts Thrust::Git.new(Thrust::Executor.new, $stdout).commit_summary_for_last_deploy(deployment_target)
38
- end
39
- end
40
- end
@@ -1,12 +1,13 @@
1
- require File.expand_path('../../thrust', __FILE__)
1
+ require_relative '../thrust'
2
+
3
+ @thrust = Thrust::Config.make(Dir.getwd, File.join(Dir.getwd, 'thrust.yml'))
2
4
 
3
5
  desc 'Set build number'
4
6
  task :set_build_number, :build_number do |_, args|
5
- executor = Thrust::Executor.new
6
-
7
7
  if File.exists?('AndroidManifest.xml')
8
- Thrust::Android::Tools.new(executor, $stdout).change_build_number(Time.now.utc.strftime('%y%m%d%H%M'), args[:build_number])
8
+ Thrust::Android::Tools.new.change_build_number(Time.now.utc.strftime('%y%m%d%H%M'), args[:build_number])
9
9
  else
10
- Thrust::IOS::AgvTool.new(executor, $stdout).change_build_number(args[:build_number])
10
+ path_to_xcodeproj = @thrust.app_config.path_to_xcodeproj
11
+ Thrust::IOS::AgvTool.new.change_build_number(args[:build_number], path_to_xcodeproj)
11
12
  end
12
13
  end
@@ -1,22 +1,26 @@
1
- class Thrust::Android::Deploy
2
- def initialize(out, tools, git, testflight, notify, distribution_list, autogenerate_notes, deployment_target)
3
- @out = out
4
- @tools = tools
5
- @git = git
6
- @testflight = testflight
7
- @notify = notify
8
- @distribution_list = distribution_list
9
- @deployment_target = deployment_target
10
- @autogenerate_notes = autogenerate_notes
11
- end
1
+ module Thrust
2
+ module Android
3
+ class Deploy
4
+ def initialize(out, tools, git, testflight, notify, distribution_list, autogenerate_notes, deployment_target)
5
+ @out = out
6
+ @tools = tools
7
+ @git = git
8
+ @testflight = testflight
9
+ @notify = notify
10
+ @distribution_list = distribution_list
11
+ @deployment_target = deployment_target
12
+ @autogenerate_notes = autogenerate_notes
13
+ end
12
14
 
13
- def run
14
- @git.ensure_clean
15
- @tools.change_build_number(Time.now.utc.strftime('%y%m%d%H%M'), @git.current_commit)
16
- apk_path = @tools.build_signed_release
15
+ def run
16
+ @git.ensure_clean
17
+ @tools.change_build_number(Time.now.utc.strftime('%y%m%d%H%M'), @git.current_commit)
18
+ apk_path = @tools.build_signed_release
17
19
 
18
- @testflight.upload(apk_path, @notify, @distribution_list, @autogenerate_notes, @deployment_target)
20
+ @testflight.upload(apk_path, @notify, @distribution_list, @autogenerate_notes, @deployment_target)
19
21
 
20
- @git.reset
22
+ @git.reset
23
+ end
24
+ end
21
25
  end
22
26
  end
@@ -1,13 +1,17 @@
1
- class Thrust::Android::DeployProvider
2
- def instance(thrust_config, deployment_config, deployment_target)
3
- thrust_executor = Thrust::Executor.new
4
- tools = Thrust::Android::Tools.new(thrust_executor, $stdout)
5
- git = Thrust::Git.new(thrust_executor, $stdout)
1
+ module Thrust
2
+ module Android
3
+ class DeployProvider
4
+ def instance(thrust_config, deployment_config, deployment_target)
5
+ thrust_executor = Thrust::Executor.new
6
+ tools = Thrust::Android::Tools.new($stdout, thrust_executor)
7
+ git = Thrust::Git.new($stdout, thrust_executor)
6
8
 
7
- testflight_config = thrust_config.app_config['testflight']
8
- testflight = Thrust::Testflight.new(thrust_executor, $stdout, $stdin, testflight_config['api_token'], testflight_config['team_token'])
9
+ testflight_config = thrust_config.app_config.testflight
10
+ testflight = Thrust::Testflight.new(thrust_executor, $stdout, $stdin, testflight_config.api_token, testflight_config.team_token)
9
11
 
10
- autogenerate_notes = deployment_config['note_generation_method'] == 'autotag'
11
- Thrust::Android::Deploy.new($stdout, tools, git, testflight, deployment_config['notify'], deployment_config['distribution_list'], autogenerate_notes, deployment_target)
12
+ autogenerate_notes = deployment_config.note_generation_method == 'autotag'
13
+ Thrust::Android::Deploy.new($stdout, tools, git, testflight, deployment_config.notify, deployment_config.distribution_list, autogenerate_notes, deployment_target)
14
+ end
15
+ end
12
16
  end
13
17
  end
@@ -1,38 +1,42 @@
1
1
  require 'colorize'
2
2
 
3
- class Thrust::Android::Tools
4
- def initialize(thrust_executor, out)
5
- @thrust_executor = thrust_executor
6
- @out = out
7
- end
3
+ module Thrust
4
+ module Android
5
+ class Tools
6
+ def initialize(out = $stdout, thrust_executor = Thrust::Executor.new)
7
+ @thrust_executor = thrust_executor
8
+ @out = out
9
+ end
8
10
 
9
- def change_build_number(version_code, version_name)
10
- @thrust_executor.system_or_exit(
11
- "sed -i ''" +
11
+ def change_build_number(version_code, version_name)
12
+ @thrust_executor.system_or_exit(
13
+ "sed -i ''" +
12
14
  " -e 's/android:versionCode=\"[0-9]*\"/android:versionCode=\"#{version_code}\"/'" +
13
15
  " -e 's/android:versionName=\"\\([^ \"]*\\)[^\"]*\"/android:versionName=\"\\1 (#{version_name})\"/'" +
14
16
  " AndroidManifest.xml")
15
- @thrust_executor.system_or_exit(
16
- "sed -i ''" +
17
+ @thrust_executor.system_or_exit(
18
+ "sed -i ''" +
17
19
  " '1,/<version>/s/<version>\\([^- <]*\\)[^<]*<\\/version>/<version>\\1 (#{version_name})<\\/version>/'" +
18
20
  " pom.xml")
19
- end
21
+ end
20
22
 
21
- def build_signed_release
22
- verify_android_installed!
23
- @thrust_executor.system_or_exit('mvn clean package -Prelease')
24
- Dir.glob('target/*-signed-aligned.apk').first or raise 'Signed APK was not generated'
25
- end
23
+ def build_signed_release
24
+ verify_android_installed!
25
+ @thrust_executor.system_or_exit('mvn clean package -Prelease')
26
+ Dir.glob('target/*-signed-aligned.apk').first or raise 'Signed APK was not generated'
27
+ end
26
28
 
27
- private
29
+ private
28
30
 
29
- def verify_android_installed!
30
- if ENV['ANDROID_HOME'].nil?
31
- if File.directory?('/usr/local/opt/android-sdk')
32
- @out.puts 'Setting /usr/local/opt/android-sdk as ANDROID_HOME...'.magenta
33
- ENV['ANDROID_HOME'] = '/usr/local/opt/android-sdk'
34
- else
35
- raise('**********Android is not installed. Run `brew install android`.**********')
31
+ def verify_android_installed!
32
+ if ENV['ANDROID_HOME'].nil?
33
+ if File.directory?('/usr/local/opt/android-sdk')
34
+ @out.puts 'Setting /usr/local/opt/android-sdk as ANDROID_HOME...'.magenta
35
+ ENV['ANDROID_HOME'] = '/usr/local/opt/android-sdk'
36
+ else
37
+ raise('**********Android is not installed. Run `brew install android`.**********')
38
+ end
39
+ end
36
40
  end
37
41
  end
38
42
  end
@@ -0,0 +1,57 @@
1
+ require_relative 'deployment_target'
2
+ require_relative 'ios_spec_target'
3
+ require_relative 'testflight_credentials'
4
+
5
+ module Thrust
6
+ class AppConfig
7
+ attr_reader :app_name,
8
+ :deployment_targets,
9
+ :ios_distribution_certificate,
10
+ :ios_sim_binary,
11
+ :ios_spec_targets,
12
+ :project_name,
13
+ :testflight,
14
+ :thrust_version,
15
+ :workspace_name,
16
+ :path_to_xcodeproj
17
+
18
+ def initialize(attributes)
19
+ @app_name = attributes['app_name']
20
+ @deployment_targets = generate_deployment_targets(attributes['deployment_targets'])
21
+ @ios_distribution_certificate = attributes['ios_distribution_certificate']
22
+ @ios_sim_binary = attributes['ios_sim_binary']
23
+ @ios_spec_targets = generate_ios_spec_targets(attributes['ios_spec_targets'])
24
+ @project_name = attributes['project_name']
25
+ @testflight = generate_testflight_credentials(attributes['testflight'])
26
+ @thrust_version = attributes['thrust_version'].to_s
27
+ @workspace_name = attributes['workspace_name']
28
+ @path_to_xcodeproj = attributes['path_to_xcodeproj']
29
+ end
30
+
31
+ private
32
+
33
+ def generate_ios_spec_targets(ios_spec_targets_hash)
34
+ return {} if ios_spec_targets_hash.nil?
35
+
36
+ ios_spec_targets_hash.inject({}) do |existing, (key, value)|
37
+ existing[key] = IOSSpecTarget.new(value)
38
+ existing
39
+ end
40
+ end
41
+
42
+ def generate_deployment_targets(deployment_targets_hash)
43
+ return {} if deployment_targets_hash.nil?
44
+
45
+ deployment_targets_hash.inject({}) do |existing, (key, value)|
46
+ existing[key] = DeploymentTarget.new(value)
47
+ existing
48
+ end
49
+ end
50
+
51
+ def generate_testflight_credentials(testflight_credentials_hash)
52
+ return if testflight_credentials_hash.nil?
53
+
54
+ TestflightCredentials.new(testflight_credentials_hash)
55
+ end
56
+ end
57
+ end
data/lib/thrust/config.rb CHANGED
@@ -1,39 +1,43 @@
1
1
  require 'colorize'
2
+ require_relative 'app_config'
3
+ require 'yaml'
2
4
 
3
- class Thrust::Config
4
- attr_reader :project_root, :app_config, :build_dir
5
- THRUST_VERSION = 0.3
6
- THRUST_ROOT = File.expand_path('../..', __FILE__)
5
+ module Thrust
6
+ class Config
7
+ attr_reader :project_root, :app_config, :build_dir
7
8
 
8
- def self.make(relative_project_root, config_file)
9
- begin
10
- config_file_contents = YAML.load_file(config_file)
11
- rescue Errno::ENOENT
12
- puts ""
13
- puts " Missing thrust.yml. Create by running:\n".red
14
- puts " cp thrust.example.yml thrust.yml".blue
15
- exit 1
16
- rescue Psych::SyntaxError
17
- puts ""
18
- puts " Malformed thrust.yml.".red
19
- exit 1
9
+ THRUST_VERSION = '0.4'
10
+ THRUST_ROOT = File.expand_path('../..', __FILE__)
11
+
12
+ def self.make(relative_project_root, config_file)
13
+ begin
14
+ config_file_contents = YAML.load_file(config_file)
15
+ rescue Errno::ENOENT
16
+ puts ""
17
+ puts " Missing thrust.yml. Create by running:\n".red
18
+ puts " cp thrust.example.yml thrust.yml".blue
19
+ exit 1
20
+ rescue Psych::SyntaxError
21
+ puts ""
22
+ puts " Malformed thrust.yml.".red
23
+ exit 1
24
+ end
25
+ new(relative_project_root, config_file_contents)
20
26
  end
21
- new(relative_project_root, config_file_contents)
22
- end
23
27
 
24
- def initialize(relative_project_root, config)
25
- @project_root = File.expand_path(relative_project_root)
26
- @build_dir = File.join(project_root, 'build')
27
- @app_config = config
28
- verify_configuration(@app_config)
29
- end
28
+ def initialize(relative_project_root, config)
29
+ @project_root = File.expand_path(relative_project_root)
30
+ @build_dir = File.join(project_root, 'build')
31
+ @app_config = Thrust::AppConfig.new(config)
32
+ verify_configuration
33
+ end
30
34
 
31
- private
35
+ private
32
36
 
33
- def verify_configuration(config)
34
- config['thrust_version'] ||= 0
35
- if config['thrust_version'] != THRUST_VERSION
36
- fail "Invalid configuration. Have you updated thrust recently? Your thrust.yml specifies version #{config['thrust_version']}, but thrust is at version #{THRUST_VERSION}. See README for details.".red
37
+ def verify_configuration
38
+ if @app_config.thrust_version != THRUST_VERSION
39
+ fail "Invalid configuration. Have you updated thrust recently? Your thrust.yml specifies an out-of-date version, and thrust is at version: #{THRUST_VERSION}. See README for details.".red
40
+ end
37
41
  end
38
42
  end
39
43
  end
@@ -0,0 +1,21 @@
1
+ module Thrust
2
+ class DeploymentTarget
3
+ attr_reader :distribution_list,
4
+ :ios_build_configuration,
5
+ :ios_provisioning_search_query,
6
+ :ios_target,
7
+ :note_generation_method,
8
+ :notify,
9
+ :versioning_method
10
+
11
+ def initialize(attributes)
12
+ @distribution_list = attributes['distribution_list']
13
+ @ios_build_configuration = attributes['ios_build_configuration']
14
+ @ios_provisioning_search_query = attributes['ios_provisioning_search_query']
15
+ @ios_target = attributes['ios_target']
16
+ @note_generation_method = attributes['note_generation_method']
17
+ @notify = attributes['notify']
18
+ @versioning_method = attributes['versioning_method']
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ module Thrust
2
+ class ExecutionHelper
3
+ def capture_status_from_command(command, env = {})
4
+ system(env, command)
5
+ end
6
+
7
+ def capture_status_and_output_from_command(command, env = {})
8
+ env_string = ''
9
+ for key in env.keys
10
+ env_string += "#{key}=#{env[key]} "
11
+ end
12
+
13
+ output = `#{env_string}#{command}`
14
+ { success: $?.exitstatus == 0, output: output }
15
+ end
16
+ end
17
+ end
@@ -1,29 +1,44 @@
1
- class Thrust::Executor
2
- CommandFailed = Class.new(StandardError)
1
+ module Thrust
2
+ class Executor
3
+ CommandFailed = Class.new(StandardError)
3
4
 
4
- def system_or_exit(cmd, output_file = nil)
5
- system(cmd, output_file) or raise(CommandFailed, '******** Build failed ********')
6
- end
5
+ def initialize(out = STDERR, execution_helper = Thrust::ExecutionHelper.new)
6
+ @execution_helper = execution_helper
7
+ @out = out
8
+ end
7
9
 
8
- def system(cmd, output_file = nil)
9
- STDERR.puts "Executing #{cmd}"
10
- cmd += " > #{output_file}" if output_file
11
- Kernel::system(cmd)
12
- end
10
+ def system_or_exit(cmd, output_file = nil, env = {})
11
+ @out.puts "Executing #{cmd}"
12
+ cmd += " > #{output_file}" if output_file
13
13
 
14
- def capture_output_from_system(cmd)
15
- captured_output = `#{cmd}`
16
- raise(CommandFailed, '******** Build failed ********') if $?.exitstatus > 0
14
+ unless @execution_helper.capture_status_from_command(cmd, env)
15
+ raise(CommandFailed, '******** Build failed ********')
16
+ end
17
+ end
17
18
 
18
- captured_output
19
- end
19
+ def system(cmd, output_file = nil)
20
+ @out.puts "Executing #{cmd}"
21
+ cmd += " > #{output_file}" if output_file
22
+
23
+ @execution_helper.capture_status_from_command(cmd)
24
+ end
25
+
26
+ def capture_output_from_system(cmd, env = {})
27
+ execution = @execution_helper.capture_status_and_output_from_command(cmd, env)
28
+
29
+ raise(CommandFailed, '******** Build failed ********') unless execution[:success]
30
+
31
+ execution[:output]
32
+ end
20
33
 
21
- def check_command_for_failure(cmd)
22
- STDERR.puts "Executing #{cmd} and checking for FAILURE"
23
- result = %x[#{cmd} 2>&1]
24
- STDERR.puts "Results:"
25
- STDERR.puts result
34
+ def check_command_for_failure(cmd, env = {})
35
+ @out.puts "Executing #{cmd} and checking for FAILURE"
36
+ execution = @execution_helper.capture_status_and_output_from_command("#{cmd} 2>&1", env)
37
+ result = execution[:output]
38
+ @out.puts "Results:"
39
+ @out.puts result
26
40
 
27
- result.include?("Finished") && !result.include?("FAILURE") && !result.include?("EXCEPTION")
41
+ result.include?("Finished") && !result.include?("FAILURE") && !result.include?("EXCEPTION")
42
+ end
28
43
  end
29
44
  end