diff --git a/examples/temp_sensor/project.yml b/examples/temp_sensor/project.yml index b94852ab5..601227f46 100644 --- a/examples/temp_sensor/project.yml +++ b/examples/temp_sensor/project.yml @@ -113,16 +113,11 @@ :use_test_definition: FALSE # Configure additional command line flags provided to tools used in each build step -# :flags: -# :release: -# :compile: # Add '-Wall' and '--02' to compilation of all files in release target -# - -Wall -# - --O2 -# :test: -# :compile: -# '(_|-)special': # Add '-pedantic' to compilation of all files in all test executables with '_special' or '-special' in their names -# - -pedantic -# '*': # Add '-foo' to compilation of all files in all test executables +:flags: + :test: + :compile: + 'TemperatureCalculator': + - '-DSUPPLY_VOLTAGE=3.0' # Configuration Options specific to CMock. See CMock docs for details :cmock: diff --git a/examples/temp_sensor/src/TemperatureCalculator.c b/examples/temp_sensor/src/TemperatureCalculator.c index 8984453de..d1741c88e 100644 --- a/examples/temp_sensor/src/TemperatureCalculator.c +++ b/examples/temp_sensor/src/TemperatureCalculator.c @@ -13,9 +13,13 @@ #define logl log #endif +#ifndef SUPPLY_VOLTAGE +#define SUPPLY_VOLTAGE 5.0 +#endif + float TemperatureCalculator_Calculate(uint16 millivolts) { - const double supply_voltage = 3.0; + const double supply_voltage = SUPPLY_VOLTAGE; const double series_resistance = 5000; const double coefficient_A = 316589.698; const double coefficient_B = -0.1382009; diff --git a/examples/temp_sensor/test/TestAdcConductor.c b/examples/temp_sensor/test/adc/TestAdcConductor.c similarity index 100% rename from examples/temp_sensor/test/TestAdcConductor.c rename to examples/temp_sensor/test/adc/TestAdcConductor.c diff --git a/examples/temp_sensor/test/TestAdcHardware.c b/examples/temp_sensor/test/adc/TestAdcHardware.c similarity index 100% rename from examples/temp_sensor/test/TestAdcHardware.c rename to examples/temp_sensor/test/adc/TestAdcHardware.c diff --git a/examples/temp_sensor/test/TestAdcModel.c b/examples/temp_sensor/test/adc/TestAdcModel.c similarity index 100% rename from examples/temp_sensor/test/TestAdcModel.c rename to examples/temp_sensor/test/adc/TestAdcModel.c diff --git a/spec/gcov/gcov_deployment_spec.rb b/spec/gcov/gcov_deployment_spec.rb index 208d35407..e1db08979 100644 --- a/spec/gcov/gcov_deployment_spec.rb +++ b/spec/gcov/gcov_deployment_spec.rb @@ -73,6 +73,60 @@ end end end + + it "should be able to test a single module (it should INHERIT file-specific flags)" do + @c.with_context do + Dir.chdir "temp_sensor" do + @output = `bundle exec ruby -S ceedling gcov:TemperatureCalculator 2>&1` + expect(@output).to match(/TESTED:\s+2/) + expect(@output).to match(/PASSED:\s+2/) + + expect(@output).to match(/TemperatureCalculator\.c \| Lines executed:/i) + end + end + end + + it "should be able to test multiple files matching a pattern" do + @c.with_context do + Dir.chdir "temp_sensor" do + @output = `bundle exec ruby -S ceedling gcov:pattern[Temp] 2>&1` + expect(@output).to match(/TESTED:\s+6/) + expect(@output).to match(/PASSED:\s+6/) + + expect(@output).to match(/TemperatureCalculator\.c \| Lines executed:/i) + expect(@output).to match(/TemperatureFilter\.c \| Lines executed:/i) + end + end + end + + it "should be able to test all files matching in a path" do + @c.with_context do + Dir.chdir "temp_sensor" do + @output = `bundle exec ruby -S ceedling gcov:path[adc] 2>&1` + expect(@output).to match(/TESTED:\s+15/) + expect(@output).to match(/PASSED:\s+15/) + + expect(@output).to match(/AdcConductor\.c \| Lines executed:/i) + expect(@output).to match(/AdcHardware\.c \| Lines executed:/i) + expect(@output).to match(/AdcModel\.c \| Lines executed:/i) + end + end + end + + it "should be able to test specific test cases in a file" do + @c.with_context do + Dir.chdir "temp_sensor" do + @output = `bundle exec ruby -S ceedling gcov:path[adc] --test-case="RunShouldNot" 2>&1` + expect(@output).to match(/TESTED:\s+2/) + expect(@output).to match(/PASSED:\s+2/) + + expect(@output).to match(/AdcConductor\.c \| Lines executed:/i) + expect(@output).to match(/AdcHardware\.c \| Lines executed:/i) + expect(@output).to match(/AdcModel\.c \| Lines executed:/i) + end + end + end + end end end diff --git a/spec/system/deployment_spec.rb b/spec/system/deployment_spec.rb index ba5c246cb..8accc44b4 100644 --- a/spec/system/deployment_spec.rb +++ b/spec/system/deployment_spec.rb @@ -206,6 +206,59 @@ end end end + + it "should be able to test a single module (it includes file-specific flags)" do + @c.with_context do + Dir.chdir "temp_sensor" do + @output = `bundle exec ruby -S ceedling test:TemperatureCalculator 2>&1` + expect(@output).to match(/TESTED:\s+2/) + expect(@output).to match(/PASSED:\s+2/) + + expect(@output).to match(/TemperatureCalculator\.out/i) + end + end + end + + it "should be able to test multiple files matching a pattern" do + @c.with_context do + Dir.chdir "temp_sensor" do + @output = `bundle exec ruby -S ceedling test:pattern[Temp] 2>&1` + expect(@output).to match(/TESTED:\s+6/) + expect(@output).to match(/PASSED:\s+6/) + + expect(@output).to match(/TemperatureCalculator\.out/i) + expect(@output).to match(/TemperatureFilter\.out/i) + end + end + end + + it "should be able to test all files matching in a path" do + @c.with_context do + Dir.chdir "temp_sensor" do + @output = `bundle exec ruby -S ceedling test:path[adc] 2>&1` + expect(@output).to match(/TESTED:\s+15/) + expect(@output).to match(/PASSED:\s+15/) + + expect(@output).to match(/AdcModel\.out/i) + expect(@output).to match(/AdcHardware\.out/i) + expect(@output).to match(/AdcConductor\.out/i) + end + end + end + + it "should be able to test specific test cases in a file" do + @c.with_context do + Dir.chdir "temp_sensor" do + @output = `bundle exec ruby -S ceedling test:path[adc] --test-case="RunShouldNot" 2>&1` + expect(@output).to match(/TESTED:\s+2/) + expect(@output).to match(/PASSED:\s+2/) + + expect(@output).to match(/AdcModel\.out/i) + expect(@output).to match(/AdcHardware\.out/i) + expect(@output).to match(/AdcConductor\.out/i) + end + end + end end # # blinky depends on avr-gcc. If you happen to have this installed, go