Skip to content

Commit

Permalink
further test patches for updated features.
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandervoord committed Dec 13, 2023
1 parent 20c551e commit 33c2013
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 100 deletions.
2 changes: 1 addition & 1 deletion lib/ceedling/system_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def setup
# Checks the system shell to see if it a tcsh shell.
def tcsh_shell?
# once run a single time, return state determined at that execution
return @tcsh_shell if not @tcsh_shell.nil?
return @tcsh_shell unless @tcsh_shell.nil?

result = @system_wrapper.shell_backticks(command:'echo $version')

Expand Down
6 changes: 3 additions & 3 deletions spec/gcov/gcov_test_cases_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def can_create_gcov_html_report_from_crashing_test_runner_with_enabled_debug_and
expect(output).to match(/example_file.c \| Lines executed:50.00% of 4/)

expect(output).to match(/Creating HTML coverage report\(s\) with gcovr in 'build\/artifacts\/gcov'\.\.\./)
expect(output).to.match(/Done/)
expect(output).to match(/Done/)
expect(File.exist?('build/artifacts/gcov/GcovCoverageResults.html')).to eq true
end
end
Expand Down Expand Up @@ -248,7 +248,7 @@ def can_create_gcov_html_report_from_crashing_test_runner_with_enabled_debug_and
expect(output).to match(/example_file.c \| Lines executed:0.00% of 4/)

expect(output).to match(/Creating HTML coverage report\(s\) with gcovr in 'build\/artifacts\/gcov'\.\.\./)
expect(output).to.match(/Done/)
expect(output).to match(/Done/)
expect(File.exist?('build/artifacts/gcov/GcovCoverageResults.html')).to eq true
end
end
Expand Down Expand Up @@ -283,7 +283,7 @@ def can_create_gcov_html_report_from_test_runner_with_enabled_debug_and_cmd_args
expect(output).to match(/example_file.c \| Lines executed:100.00% of 4/)

expect(output).to match(/Creating HTML coverage report\(s\) with gcovr in 'build\/artifacts\/gcov'\.\.\./)
expect(output).to.match(/Done/)
expect(output).to match(/Done/)
expect(File.exist?('build/artifacts/gcov/GcovCoverageResults.html')).to eq true
end
end
Expand Down
41 changes: 21 additions & 20 deletions spec/spec_system_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def can_test_projects_with_test_and_vendor_defines_with_success
FileUtils.cp test_asset_path("example_file.c"), 'src/'
FileUtils.cp test_asset_path("test_example_file_unity_printf.c"), 'test/'
settings = { :unity => { :defines => [ "UNITY_INCLUDE_PRINT_FORMATTED" ] },
:defines => { :test_example_file_unity_printf => [ "TEST" ] }
:defines => { :test => { :example_file_unity_printf => [ "TEST" ] } }
}
add_project_settings("project.yml", settings)

Expand All @@ -364,23 +364,24 @@ def can_test_projects_with_test_and_vendor_defines_with_success
end
end

def can_test_projects_with_enabled_auto_link_deep_deependency_with_success
@c.with_context do
Dir.chdir @proj_name do
FileUtils.copy_entry test_asset_path("auto_link_deep_dependencies/src/"), 'src/'
FileUtils.cp_r test_asset_path("auto_link_deep_dependencies/test/."), 'test/'
settings = { :project => { :auto_link_deep_dependencies => true } }
add_project_settings("project.yml", settings)

output = `bundle exec ruby -S ceedling 2>&1`
expect($?.exitstatus).to match(0) # Since a test either pass or are ignored, we return success here
expect(output).to match(/TESTED:\s+\d/)
expect(output).to match(/PASSED:\s+\d/)
expect(output).to match(/FAILED:\s+\d/)
expect(output).to match(/IGNORED:\s+\d/)
end
end
end
#TODO: feature temporarily disabled
# def can_test_projects_with_enabled_auto_link_deep_deependency_with_success
# @c.with_context do
# Dir.chdir @proj_name do
# FileUtils.copy_entry test_asset_path("auto_link_deep_dependencies/src/"), 'src/'
# FileUtils.cp_r test_asset_path("auto_link_deep_dependencies/test/."), 'test/'
# settings = { :project => { :auto_link_deep_dependencies => true } }
# add_project_settings("project.yml", settings)

# output = `bundle exec ruby -S ceedling 2>&1`
# expect($?.exitstatus).to match(0) # Since a test either pass or are ignored, we return success here
# expect(output).to match(/TESTED:\s+\d/)
# expect(output).to match(/PASSED:\s+\d/)
# expect(output).to match(/FAILED:\s+\d/)
# expect(output).to match(/IGNORED:\s+\d/)
# end
# end
# end

def can_test_projects_with_enabled_preprocessor_directives_with_success
@c.with_context do
Expand All @@ -405,9 +406,9 @@ def can_test_projects_with_test_name_replaced_defines_with_success
Dir.chdir @proj_name do
FileUtils.copy_entry test_asset_path("tests_with_defines/src/"), 'src/'
FileUtils.cp_r test_asset_path("tests_with_defines/test/."), 'test/'
settings = { :defines => { :test => [ "STANDARD_CONFIG" ],
settings = { :defines => { :test => { :* => [ "STANDARD_CONFIG" ],
:test_adc_hardware_special => [ "TEST", "SPECIFIC_CONFIG" ],
}
} }
}
add_project_settings("project.yml", settings)

Expand Down
14 changes: 8 additions & 6 deletions spec/system_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

@sys_utils = described_class.new({:system_wrapper => @sys_wrapper})
@sys_utils.setup

@echo_test_cmd = {:command=>'echo $version'}
end

describe '#setup' do
Expand All @@ -21,7 +23,7 @@
expect(@sys_utils.instance_variable_get(:@tcsh_shell)).to eq(nil)


allow(@streaminator).to receive(:shell_backticks).with('echo $version').and_return({:exit_code => 0, :output =>'tcsh 1234567890'})
allow(@streaminator).to receive(:shell_backticks).with(@echo_test_cmd).and_return({:exit_code => 0, :output =>'tcsh 1234567890'})
@sys_utils.tcsh_shell?

@sys_utils.setup
Expand All @@ -32,24 +34,24 @@

describe '#tcsh_shell?' do
it 'returns true if exit code is zero and output contains tcsh' do
allow(@streaminator).to receive(:shell_backticks).with('echo $version').and_return({:exit_code => 0, :output =>'tcsh 1234567890'})
allow(@streaminator).to receive(:shell_backticks).with(@echo_test_cmd).and_return({:exit_code => 0, :output =>'tcsh 1234567890'})
expect(@sys_utils.tcsh_shell?).to eq(true)
end

it 'returns false if exit code is not 0' do
allow(@streaminator).to receive(:shell_backticks).with('echo $version').and_return({:exit_code => 1, :output =>'tcsh 1234567890'})
allow(@streaminator).to receive(:shell_backticks).with(@echo_test_cmd).and_return({:exit_code => 1, :output =>'tcsh 1234567890'})
expect(@sys_utils.tcsh_shell?).to eq(false)
end

it 'returns false if output does not contain tcsh' do
allow(@streaminator).to receive(:shell_backticks).with('echo $version').and_return({:exit_code => 0, :output =>'???'})
allow(@streaminator).to receive(:shell_backticks).with(@echo_test_cmd).and_return({:exit_code => 0, :output =>'???'})
expect(@sys_utils.tcsh_shell?).to eq(false)
end

it 'returns last value if already run' do
allow(@streaminator).to receive(:shell_backticks).with('echo $version').and_return({:exit_code => 1, :output =>'???'})
allow(@streaminator).to receive(:shell_backticks).with(@echo_test_cmd).and_return({:exit_code => 1, :output =>'???'})
expect(@sys_utils.tcsh_shell?).to eq(false)
allow(@streaminator).to receive(:shell_backticks).with('echo $version').and_return({:exit_code => 0, :output =>'tcsh 1234567890'})
allow(@streaminator).to receive(:shell_backticks).with(@echo_test_cmd).and_return({:exit_code => 0, :output =>'tcsh 1234567890'})
expect(@sys_utils.tcsh_shell?).to eq(false)
end
end
Expand Down
70 changes: 0 additions & 70 deletions spec/tool_executor_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,6 @@
end


describe '#background_exec_cmdline_prepend' do
it 'returns nil if tool_config is nil' do
expect(@tool_exe_helper.background_exec_cmdline_prepend(nil)).to be_nil
end

it 'returns nil if tool_config[:background_exec] is nil' do
expect(@tool_exe_helper.background_exec_cmdline_prepend({:background_exec =>nil})).to be_nil
end

it 'returns "start" if tool_config[:background_exec] is AUTO on windows' do
expect(@sys_wraper).to receive(:windows?).and_return(true)
expect(@tool_exe_helper.background_exec_cmdline_prepend({:background_exec =>BackgroundExec::AUTO})).to eq('start')
end

it 'returns nil if tool_config[:background_exec] is AUTO not on windows' do
expect(@sys_wraper).to receive(:windows?).and_return(false)
expect(@tool_exe_helper.background_exec_cmdline_prepend({:background_exec =>BackgroundExec::AUTO})).to be_nil
end

it 'returns "start" if tool_config[:background_exec] is WIN' do
expect(@tool_exe_helper.background_exec_cmdline_prepend({:background_exec =>BackgroundExec::WIN})).to eq('start')
end
end


describe '#osify_path_separators' do
it 'returns path if system is not windows' do
exe = '/just/some/executable.out'
Expand Down Expand Up @@ -155,51 +130,6 @@
end
end


describe '#background_exec_cmdline_append' do
it 'returns nil if tool_config is nil' do
expect(@tool_exe_helper.background_exec_cmdline_append(nil)).to be_nil
end

it 'returns nil if tool_config[:background_exec] is nil' do
tool_config = {:background_exec => nil}
expect(@tool_exe_helper.background_exec_cmdline_append(tool_config)).to be_nil
end

it 'returns nil if tool_config is set to none' do
tool_config = {:background_exec => BackgroundExec::NONE}
expect(@tool_exe_helper.background_exec_cmdline_append(tool_config)).to be_nil
end

it 'returns nil if tool_config is set to none' do
tool_config = {:background_exec => BackgroundExec::WIN}
expect(@tool_exe_helper.background_exec_cmdline_append(tool_config)).to be_nil
end

it 'returns "&" if tool_config is set to UNIX' do
tool_config = {:background_exec => BackgroundExec::UNIX}
expect(@tool_exe_helper.background_exec_cmdline_append(tool_config)).to eq('&')
end

context 'when tool_config[:background_exec] BackgroundExec:AUTO' do
before(:each) do
@tool_config = {:background_exec => BackgroundExec::AUTO}
end


it 'returns nil if system is windows' do
expect(@sys_wraper).to receive(:windows?).and_return(true)
expect(@tool_exe_helper.background_exec_cmdline_append(@tool_config)).to be_nil
end

it 'returns "&" if system is not windows' do
expect(@sys_wraper).to receive(:windows?).and_return(false)
expect(@sys_wraper).to receive(:windows?).and_return(false)
expect(@tool_exe_helper.background_exec_cmdline_append(@tool_config)).to eq('&')
end
end
end

describe '#print_happy_results' do
context 'when exit code is 0' do
before(:each) do
Expand Down

0 comments on commit 33c2013

Please sign in to comment.