ceedling 0.27.0 → 0.28.1

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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/assets/project_as_gem.yml +6 -0
  3. data/assets/project_with_guts.yml +6 -0
  4. data/assets/project_with_guts_gcov.yml +88 -0
  5. data/assets/test_example_file_boom.c +13 -0
  6. data/assets/test_example_file_success.c +14 -0
  7. data/bin/ceedling +57 -113
  8. data/ceedling.gemspec +1 -1
  9. data/config/test_environment.rb +0 -1
  10. data/examples/blinky/project.yml +1 -1
  11. data/examples/temp_sensor/project.yml +7 -1
  12. data/examples/temp_sensor/rakefile.rb +3 -1
  13. data/lib/ceedling/build_invoker_utils.rb +14 -2
  14. data/lib/ceedling/configurator.rb +3 -1
  15. data/lib/ceedling/configurator_builder.rb +6 -4
  16. data/lib/ceedling/configurator_setup.rb +5 -1
  17. data/lib/ceedling/defaults.rb +5 -2
  18. data/lib/ceedling/dependinator.rb +1 -1
  19. data/lib/ceedling/file_path_utils.rb +1 -2
  20. data/lib/ceedling/generator_test_results.rb +3 -2
  21. data/lib/ceedling/generator_test_results_sanity_checker.rb +4 -3
  22. data/lib/ceedling/project_file_loader.rb +26 -9
  23. data/lib/ceedling/rakefile.rb +9 -2
  24. data/lib/ceedling/release_invoker.rb +1 -1
  25. data/lib/ceedling/reportinator.rb +18 -1
  26. data/lib/ceedling/system_utils.rb +6 -1
  27. data/lib/ceedling/system_wrapper.rb +2 -1
  28. data/lib/ceedling/target_loader.rb +2 -2
  29. data/lib/ceedling/tasks_filesystem.rake +8 -2
  30. data/lib/ceedling/tool_executor_helper.rb +71 -22
  31. data/lib/ceedling/version.rb +1 -1
  32. data/license.txt +1 -1
  33. data/out.fail +21 -0
  34. data/plugins/command_hooks/lib/command_hooks.rb +2 -1
  35. data/plugins/gcov/config/defaults.yml +22 -0
  36. data/plugins/gcov/gcov.rake +79 -65
  37. data/plugins/gcov/lib/gcov.rb +25 -38
  38. data/plugins/gcov/lib/gcov_constants.rb +16 -0
  39. data/spec/build_invoker_utils_spec.rb +54 -0
  40. data/spec/file_finder_helper_spec.rb +53 -0
  41. data/spec/gcov/gcov_deployment_spec.rb +70 -0
  42. data/spec/gcov/gcov_test_cases_spec.rb +91 -0
  43. data/spec/generator_test_results_sanity_checker_spec.rb +88 -0
  44. data/spec/generator_test_results_spec.rb +102 -0
  45. data/spec/reportinator_spec.rb +19 -0
  46. data/spec/spec_system_helper.rb +67 -5
  47. data/spec/support/other_target.yml +0 -0
  48. data/spec/support/target.yml +0 -0
  49. data/spec/support/test_example.fail +21 -0
  50. data/spec/support/test_example.pass +21 -0
  51. data/spec/support/test_example_empty.pass +13 -0
  52. data/spec/support/test_example_ignore.pass +21 -0
  53. data/spec/support/test_example_mangled.pass +19 -0
  54. data/spec/system/deployment_spec.rb +25 -5
  55. data/spec/system_utils_spec.rb +56 -0
  56. data/spec/target_loader_spec.rb +30 -0
  57. data/spec/tool_executor_helper_spec.rb +310 -0
  58. data/vendor/cmock/scripts/create_makefile.rb +35 -12
  59. data/vendor/unity/src/unity_internals.h +3 -3
  60. metadata +62 -27
  61. data/assets/rakefile_as_gem.rb +0 -3
  62. data/assets/rakefile_with_guts.rb +0 -6
  63. data/vendor/constructor/History.rdoc +0 -19
  64. data/vendor/constructor/README.rdoc +0 -72
  65. data/vendor/constructor/Rakefile +0 -33
  66. data/vendor/constructor/homepage/Notes.txt +0 -27
  67. data/vendor/constructor/homepage/Rakefile +0 -15
  68. data/vendor/constructor/homepage/index.erb +0 -27
  69. data/vendor/constructor/homepage/index.html +0 -36
  70. data/vendor/constructor/homepage/page_header.graffle +0 -0
  71. data/vendor/constructor/homepage/page_header.html +0 -9
  72. data/vendor/constructor/homepage/page_header.png +0 -0
  73. data/vendor/constructor/homepage/sample_code.png +0 -0
  74. data/vendor/constructor/homepage/sample_code.rb +0 -12
  75. data/vendor/constructor/lib/constructor.rb +0 -127
  76. data/vendor/constructor/lib/constructor_struct.rb +0 -33
  77. data/vendor/constructor/specs/constructor_spec.rb +0 -407
  78. data/vendor/constructor/specs/constructor_struct_spec.rb +0 -84
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+ require 'ceedling/reportinator'
3
+
4
+ describe Reportinator do
5
+ before(:each) do
6
+ @rp = described_class.new
7
+ end
8
+
9
+ describe '#generate_banner' do
10
+ it 'generates a banner with a width based on a string' do
11
+ expect(@rp.generate_banner("Hello world!")).to eq("------------\nHello world!\n------------\n")
12
+ end
13
+
14
+ it 'generates a banner with a fixed width' do
15
+ expect(@rp.generate_banner("Hello world!", 3)).to eq("---\nHello world!\n---\n")
16
+ end
17
+ end
18
+
19
+ end
@@ -60,7 +60,7 @@ class SystemContext
60
60
  checks = ["bundle exec ruby -S ceedling 2>&1"]
61
61
  checks.each do |c|
62
62
  `#{c}`
63
- raise VerificationFailed.new(c) unless $?.success?
63
+ #raise VerificationFailed.new(c) unless $?.success?
64
64
  end
65
65
  end
66
66
  end
@@ -125,7 +125,6 @@ module CeedlingTestCases
125
125
  @c.with_context do
126
126
  Dir.chdir @proj_name do
127
127
  expect(File.exists?("project.yml")).to eq true
128
- expect(File.exists?("rakefile.rb")).to eq true
129
128
  expect(File.exists?("src")).to eq true
130
129
  expect(File.exists?("test")).to eq true
131
130
  end
@@ -139,7 +138,6 @@ module CeedlingTestCases
139
138
  expect(output).to match(/upgraded!/i)
140
139
  Dir.chdir @proj_name do
141
140
  expect(File.exists?("project.yml")).to eq true
142
- expect(File.exists?("rakefile.rb")).to eq true
143
141
  expect(File.exists?("src")).to eq true
144
142
  expect(File.exists?("test")).to eq true
145
143
  all_docs = Dir["vendor/ceedling/docs/*.pdf"].length + Dir["vendor/ceedling/docs/*.md"].length
@@ -182,7 +180,24 @@ module CeedlingTestCases
182
180
  end
183
181
  end
184
182
 
185
- def can_test_projects
183
+ def can_test_projects_with_success
184
+ @c.with_context do
185
+ Dir.chdir @proj_name do
186
+ FileUtils.cp test_asset_path("example_file.h"), 'src/'
187
+ FileUtils.cp test_asset_path("example_file.c"), 'src/'
188
+ FileUtils.cp test_asset_path("test_example_file_success.c"), 'test/'
189
+
190
+ output = `bundle exec ruby -S ceedling test:all`
191
+ expect($?.exitstatus).to match(0) # Since a test either pass or are ignored, we return success here
192
+ expect(output).to match(/TESTED:\s+\d/)
193
+ expect(output).to match(/PASSED:\s+\d/)
194
+ expect(output).to match(/FAILED:\s+\d/)
195
+ expect(output).to match(/IGNORED:\s+\d/)
196
+ end
197
+ end
198
+ end
199
+
200
+ def can_test_projects_with_fail
186
201
  @c.with_context do
187
202
  Dir.chdir @proj_name do
188
203
  FileUtils.cp test_asset_path("example_file.h"), 'src/'
@@ -190,7 +205,7 @@ module CeedlingTestCases
190
205
  FileUtils.cp test_asset_path("test_example_file.c"), 'test/'
191
206
 
192
207
  output = `bundle exec ruby -S ceedling test:all`
193
- expect($?.exitstatus).to match(0)
208
+ expect($?.exitstatus).to match(1) # Since a test fails, we return error here
194
209
  expect(output).to match(/TESTED:\s+\d/)
195
210
  expect(output).to match(/PASSED:\s+\d/)
196
211
  expect(output).to match(/FAILED:\s+\d/)
@@ -199,6 +214,21 @@ module CeedlingTestCases
199
214
  end
200
215
  end
201
216
 
217
+ def can_test_projects_with_compile_error
218
+ @c.with_context do
219
+ Dir.chdir @proj_name do
220
+ FileUtils.cp test_asset_path("example_file.h"), 'src/'
221
+ FileUtils.cp test_asset_path("example_file.c"), 'src/'
222
+ FileUtils.cp test_asset_path("test_example_file_boom.c"), 'test/'
223
+
224
+ output = `bundle exec ruby -S ceedling test:all`
225
+ expect($?.exitstatus).to match(1) # Since a test explodes, we return error here
226
+ expect(output).to match(/ERROR: Ceedling Failed/)
227
+ end
228
+ end
229
+ end
230
+
231
+
202
232
  def can_fetch_non_project_help
203
233
  @c.with_context do
204
234
  #notice we don't change directory into the project
@@ -239,7 +269,39 @@ module CeedlingTestCases
239
269
  output = `bundle exec ruby -S ceedling test:all`
240
270
  expect($?.exitstatus).to match(0)
241
271
  expect(output).to match(/Need to Implement ponies/)
272
+ output = `bundle exec ruby -S ceedling module:destroy[ponies]`
273
+ expect($?.exitstatus).to match(0)
274
+ expect(output).to match(/Destroy Complete/i)
275
+ end
276
+ end
277
+ end
278
+
279
+ def handles_creating_the_same_module_twice_using_the_module_plugin
280
+ @c.with_context do
281
+ Dir.chdir @proj_name do
282
+ output = `bundle exec ruby -S ceedling module:create[unicorns]`
283
+ expect($?.exitstatus).to match(0)
284
+ expect(output).to match(/Generate Complete/i)
285
+
286
+ output = `bundle exec ruby -S ceedling module:create[unicorns]`
287
+ expect($?.exitstatus).to match(1)
288
+ expect(output).to match(/ERROR: Ceedling Failed/)
242
289
  end
243
290
  end
244
291
  end
292
+
293
+ def handles_destroying_a_module_that_does_not_exist_using_the_module_plugin
294
+ @c.with_context do
295
+ Dir.chdir @proj_name do
296
+ output = `bundle exec ruby -S ceedling module:destroy[unknown]`
297
+ expect($?.exitstatus).to match(0)
298
+
299
+ expect(output).to match(/File src\/unknown\.c does not exist so cannot be removed\./)
300
+ expect(output).to match(/File src\/unknown\.h does not exist so cannot be removed\./)
301
+ expect(output).to match(/File test\/test_unknown\.c does not exist so cannot be removed\./)
302
+ expect(output).to match(/Destroy Complete/)
303
+ end
304
+ end
305
+ end
306
+
245
307
  end
File without changes
File without changes
@@ -0,0 +1,21 @@
1
+ ---
2
+ :source:
3
+ :path: some/place
4
+ :file: test_example.c
5
+ :successes: []
6
+ :failures:
7
+ - :test: test_one
8
+ :line: 257
9
+ :message: ''
10
+ - :test: test_two
11
+ :line: 269
12
+ :message: ''
13
+ :ignores: []
14
+ :counts:
15
+ :total: 2
16
+ :passed: 0
17
+ :failed: 2
18
+ :ignored: 0
19
+ :stdout:
20
+ - Verbose output one
21
+ - Verbous output two
@@ -0,0 +1,21 @@
1
+ ---
2
+ :source:
3
+ :path: some/place
4
+ :file: test_example.c
5
+ :successes:
6
+ - :test: test_one
7
+ :line: 257
8
+ :message: ''
9
+ - :test: test_two
10
+ :line: 269
11
+ :message: ''
12
+ :failures: []
13
+ :ignores: []
14
+ :counts:
15
+ :total: 2
16
+ :passed: 2
17
+ :failed: 0
18
+ :ignored: 0
19
+ :stdout:
20
+ - Verbose output one
21
+ - Verbous output two
@@ -0,0 +1,13 @@
1
+ ---
2
+ :source:
3
+ :path: some/place
4
+ :file: test_example.c
5
+ :successes: []
6
+ :failures: []
7
+ :ignores: []
8
+ :counts:
9
+ :total: 0
10
+ :passed: 0
11
+ :failed: 0
12
+ :ignored: 0
13
+ :stdout: []
@@ -0,0 +1,21 @@
1
+ ---
2
+ :source:
3
+ :path: some/place
4
+ :file: test_example.c
5
+ :successes: []
6
+ :failures: []
7
+ :ignores:
8
+ - :test: test_one
9
+ :line: 257
10
+ :message: ''
11
+ - :test: test_two
12
+ :line: 269
13
+ :message: ''
14
+ :counts:
15
+ :total: 2
16
+ :passed: 0
17
+ :failed: 0
18
+ :ignored: 2
19
+ :stdout:
20
+ - Verbose output one
21
+ - Verbous output two
@@ -0,0 +1,19 @@
1
+ ---
2
+ :source:
3
+ :path: some/place
4
+ :file: test_example.c
5
+ :successes:
6
+ - :test: test_one
7
+ :line: 257
8
+ :message: ''
9
+ -
10
+ :failures: []
11
+ :ignores: []
12
+ :counts:
13
+ :total: 2
14
+ :passed: 2
15
+ :failed: 0
16
+ :ignored: 0
17
+ :stdout:
18
+ - Verbose output one
19
+ - test_example.c:269:test_tVerbous output two
@@ -27,8 +27,12 @@ describe "Ceedling" do
27
27
  it { contains_documentation }
28
28
  it { can_fetch_non_project_help }
29
29
  it { can_fetch_project_help }
30
- it { can_test_projects }
30
+ it { can_test_projects_with_success }
31
+ it { can_test_projects_with_fail }
32
+ it { can_test_projects_with_compile_error }
31
33
  it { can_use_the_module_plugin }
34
+ it { handles_creating_the_same_module_twice_using_the_module_plugin }
35
+ it { handles_destroying_a_module_that_does_not_exist_using_the_module_plugin }
32
36
  end
33
37
 
34
38
  describe "deployed in a project's `vendor` directory without docs." do
@@ -43,8 +47,12 @@ describe "Ceedling" do
43
47
  it { does_not_contain_documentation }
44
48
  it { can_fetch_non_project_help }
45
49
  it { can_fetch_project_help }
46
- it { can_test_projects }
50
+ it { can_test_projects_with_success }
51
+ it { can_test_projects_with_fail }
52
+ it { can_test_projects_with_compile_error }
47
53
  it { can_use_the_module_plugin }
54
+ it { handles_creating_the_same_module_twice_using_the_module_plugin }
55
+ it { handles_destroying_a_module_that_does_not_exist_using_the_module_plugin }
48
56
  end
49
57
 
50
58
  describe "ugrade a project's `vendor` directory" do
@@ -59,15 +67,23 @@ describe "Ceedling" do
59
67
  it { does_not_contain_documentation }
60
68
  it { can_fetch_non_project_help }
61
69
  it { can_fetch_project_help }
62
- it { can_test_projects }
70
+ it { can_test_projects_with_success }
71
+ it { can_test_projects_with_fail }
72
+ it { can_test_projects_with_compile_error }
63
73
  it { can_use_the_module_plugin }
74
+ it { handles_creating_the_same_module_twice_using_the_module_plugin }
75
+ it { handles_destroying_a_module_that_does_not_exist_using_the_module_plugin }
64
76
 
65
77
  it { can_upgrade_projects }
66
78
  it { contains_a_vendor_directory }
67
79
  it { can_fetch_non_project_help }
68
80
  it { can_fetch_project_help }
69
- it { can_test_projects }
81
+ it { can_test_projects_with_success }
82
+ it { can_test_projects_with_fail }
83
+ it { can_test_projects_with_compile_error }
70
84
  it { can_use_the_module_plugin }
85
+ it { handles_creating_the_same_module_twice_using_the_module_plugin }
86
+ it { handles_destroying_a_module_that_does_not_exist_using_the_module_plugin }
71
87
  end
72
88
 
73
89
  describe "deployed as a gem" do
@@ -81,8 +97,12 @@ describe "Ceedling" do
81
97
  it { does_not_contain_a_vendor_directory }
82
98
  it { can_fetch_non_project_help }
83
99
  it { can_fetch_project_help }
84
- it { can_test_projects }
100
+ it { can_test_projects_with_success }
101
+ it { can_test_projects_with_fail }
102
+ it { can_test_projects_with_compile_error }
85
103
  it { can_use_the_module_plugin }
104
+ it { handles_creating_the_same_module_twice_using_the_module_plugin }
105
+ it { handles_destroying_a_module_that_does_not_exist_using_the_module_plugin }
86
106
  end
87
107
 
88
108
  describe "command: `ceedling examples`" do
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+ require 'ceedling/system_utils'
3
+
4
+
5
+ describe SystemUtils do
6
+ before(:each) do
7
+ # this will always be mocked
8
+ @sys_wrapper = nil
9
+ allow_message_expectations_on_nil
10
+
11
+ @sys_utils = described_class.new({:system_wrapper => @sys_wrapper})
12
+ @sys_utils.setup
13
+ end
14
+
15
+ describe '#setup' do
16
+ it 'sets tcsh_shell to nil' do
17
+ expect(@sys_utils.instance_variable_get(:@tcsh_shell)).to eq(nil)
18
+ end
19
+
20
+ it 'sets tcsh_shell to nil after being set' do
21
+ expect(@sys_utils.instance_variable_get(:@tcsh_shell)).to eq(nil)
22
+
23
+
24
+ allow(@streaminator).to receive(:shell_backticks).with('echo $version').and_return({:exit_code => 0, :output =>'tcsh 1234567890'})
25
+ @sys_utils.tcsh_shell?
26
+
27
+ @sys_utils.setup
28
+ expect(@sys_utils.instance_variable_get(:@tcsh_shell)).to eq(nil)
29
+ end
30
+ end
31
+
32
+
33
+ describe '#tcsh_shell?' do
34
+ it 'returns true if exit code is zero and output contains tcsh' do
35
+ allow(@streaminator).to receive(:shell_backticks).with('echo $version').and_return({:exit_code => 0, :output =>'tcsh 1234567890'})
36
+ expect(@sys_utils.tcsh_shell?).to eq(true)
37
+ end
38
+
39
+ it 'returns false if exit code is not 0' do
40
+ allow(@streaminator).to receive(:shell_backticks).with('echo $version').and_return({:exit_code => 1, :output =>'tcsh 1234567890'})
41
+ expect(@sys_utils.tcsh_shell?).to eq(false)
42
+ end
43
+
44
+ it 'returns false if output does not contain tcsh' do
45
+ allow(@streaminator).to receive(:shell_backticks).with('echo $version').and_return({:exit_code => 0, :output =>'???'})
46
+ expect(@sys_utils.tcsh_shell?).to eq(false)
47
+ end
48
+
49
+ it 'returns last value if already run' do
50
+ allow(@streaminator).to receive(:shell_backticks).with('echo $version').and_return({:exit_code => 1, :output =>'???'})
51
+ expect(@sys_utils.tcsh_shell?).to eq(false)
52
+ allow(@streaminator).to receive(:shell_backticks).with('echo $version').and_return({:exit_code => 0, :output =>'tcsh 1234567890'})
53
+ expect(@sys_utils.tcsh_shell?).to eq(false)
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'ceedling/target_loader'
3
+
4
+
5
+ describe TargetLoader do
6
+ describe '.inspect' do
7
+
8
+ it 'raises NoTargets if targets does not exist' do
9
+ expect{TargetLoader.inspect({})}.to raise_error(TargetLoader::NoTargets)
10
+ end
11
+
12
+ it 'raises NoDirectory if targets_directory inside of targets does not exist' do
13
+ expect{TargetLoader.inspect({:targets => {}})}.to raise_error(TargetLoader::NoDirectory)
14
+ end
15
+
16
+ it 'raises NoDefault if default_target inside of targets does not exist' do
17
+ expect{TargetLoader.inspect({:targets => {:targets_directory => File.join('spec', 'support')}})}.to raise_error(TargetLoader::NoDefault)
18
+ end
19
+
20
+ it 'raises NoSuchTarget if file does not exist' do
21
+ expect{TargetLoader.inspect({:targets => {:targets_directory => File.join('spec', 'other'), :default_target => 'target'}})}.to raise_error(TargetLoader::NoSuchTarget)
22
+ end
23
+
24
+ it 'raises RequestReload if file exists' do
25
+ expect{TargetLoader.inspect({:targets => {:targets_directory => File.join('spec', 'support'), :default_target => 'target'}})}.to raise_error(TargetLoader::RequestReload)
26
+ expect{TargetLoader.inspect({:targets => {:targets_directory => File.join('spec', 'support'), :default_target => 'target'}}, 'other_target')}.to raise_error(TargetLoader::RequestReload)
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,310 @@
1
+ require 'spec_helper'
2
+ require 'ceedling/constants'
3
+ require 'ceedling/tool_executor_helper'
4
+ require 'ceedling/system_wrapper'
5
+ require 'ceedling/streaminator'
6
+ require 'ceedling/system_utils'
7
+
8
+ HAPPY_OUTPUT =
9
+ "> Shell executed command:\n" +
10
+ "'gcc ab.c'\n" +
11
+ "\n".freeze
12
+
13
+ HAPPY_OUTPUT_WITH_STATUS =
14
+ "> Shell executed command:\n" +
15
+ "'gcc ab.c'\n" +
16
+ "> And exited with status: [1].\n" +
17
+ "\n".freeze
18
+
19
+ HAPPY_OUTPUT_WITH_MESSAGE =
20
+ "> Shell executed command:\n" +
21
+ "'gcc ab.c'\n" +
22
+ "> Produced output:\n" +
23
+ "xyz\n" +
24
+ "\n".freeze
25
+
26
+ HAPPY_OUTPUT_WITH_MESSAGE_AND_STATUS =
27
+ "> Shell executed command:\n" +
28
+ "'gcc ab.c'\n" +
29
+ "> Produced output:\n" +
30
+ "xyz\n" +
31
+ "> And exited with status: [1].\n" +
32
+ "\n".freeze
33
+
34
+ ERROR_OUTPUT =
35
+ "ERROR: Shell command failed.\n" +
36
+ "> Shell executed command:\n" +
37
+ "'gcc ab.c'\n" +
38
+ "> And exited with status: [1].\n" +
39
+ "\n"
40
+
41
+ ERROR_OUTPUT_WITH_MESSAGE =
42
+ "ERROR: Shell command failed.\n" +
43
+ "> Shell executed command:\n" +
44
+ "'gcc ab.c'\n" +
45
+ "> Produced output:\n" +
46
+ "xyz\n" +
47
+ "> And exited with status: [1].\n" +
48
+ "\n"
49
+
50
+
51
+ describe ToolExecutorHelper do
52
+ before(:each) do
53
+ # these will always be mocked
54
+ @sys_wraper = SystemWrapper.new
55
+ @sys_utils = SystemUtils.new({:system_wrapper => @sys_wraper})
56
+ @streaminator = Streaminator.new({:streaminator_helper => nil, :verbosinator => nil, :loginator => nil, :stream_wrapper => @sys_wraper})
57
+
58
+
59
+ @tool_exe_helper = described_class.new({:streaminator => @streaminator, :system_utils => @sys_utils, :system_wrapper => @sys_wraper})
60
+ end
61
+
62
+
63
+ describe '#stderr_redirection' do
64
+ it 'returns stderr_redirect if logging is false' do
65
+ expect(@tool_exe_helper.stderr_redirection({:stderr_redirect => StdErrRedirect::NONE}, false)).to eq(StdErrRedirect::NONE)
66
+ end
67
+
68
+ it 'returns stderr_redirect if logging is true and is a string' do
69
+ expect(@tool_exe_helper.stderr_redirection({:stderr_redirect => 'abc'}, true)).to eq('abc')
70
+ end
71
+
72
+ it 'returns AUTO if logging is true and stderr_redirect is not a string' do
73
+ expect(@tool_exe_helper.stderr_redirection({:stderr_redirect => StdErrRedirect::NONE}, true)).to eq(StdErrRedirect::AUTO)
74
+ end
75
+ end
76
+
77
+
78
+ describe '#background_exec_cmdline_prepend' do
79
+ it 'returns nil if tool_config is nil' do
80
+ expect(@tool_exe_helper.background_exec_cmdline_prepend(nil)).to be_nil
81
+ end
82
+
83
+ it 'returns nil if tool_config[:background_exec] is nil' do
84
+ expect(@tool_exe_helper.background_exec_cmdline_prepend({:background_exec =>nil})).to be_nil
85
+ end
86
+
87
+ it 'returns "start" if tool_config[:background_exec] is AUTO on windows' do
88
+ expect(@sys_wraper).to receive(:windows?).and_return(true)
89
+ expect(@tool_exe_helper.background_exec_cmdline_prepend({:background_exec =>BackgroundExec::AUTO})).to eq('start')
90
+ end
91
+
92
+ it 'returns nil if tool_config[:background_exec] is AUTO not on windows' do
93
+ expect(@sys_wraper).to receive(:windows?).and_return(false)
94
+ expect(@tool_exe_helper.background_exec_cmdline_prepend({:background_exec =>BackgroundExec::AUTO})).to be_nil
95
+ end
96
+
97
+ it 'returns "start" if tool_config[:background_exec] is WIN' do
98
+ expect(@tool_exe_helper.background_exec_cmdline_prepend({:background_exec =>BackgroundExec::WIN})).to eq('start')
99
+ end
100
+ end
101
+
102
+
103
+ describe '#osify_path_separators' do
104
+ it 'returns path if system is not windows' do
105
+ exe = '/just/some/executable.out'
106
+ expect(@sys_wraper).to receive(:windows?).and_return(false)
107
+ expect(@tool_exe_helper.osify_path_separators(exe)).to eq(exe)
108
+ end
109
+
110
+ it 'returns modifed if system is windows' do
111
+ exe = '/just/some/executable.exe'
112
+ expect(@sys_wraper).to receive(:windows?).and_return(true)
113
+ expect(@tool_exe_helper.osify_path_separators(exe)).to eq("\\just\\some\\executable.exe")
114
+ end
115
+ end
116
+
117
+
118
+ describe '#stderr_redirect_cmdline_append' do
119
+ it 'returns nil if tool_config is nil' do
120
+ expect(@tool_exe_helper.stderr_redirect_cmdline_append(nil)).to be_nil
121
+ end
122
+
123
+ it 'returns nil if tool_config[:stderr_redirect] is nil' do
124
+ tool_config = {:stderr_redirect => nil}
125
+ expect(@tool_exe_helper.stderr_redirect_cmdline_append(tool_config)).to be_nil
126
+ end
127
+
128
+ it 'returns nil if tool_config is set to none' do
129
+ tool_config = {:stderr_redirect => StdErrRedirect::NONE}
130
+ expect(@tool_exe_helper.stderr_redirect_cmdline_append(tool_config)).to be_nil
131
+ end
132
+
133
+ context 'StdErrRedirect::AUTO' do
134
+ before(:each) do
135
+ @tool_config = {:stderr_redirect => StdErrRedirect::AUTO}
136
+ end
137
+
138
+
139
+ it 'returns "2>&1" if system is windows' do
140
+ expect(@sys_wraper).to receive(:windows?).and_return(true)
141
+ expect(@tool_exe_helper.stderr_redirect_cmdline_append(@tool_config)).to eq('2>&1')
142
+ end
143
+
144
+ it 'returns "|&" if system is tcsh' do
145
+ expect(@sys_wraper).to receive(:windows?).and_return(false)
146
+ expect(@sys_utils).to receive(:tcsh_shell?).and_return(true)
147
+ expect(@tool_exe_helper.stderr_redirect_cmdline_append(@tool_config)).to eq('|&')
148
+ end
149
+
150
+ it 'returns "2>&1" if system is unix' do
151
+ expect(@sys_wraper).to receive(:windows?).and_return(false)
152
+ expect(@sys_utils).to receive(:tcsh_shell?).and_return(false)
153
+ expect(@tool_exe_helper.stderr_redirect_cmdline_append(@tool_config)).to eq('2>&1')
154
+ end
155
+ end
156
+ end
157
+
158
+
159
+ describe '#background_exec_cmdline_append' do
160
+ it 'returns nil if tool_config is nil' do
161
+ expect(@tool_exe_helper.background_exec_cmdline_append(nil)).to be_nil
162
+ end
163
+
164
+ it 'returns nil if tool_config[:background_exec] is nil' do
165
+ tool_config = {:background_exec => nil}
166
+ expect(@tool_exe_helper.background_exec_cmdline_append(tool_config)).to be_nil
167
+ end
168
+
169
+ it 'returns nil if tool_config is set to none' do
170
+ tool_config = {:background_exec => BackgroundExec::NONE}
171
+ expect(@tool_exe_helper.background_exec_cmdline_append(tool_config)).to be_nil
172
+ end
173
+
174
+ it 'returns nil if tool_config is set to none' do
175
+ tool_config = {:background_exec => BackgroundExec::WIN}
176
+ expect(@tool_exe_helper.background_exec_cmdline_append(tool_config)).to be_nil
177
+ end
178
+
179
+ it 'returns "&" if tool_config is set to UNIX' do
180
+ tool_config = {:background_exec => BackgroundExec::UNIX}
181
+ expect(@tool_exe_helper.background_exec_cmdline_append(tool_config)).to eq('&')
182
+ end
183
+
184
+ context 'when tool_config[:background_exec] BackgroundExec:AUTO' do
185
+ before(:each) do
186
+ @tool_config = {:background_exec => BackgroundExec::AUTO}
187
+ end
188
+
189
+
190
+ it 'returns nil if system is windows' do
191
+ expect(@sys_wraper).to receive(:windows?).and_return(true)
192
+ expect(@tool_exe_helper.background_exec_cmdline_append(@tool_config)).to be_nil
193
+ end
194
+
195
+ it 'returns "&" if system is not windows' do
196
+ expect(@sys_wraper).to receive(:windows?).and_return(false)
197
+ expect(@sys_wraper).to receive(:windows?).and_return(false)
198
+ expect(@tool_exe_helper.background_exec_cmdline_append(@tool_config)).to eq('&')
199
+ end
200
+ end
201
+ end
202
+
203
+ describe '#print_happy_results' do
204
+ context 'when exit code is 0' do
205
+ before(:each) do
206
+ @shell_result = {:exit_code => 0, :output => ""}
207
+ end
208
+
209
+ it 'and boom is true displays output' do
210
+ expect(@streaminator).to receive(:stdout_puts).with(HAPPY_OUTPUT, Verbosity::OBNOXIOUS)
211
+ @tool_exe_helper.print_happy_results("gcc ab.c", @shell_result, true)
212
+ end
213
+
214
+ it 'and boom is true with message displays output' do
215
+ @shell_result[:output] = "xyz"
216
+ expect(@streaminator).to receive(:stdout_puts).with(HAPPY_OUTPUT_WITH_MESSAGE, Verbosity::OBNOXIOUS)
217
+ @tool_exe_helper.print_happy_results("gcc ab.c", @shell_result, true)
218
+ end
219
+
220
+ it 'and boom is false displays output' do
221
+ expect(@streaminator).to receive(:stdout_puts).with(HAPPY_OUTPUT, Verbosity::OBNOXIOUS)
222
+ @tool_exe_helper.print_happy_results("gcc ab.c", @shell_result, false)
223
+ end
224
+
225
+ it 'and boom is false with message displays output' do
226
+ @shell_result[:output] = "xyz"
227
+ expect(@streaminator).to receive(:stdout_puts).with(HAPPY_OUTPUT_WITH_MESSAGE, Verbosity::OBNOXIOUS)
228
+ @tool_exe_helper.print_happy_results("gcc ab.c", @shell_result, false)
229
+ end
230
+ end
231
+
232
+ context 'when exit code is not 0' do
233
+ before(:each) do
234
+ @shell_result = {:exit_code => 1, :output => ""}
235
+ end
236
+
237
+ it 'and boom is true does not displays output' do
238
+ @tool_exe_helper.print_happy_results("gcc ab.c", @shell_result, true)
239
+ end
240
+
241
+ it 'and boom is true with message does not displays output' do
242
+ @shell_result[:output] = "xyz"
243
+ @tool_exe_helper.print_happy_results("gcc ab.c", @shell_result, true)
244
+ end
245
+
246
+ it 'and boom is false displays output' do
247
+ expect(@streaminator).to receive(:stdout_puts).with(HAPPY_OUTPUT_WITH_STATUS, Verbosity::OBNOXIOUS)
248
+ @tool_exe_helper.print_happy_results("gcc ab.c", @shell_result, false)
249
+ end
250
+
251
+ it 'and boom is false with message displays output' do
252
+ @shell_result[:output] = "xyz"
253
+ expect(@streaminator).to receive(:stdout_puts).with(HAPPY_OUTPUT_WITH_MESSAGE_AND_STATUS, Verbosity::OBNOXIOUS)
254
+ @tool_exe_helper.print_happy_results("gcc ab.c", @shell_result, false)
255
+ end
256
+ end
257
+ end
258
+
259
+ describe '#print_error_results' do
260
+ context 'when exit code is 0' do
261
+ before(:each) do
262
+ @shell_result = {:exit_code => 0, :output => ""}
263
+ end
264
+
265
+ it 'and boom is true does not display output' do
266
+ @tool_exe_helper.print_error_results("gcc ab.c", @shell_result, true)
267
+ end
268
+
269
+ it 'and boom is true with message does not display output' do
270
+ @shell_result[:output] = "xyz"
271
+ @tool_exe_helper.print_error_results("gcc ab.c", @shell_result, true)
272
+ end
273
+
274
+ it 'and boom is false does not display output' do
275
+ @tool_exe_helper.print_error_results("gcc ab.c", @shell_result, false)
276
+ end
277
+
278
+ it 'and boom is false with message does not display output' do
279
+ @shell_result[:output] = "xyz"
280
+ @tool_exe_helper.print_error_results("gcc ab.c", @shell_result, false)
281
+ end
282
+ end
283
+
284
+ context 'when exit code is non 0' do
285
+ before(:each) do
286
+ @shell_result = {:exit_code => 1, :output => ""}
287
+ end
288
+
289
+ it 'and boom is true displays output' do
290
+ expect(@streaminator).to receive(:stderr_puts).with(ERROR_OUTPUT, Verbosity::ERRORS)
291
+ @tool_exe_helper.print_error_results("gcc ab.c", @shell_result, true)
292
+ end
293
+
294
+ it 'and boom is true with message displays output' do
295
+ @shell_result[:output] = "xyz"
296
+ expect(@streaminator).to receive(:stderr_puts).with(ERROR_OUTPUT_WITH_MESSAGE, Verbosity::ERRORS)
297
+ @tool_exe_helper.print_error_results("gcc ab.c", @shell_result, true)
298
+ end
299
+
300
+ it 'and boom is false dose not display output' do
301
+ @tool_exe_helper.print_error_results("gcc ab.c", @shell_result, false)
302
+ end
303
+
304
+ it 'and boom is false with message does not display output' do
305
+ @shell_result[:output] = "xyz"
306
+ @tool_exe_helper.print_error_results("gcc ab.c", @shell_result, false)
307
+ end
308
+ end
309
+ end
310
+ end