ceedling 0.27.0 → 0.28.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/project_as_gem.yml +6 -0
- data/assets/project_with_guts.yml +6 -0
- data/assets/project_with_guts_gcov.yml +88 -0
- data/assets/test_example_file_boom.c +13 -0
- data/assets/test_example_file_success.c +14 -0
- data/bin/ceedling +57 -113
- data/ceedling.gemspec +1 -1
- data/config/test_environment.rb +0 -1
- data/examples/blinky/project.yml +1 -1
- data/examples/temp_sensor/project.yml +7 -1
- data/examples/temp_sensor/rakefile.rb +3 -1
- data/lib/ceedling/build_invoker_utils.rb +14 -2
- data/lib/ceedling/configurator.rb +3 -1
- data/lib/ceedling/configurator_builder.rb +6 -4
- data/lib/ceedling/configurator_setup.rb +5 -1
- data/lib/ceedling/defaults.rb +5 -2
- data/lib/ceedling/dependinator.rb +1 -1
- data/lib/ceedling/file_path_utils.rb +1 -2
- data/lib/ceedling/generator_test_results.rb +3 -2
- data/lib/ceedling/generator_test_results_sanity_checker.rb +4 -3
- data/lib/ceedling/project_file_loader.rb +26 -9
- data/lib/ceedling/rakefile.rb +9 -2
- data/lib/ceedling/release_invoker.rb +1 -1
- data/lib/ceedling/reportinator.rb +18 -1
- data/lib/ceedling/system_utils.rb +6 -1
- data/lib/ceedling/system_wrapper.rb +2 -1
- data/lib/ceedling/target_loader.rb +2 -2
- data/lib/ceedling/tasks_filesystem.rake +8 -2
- data/lib/ceedling/tool_executor_helper.rb +71 -22
- data/lib/ceedling/version.rb +1 -1
- data/license.txt +1 -1
- data/out.fail +21 -0
- data/plugins/command_hooks/lib/command_hooks.rb +2 -1
- data/plugins/gcov/config/defaults.yml +22 -0
- data/plugins/gcov/gcov.rake +79 -65
- data/plugins/gcov/lib/gcov.rb +25 -38
- data/plugins/gcov/lib/gcov_constants.rb +16 -0
- data/spec/build_invoker_utils_spec.rb +54 -0
- data/spec/file_finder_helper_spec.rb +53 -0
- data/spec/gcov/gcov_deployment_spec.rb +70 -0
- data/spec/gcov/gcov_test_cases_spec.rb +91 -0
- data/spec/generator_test_results_sanity_checker_spec.rb +88 -0
- data/spec/generator_test_results_spec.rb +102 -0
- data/spec/reportinator_spec.rb +19 -0
- data/spec/spec_system_helper.rb +67 -5
- data/spec/support/other_target.yml +0 -0
- data/spec/support/target.yml +0 -0
- data/spec/support/test_example.fail +21 -0
- data/spec/support/test_example.pass +21 -0
- data/spec/support/test_example_empty.pass +13 -0
- data/spec/support/test_example_ignore.pass +21 -0
- data/spec/support/test_example_mangled.pass +19 -0
- data/spec/system/deployment_spec.rb +25 -5
- data/spec/system_utils_spec.rb +56 -0
- data/spec/target_loader_spec.rb +30 -0
- data/spec/tool_executor_helper_spec.rb +310 -0
- data/vendor/cmock/scripts/create_makefile.rb +35 -12
- data/vendor/unity/src/unity_internals.h +3 -3
- metadata +62 -27
- data/assets/rakefile_as_gem.rb +0 -3
- data/assets/rakefile_with_guts.rb +0 -6
- data/vendor/constructor/History.rdoc +0 -19
- data/vendor/constructor/README.rdoc +0 -72
- data/vendor/constructor/Rakefile +0 -33
- data/vendor/constructor/homepage/Notes.txt +0 -27
- data/vendor/constructor/homepage/Rakefile +0 -15
- data/vendor/constructor/homepage/index.erb +0 -27
- data/vendor/constructor/homepage/index.html +0 -36
- data/vendor/constructor/homepage/page_header.graffle +0 -0
- data/vendor/constructor/homepage/page_header.html +0 -9
- data/vendor/constructor/homepage/page_header.png +0 -0
- data/vendor/constructor/homepage/sample_code.png +0 -0
- data/vendor/constructor/homepage/sample_code.rb +0 -12
- data/vendor/constructor/lib/constructor.rb +0 -127
- data/vendor/constructor/lib/constructor_struct.rb +0 -33
- data/vendor/constructor/specs/constructor_spec.rb +0 -407
- data/vendor/constructor/specs/constructor_struct_spec.rb +0 -84
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
GCOV_ROOT_NAME = 'gcov'.freeze
|
3
|
+
GCOV_TASK_ROOT = GCOV_ROOT_NAME + ':'
|
4
|
+
GCOV_SYM = GCOV_ROOT_NAME.to_sym
|
5
|
+
|
6
|
+
GCOV_BUILD_PATH = File.join(PROJECT_BUILD_ROOT, GCOV_ROOT_NAME)
|
7
|
+
GCOV_BUILD_OUTPUT_PATH = File.join(GCOV_BUILD_PATH, "out")
|
8
|
+
GCOV_RESULTS_PATH = File.join(GCOV_BUILD_PATH, "results")
|
9
|
+
GCOV_DEPENDENCIES_PATH = File.join(GCOV_BUILD_PATH, "dependencies")
|
10
|
+
GCOV_ARTIFACTS_PATH = File.join(PROJECT_BUILD_ARTIFACTS_ROOT, GCOV_ROOT_NAME)
|
11
|
+
|
12
|
+
GCOV_ARTIFACTS_FILE = File.join(GCOV_ARTIFACTS_PATH, "GcovCoverageResults.html")
|
13
|
+
|
14
|
+
GCOV_IGNORE_SOURCES = %w(unity cmock cexception).freeze
|
15
|
+
|
16
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ceedling/build_invoker_utils'
|
3
|
+
require 'ceedling/constants'
|
4
|
+
require 'ceedling/streaminator'
|
5
|
+
require 'ceedling/configurator'
|
6
|
+
|
7
|
+
describe BuildInvokerUtils do
|
8
|
+
before(:each) do
|
9
|
+
# this will always be mocked
|
10
|
+
@configurator = Configurator.new({:configurator_setup => nil, :configurator_builder => nil,
|
11
|
+
:configurator_plugins => nil, :cmock_builder => nil,
|
12
|
+
:yaml_wrapper => nil, :system_wrapper => nil})
|
13
|
+
@streaminator = Streaminator.new({:streaminator_helper => nil, :verbosinator => nil,
|
14
|
+
:loginator => nil, :stream_wrapper => nil})
|
15
|
+
|
16
|
+
# this is what is being tested
|
17
|
+
@bi_utils = described_class.new({:configurator => @configurator, :streaminator => @streaminator})
|
18
|
+
|
19
|
+
# these keep the actual test cleaner
|
20
|
+
@exception_msg = 'Don\'t know how to build task \'xyz\''
|
21
|
+
@basic_msg = "ERROR: Rake could not find file referenced in source or test: 'xyz'. Possible stale dependency."
|
22
|
+
@deep_dep_msg = "Try fixing #include statements or adding missing file. Then run '#{REFRESH_TASK_ROOT}#{TEST_SYM.to_s}' task and try again."
|
23
|
+
@exception = RuntimeError.new(@exception_msg)
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#process_exception' do
|
27
|
+
|
28
|
+
it 'passes given error if message does not contain handled messagr' do
|
29
|
+
expect{@bi_utils.process_exception(ArgumentError.new('oops...'), TEST_SYM)}.to raise_error(ArgumentError)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'prints to stderr for test with test_build flag set true' do
|
33
|
+
allow(@streaminator).to receive(:stderr_puts).with(@basic_msg)
|
34
|
+
allow(@configurator).to receive(:project_use_deep_dependencies).and_return(false)
|
35
|
+
expect{@bi_utils.process_exception(@exception, TEST_SYM, true)}.to raise_error(RuntimeError)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'prints to stderr for test with test_build flag set false' do
|
39
|
+
allow(@streaminator).to receive(:stderr_puts).with(@basic_msg.sub(' or test', ''))
|
40
|
+
allow(@configurator).to receive(:project_use_deep_dependencies).and_return(false)
|
41
|
+
expect{@bi_utils.process_exception(@exception, TEST_SYM, false)}.to raise_error(RuntimeError)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'prints to stderr with extra message when deep dependencies is true' do
|
45
|
+
allow(@streaminator).to receive(:stderr_puts).with(@basic_msg.sub(' or test', ''))
|
46
|
+
allow(@configurator).to receive(:project_use_deep_dependencies).and_return(true)
|
47
|
+
allow(@streaminator).to receive(:stderr_puts).with(@deep_dep_msg)
|
48
|
+
|
49
|
+
expect{@bi_utils.process_exception(@exception, TEST_SYM, false)}.to raise_error(RuntimeError)
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ceedling/file_finder_helper'
|
3
|
+
require 'ceedling/constants'
|
4
|
+
require 'ceedling/streaminator'
|
5
|
+
|
6
|
+
FILE_LIST = ['some/dir/a.c', 'some/dir/a.h', \
|
7
|
+
'another/place/b.c','another/place/b.h',\
|
8
|
+
'here/c.cpp', 'here/c.hpp',\
|
9
|
+
'copy/c.cpp', 'copy/c.hpp'].freeze
|
10
|
+
|
11
|
+
describe FileFinderHelper do
|
12
|
+
before(:each) do
|
13
|
+
# this will always be mocked
|
14
|
+
@streaminator = Streaminator.new({:streaminator_helper => nil, :verbosinator => nil, :loginator => nil, :stream_wrapper => nil})
|
15
|
+
|
16
|
+
@ff_helper = described_class.new({:streaminator => @streaminator})
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
describe '#find_file_in_collection' do
|
21
|
+
it 'returns the full path of the matching file' do
|
22
|
+
expect(@ff_helper.find_file_in_collection('a.c', FILE_LIST, :ignore)).to eq(FILE_LIST[0])
|
23
|
+
expect(@ff_helper.find_file_in_collection('b.h', FILE_LIST, :ignore)).to eq(FILE_LIST[3])
|
24
|
+
end
|
25
|
+
|
26
|
+
xit 'handles duplicate files' do
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'file not found' do
|
30
|
+
it 'returns nil' do
|
31
|
+
expect(@ff_helper.find_file_in_collection('unknown/d.c', FILE_LIST, :ignore)).to be_nil
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'outputs nothing if complain is ignore' do
|
35
|
+
@ff_helper.find_file_in_collection('unknown/d.c', FILE_LIST, :ignore)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'outputs a complaint if complain is warn' do
|
39
|
+
msg = 'WARNING: Found no file \'d.c\' in search paths.'
|
40
|
+
expect(@streaminator).to receive(:stderr_puts).with(msg, Verbosity::COMPLAIN)
|
41
|
+
@ff_helper.find_file_in_collection('d.c', FILE_LIST, :warn)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'outputs and raises an error if complain is error' do
|
45
|
+
msg = 'ERROR: Found no file \'d.c\' in search paths.'
|
46
|
+
allow(@streaminator).to receive(:stderr_puts).with(msg, Verbosity::ERRORS) do
|
47
|
+
expect{@ff_helper.find_file_in_collection('d.c', FILE_LIST, :warn)}.to raise_error
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_system_helper'
|
2
|
+
require 'gcov/gcov_test_cases_spec'
|
3
|
+
|
4
|
+
describe "Ceedling" do
|
5
|
+
describe "Gcov" do
|
6
|
+
include CeedlingTestCases
|
7
|
+
include GcovTestCases
|
8
|
+
before :all do
|
9
|
+
@c = SystemContext.new
|
10
|
+
@c.deploy_gem
|
11
|
+
end
|
12
|
+
|
13
|
+
after :all do
|
14
|
+
@c.done!
|
15
|
+
end
|
16
|
+
|
17
|
+
before { @proj_name = "fake_project" }
|
18
|
+
after { @c.with_context { FileUtils.rm_rf @proj_name } }
|
19
|
+
|
20
|
+
describe "basic operations" do
|
21
|
+
before do
|
22
|
+
@c.with_context do
|
23
|
+
`bundle exec ruby -S ceedling new #{@proj_name} 2>&1`
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it { can_test_projects_with_gcov_with_success }
|
28
|
+
it { can_test_projects_with_gcov_with_fail }
|
29
|
+
it { can_test_projects_with_gcov_with_compile_error }
|
30
|
+
it { can_fetch_project_help_for_gcov }
|
31
|
+
it { can_create_html_report }
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
describe "command: `ceedling example [example]`" do
|
36
|
+
describe "temp_sensor" do
|
37
|
+
before do
|
38
|
+
@c.with_context do
|
39
|
+
output = `bundle exec ruby -S ceedling example temp_sensor 2>&1`
|
40
|
+
expect(output).to match(/created!/)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should be testable" do
|
45
|
+
@c.with_context do
|
46
|
+
Dir.chdir "temp_sensor" do
|
47
|
+
@output = `bundle exec ruby -S ceedling gcov:all`
|
48
|
+
expect(@output).to match(/TESTED:\s+47/)
|
49
|
+
expect(@output).to match(/PASSED:\s+47/)
|
50
|
+
|
51
|
+
expect(@output).to match(/AdcConductor\.c Lines executed:/i)
|
52
|
+
expect(@output).to match(/AdcHardware\.c Lines executed:/i)
|
53
|
+
expect(@output).to match(/AdcModel\.c Lines executed:/i)
|
54
|
+
expect(@output).to match(/Executor\.c Lines executed:/i)
|
55
|
+
expect(@output).to match(/Main\.c Lines executed:/i)
|
56
|
+
expect(@output).to match(/Model\.c Lines executed:/i)
|
57
|
+
# there are more, but this is a good place to stop.
|
58
|
+
|
59
|
+
@output = `bundle exec ruby -S ceedling utils:gcov`
|
60
|
+
expect(@output).to match(/For now, just creating basic\./)
|
61
|
+
expect(@output).to match(/Creating a basic html report of gcov results in build\/artifacts\/gcov\/GcovCoverageResults\.html\.\.\./)
|
62
|
+
expect(File.exists?('build/artifacts/gcov/GcovCoverageResults.html')).to eq true
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'yaml'
|
4
|
+
require 'spec_system_helper'
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
|
8
|
+
module GcovTestCases
|
9
|
+
|
10
|
+
def can_test_projects_with_gcov_with_success
|
11
|
+
@c.with_context do
|
12
|
+
Dir.chdir @proj_name do
|
13
|
+
FileUtils.cp test_asset_path("project_with_guts_gcov.yml"), "project.yml"
|
14
|
+
FileUtils.cp test_asset_path("example_file.h"), 'src/'
|
15
|
+
FileUtils.cp test_asset_path("example_file.c"), 'src/'
|
16
|
+
FileUtils.cp test_asset_path("test_example_file_success.c"), 'test/'
|
17
|
+
|
18
|
+
output = `bundle exec ruby -S ceedling gcov:all`
|
19
|
+
expect($?.exitstatus).to match(0) # Since a test either pass or are ignored, we return success here
|
20
|
+
expect(output).to match(/TESTED:\s+\d/)
|
21
|
+
expect(output).to match(/PASSED:\s+\d/)
|
22
|
+
expect(output).to match(/FAILED:\s+\d/)
|
23
|
+
expect(output).to match(/IGNORED:\s+\d/)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def can_test_projects_with_gcov_with_fail
|
29
|
+
@c.with_context do
|
30
|
+
Dir.chdir @proj_name do
|
31
|
+
FileUtils.cp test_asset_path("project_with_guts_gcov.yml"), "project.yml"
|
32
|
+
FileUtils.cp test_asset_path("example_file.h"), 'src/'
|
33
|
+
FileUtils.cp test_asset_path("example_file.c"), 'src/'
|
34
|
+
FileUtils.cp test_asset_path("test_example_file.c"), 'test/'
|
35
|
+
|
36
|
+
output = `bundle exec ruby -S ceedling gcov:all`
|
37
|
+
expect($?.exitstatus).to match(1) # Since a test fails, we return error here
|
38
|
+
expect(output).to match(/TESTED:\s+\d/)
|
39
|
+
expect(output).to match(/PASSED:\s+\d/)
|
40
|
+
expect(output).to match(/FAILED:\s+\d/)
|
41
|
+
expect(output).to match(/IGNORED:\s+\d/)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def can_test_projects_with_gcov_with_compile_error
|
47
|
+
@c.with_context do
|
48
|
+
Dir.chdir @proj_name do
|
49
|
+
FileUtils.cp test_asset_path("project_with_guts_gcov.yml"), "project.yml"
|
50
|
+
FileUtils.cp test_asset_path("example_file.h"), 'src/'
|
51
|
+
FileUtils.cp test_asset_path("example_file.c"), 'src/'
|
52
|
+
FileUtils.cp test_asset_path("test_example_file_boom.c"), 'test/'
|
53
|
+
|
54
|
+
output = `bundle exec ruby -S ceedling test:all`
|
55
|
+
expect($?.exitstatus).to match(1) # Since a test explodes, we return error here
|
56
|
+
expect(output).to match(/ERROR: Ceedling Failed/)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def can_fetch_project_help_for_gcov
|
62
|
+
@c.with_context do
|
63
|
+
Dir.chdir @proj_name do
|
64
|
+
FileUtils.cp test_asset_path("project_with_guts_gcov.yml"), "project.yml"
|
65
|
+
output = `bundle exec ruby -S ceedling help`
|
66
|
+
expect($?.exitstatus).to match(0)
|
67
|
+
expect(output).to match(/ceedling gcov:\*/i)
|
68
|
+
expect(output).to match(/ceedling gcov:all/i)
|
69
|
+
expect(output).to match(/ceedling gcov:delta/i)
|
70
|
+
expect(output).to match(/ceedling utils:gcov/i)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def can_create_html_report
|
76
|
+
@c.with_context do
|
77
|
+
Dir.chdir @proj_name do
|
78
|
+
FileUtils.cp test_asset_path("project_with_guts_gcov.yml"), "project.yml"
|
79
|
+
FileUtils.cp test_asset_path("example_file.h"), 'src/'
|
80
|
+
FileUtils.cp test_asset_path("example_file.c"), 'src/'
|
81
|
+
FileUtils.cp test_asset_path("test_example_file_success.c"), 'test/'
|
82
|
+
|
83
|
+
output = `bundle exec ruby -S ceedling gcov:all`
|
84
|
+
output = `bundle exec ruby -S ceedling utils:gcov`
|
85
|
+
expect(output).to match(/Creating a basic html report of gcov results in build\/artifacts\/gcov\/GcovCoverageResults\.html\.\.\./)
|
86
|
+
expect(File.exists?('build/artifacts/gcov/GcovCoverageResults.html')).to eq true
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ceedling/generator_test_results_sanity_checker'
|
3
|
+
require 'ceedling/constants'
|
4
|
+
require 'ceedling/streaminator'
|
5
|
+
require 'ceedling/configurator'
|
6
|
+
|
7
|
+
describe GeneratorTestResultsSanityChecker do
|
8
|
+
before(:each) do
|
9
|
+
# this will always be mocked
|
10
|
+
@configurator = Configurator.new({:configurator_setup => nil, :configurator_builder => nil, :configurator_plugins => nil, :cmock_builder => nil, :yaml_wrapper => nil, :system_wrapper => nil})
|
11
|
+
@streaminator = Streaminator.new({:streaminator_helper => nil, :verbosinator => nil, :loginator => nil, :stream_wrapper => nil})
|
12
|
+
|
13
|
+
@sanity_checker = described_class.new({:configurator => @configurator, :streaminator => @streaminator})
|
14
|
+
|
15
|
+
@results = {}
|
16
|
+
@results[:ignores] = ['', '', '']
|
17
|
+
@results[:failures] = ['', '', '']
|
18
|
+
@results[:successes] = ['', '', '']
|
19
|
+
@results[:source] = {:file => "test_file.c"}
|
20
|
+
@results[:counts] = {:ignored => @results[:ignores].size, :failed => @results[:failures].size, :total => 9}
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
describe '#verify' do
|
25
|
+
it 'returns immediately if sanity_checker set to NONE' do
|
26
|
+
@configurator.sanity_checks = TestResultsSanityChecks::NONE
|
27
|
+
expect(@sanity_checker.verify(nil, 255)).to be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'rasies error if results are nil' do
|
31
|
+
@configurator.sanity_checks = TestResultsSanityChecks::NORMAL
|
32
|
+
expect{@sanity_checker.verify(nil, 3)}.to raise_error(RuntimeError)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'rasies error if results are empty' do
|
36
|
+
@configurator.sanity_checks = TestResultsSanityChecks::NORMAL
|
37
|
+
expect{@sanity_checker.verify({}, 3)}.to raise_error(RuntimeError)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns nil if basic checks are good' do
|
41
|
+
@configurator.sanity_checks = TestResultsSanityChecks::NORMAL
|
42
|
+
expect(@sanity_checker.verify(@results, 3)).to be_nil
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'rasies error if basic check fails for ignore' do
|
46
|
+
@configurator.sanity_checks = TestResultsSanityChecks::NORMAL
|
47
|
+
@results[:counts][:ignored] = 0
|
48
|
+
allow(@configurator).to receive(:extension_executable).and_return('')
|
49
|
+
allow(@streaminator).to receive(:stderr_puts)
|
50
|
+
expect{@sanity_checker.verify(@results, 3)}.to raise_error(RuntimeError)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'rasies error if basic check fails for failed' do
|
54
|
+
@configurator.sanity_checks = TestResultsSanityChecks::NORMAL
|
55
|
+
@results[:counts][:failed] = 0
|
56
|
+
allow(@configurator).to receive(:extension_executable).and_return('')
|
57
|
+
allow(@streaminator).to receive(:stderr_puts)
|
58
|
+
expect{@sanity_checker.verify(@results, 3)}.to raise_error(RuntimeError)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'rasies error if basic check fails for total' do
|
62
|
+
@configurator.sanity_checks = TestResultsSanityChecks::NORMAL
|
63
|
+
@results[:counts][:total] = 0
|
64
|
+
allow(@configurator).to receive(:extension_executable).and_return('')
|
65
|
+
allow(@streaminator).to receive(:stderr_puts)
|
66
|
+
expect{@sanity_checker.verify(@results, 3)}.to raise_error(RuntimeError)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'rasies error if thorough check fails for error code not 255 not equal' do
|
70
|
+
@configurator.sanity_checks = TestResultsSanityChecks::THOROUGH
|
71
|
+
allow(@configurator).to receive(:extension_executable).and_return('')
|
72
|
+
allow(@streaminator).to receive(:stderr_puts)
|
73
|
+
expect{@sanity_checker.verify(@results, 2)}.to raise_error(RuntimeError)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'rasies error if thorough check fails for error code 255 less than 255' do
|
77
|
+
@configurator.sanity_checks = TestResultsSanityChecks::THOROUGH
|
78
|
+
allow(@configurator).to receive(:extension_executable).and_return('')
|
79
|
+
allow(@streaminator).to receive(:stderr_puts)
|
80
|
+
expect{@sanity_checker.verify(@results, 255)}.to raise_error(RuntimeError)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'returns nil if thorough checks are good' do
|
84
|
+
@configurator.sanity_checks = TestResultsSanityChecks::THOROUGH
|
85
|
+
expect(@sanity_checker.verify(@results, 3)).to be_nil
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ceedling/generator_test_results_sanity_checker'
|
3
|
+
require 'ceedling/generator_test_results'
|
4
|
+
require 'ceedling/yaml_wrapper'
|
5
|
+
require 'ceedling/constants'
|
6
|
+
require 'ceedling/streaminator'
|
7
|
+
require 'ceedling/configurator'
|
8
|
+
|
9
|
+
NORMAL_OUTPUT =
|
10
|
+
"Verbose output one\n" +
|
11
|
+
"Verbous output two\n" +
|
12
|
+
"test_example.c:257:test_one:PASS\n" +
|
13
|
+
"test_example.c:269:test_two:PASS\n" +
|
14
|
+
"\n" +
|
15
|
+
"-----------------------\n" +
|
16
|
+
"2 Tests 0 Failures 0 Ignored \n" +
|
17
|
+
"OK\n".freeze
|
18
|
+
|
19
|
+
IGNORE_OUTPUT =
|
20
|
+
"Verbose output one\n" +
|
21
|
+
"Verbous output two\n" +
|
22
|
+
"test_example.c:257:test_one:IGNORE\n" +
|
23
|
+
"test_example.c:269:test_two:IGNORE\n" +
|
24
|
+
"\n" +
|
25
|
+
"-----------------------\n" +
|
26
|
+
"2 Tests 0 Failures 2 Ignored \n" +
|
27
|
+
"OK\n".freeze
|
28
|
+
|
29
|
+
|
30
|
+
FAIL_OUTPUT =
|
31
|
+
"Verbose output one\n" +
|
32
|
+
"Verbous output two\n" +
|
33
|
+
"test_example.c:257:test_one:FAIL\n" +
|
34
|
+
"test_example.c:269:test_two:FAIL\n" +
|
35
|
+
"\n" +
|
36
|
+
"-----------------------\n" +
|
37
|
+
"2 Tests 2 Failures 0 Ignored \n" +
|
38
|
+
"OK\n".freeze
|
39
|
+
|
40
|
+
|
41
|
+
MANGLED_OUTPUT =
|
42
|
+
"Verbose output one\n" +
|
43
|
+
"test_example.c:257:test_one:PASS\n" +
|
44
|
+
"test_example.c:269:test_tVerbous output two\n" +
|
45
|
+
"wo:PASS\n" +
|
46
|
+
"\n" +
|
47
|
+
"-----------------------\n" +
|
48
|
+
"2 Tests 0 Failures 0 Ignored \n" +
|
49
|
+
"OK\n".freeze
|
50
|
+
|
51
|
+
TEST_OUT_FILE = 'out.pass'
|
52
|
+
TEST_OUT_FILE_FAIL = 'out.fail'
|
53
|
+
|
54
|
+
|
55
|
+
describe GeneratorTestResults do
|
56
|
+
before(:each) do
|
57
|
+
# these will always be mocked
|
58
|
+
@configurator = Configurator.new({:configurator_setup => nil, :configurator_builder => nil, :configurator_plugins => nil, :cmock_builder => nil, :yaml_wrapper => nil, :system_wrapper => nil})
|
59
|
+
@streaminator = Streaminator.new({:streaminator_helper => nil, :verbosinator => nil, :loginator => nil, :stream_wrapper => nil})
|
60
|
+
|
61
|
+
# these will always be used as is.
|
62
|
+
@yaml_wrapper = YamlWrapper.new
|
63
|
+
@sanity_checker = GeneratorTestResultsSanityChecker.new({:configurator => @configurator, :streaminator => @streaminator})
|
64
|
+
|
65
|
+
@generate_test_results = described_class.new({:configurator => @configurator, :generator_test_results_sanity_checker => @sanity_checker, :yaml_wrapper => @yaml_wrapper})
|
66
|
+
end
|
67
|
+
|
68
|
+
after(:each) do
|
69
|
+
if File.exists?(TEST_OUT_FILE)
|
70
|
+
File.delete(TEST_OUT_FILE)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#process_and_write_results' do
|
75
|
+
it 'handles an empty input' do
|
76
|
+
@generate_test_results.process_and_write_results({:output => ''}, TEST_OUT_FILE, 'some/place/test_example.c')
|
77
|
+
expect(IO.read(TEST_OUT_FILE)).to eq(IO.read('spec/support/test_example_empty.pass'))
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'handles a normal test output' do
|
81
|
+
@generate_test_results.process_and_write_results({:output => NORMAL_OUTPUT}, TEST_OUT_FILE, 'some/place/test_example.c')
|
82
|
+
expect(IO.read(TEST_OUT_FILE)).to eq(IO.read('spec/support/test_example.pass'))
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'handles a normal test output with ignores' do
|
86
|
+
@generate_test_results.process_and_write_results({:output => IGNORE_OUTPUT}, TEST_OUT_FILE, 'some/place/test_example.c')
|
87
|
+
expect(IO.read(TEST_OUT_FILE)).to eq(IO.read('spec/support/test_example_ignore.pass'))
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'handles a normal test output with failures' do
|
91
|
+
allow(@configurator).to receive(:extension_testfail).and_return('.fail')
|
92
|
+
@generate_test_results.process_and_write_results({:output => FAIL_OUTPUT}, TEST_OUT_FILE, 'some/place/test_example.c')
|
93
|
+
expect(IO.read(TEST_OUT_FILE_FAIL)).to eq(IO.read('spec/support/test_example.fail'))
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'handles a mangled test output as gracefully as it can' do
|
97
|
+
@generate_test_results.process_and_write_results({:output => MANGLED_OUTPUT}, TEST_OUT_FILE, 'some/place/test_example.c')
|
98
|
+
expect(IO.read(TEST_OUT_FILE)).to eq(IO.read('spec/support/test_example_mangled.pass'))
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|