Add examples to the automated testing in travis. Make err-on-fail optional on both examples (disabled during ci)

This commit is contained in:
Mark VanderVoord
2017-04-07 22:22:38 -04:00
parent 07d6714fe2
commit bfdfe944b9
10 changed files with 53 additions and 31 deletions
+2 -2
View File
@@ -14,7 +14,7 @@ all: setup test ${BUILD_DIR}/main run
setup:
mkdir -p ${BUILD_DIR}
mkdir -p ${OBJ}
ruby ../../scripts/create_makefile.rb
ruby ../../scripts/create_makefile.rb --silent
clean:
rm -rf ${BUILD_DIR}
@@ -23,7 +23,7 @@ ${BUILD_DIR}/main: ${SRC_DIR}/main.c ${SRC_DIR}/foo.c
${CC} $< -o $@
run:
./build/main
./build/main || true
test: setup
+5 -4
View File
@@ -9,10 +9,10 @@ compiler:
prefix: '-I'
items:
- 'src/'
- '../src/'
- '../vendor/unity/src/'
- '../vendor/unity/examples/example_3/helper/'
- 'mocks/'
- '../../src/'
- '../../vendor/unity/src/'
- '../../vendor/unity/examples/example_3/helper/'
- './build/mocks/'
- *unit_tests_path
defines:
prefix: '-D'
@@ -39,5 +39,6 @@ linker:
:plugins: []
:includes:
- Types.h
:mock_path: ./build/mocks
colour: true
+5 -4
View File
@@ -30,10 +30,10 @@ compiler:
prefix: '-I'
items:
- 'src/'
- '../src/'
- '../vendor/unity/src/'
- '../vendor/unity/examples/example_3/helper/'
- 'mocks/'
- '../../src/'
- '../../vendor/unity/src/'
- '../../vendor/unity/examples/example_3/helper/'
- './build/mocks/'
- [*tools_root, 'arm\inc\']
- *unit_tests_path
defines:
@@ -88,4 +88,5 @@ simulator:
:plugins: []
:includes:
- Types.h
:mock_path: ./build/mocks
+5 -4
View File
@@ -29,10 +29,10 @@ compiler:
prefix: '-I'
items:
- 'src/'
- '../src/'
- '../vendor/unity/src/'
- '../vendor/unity/examples/example_3/helper/'
- 'mocks/'
- '../../src/'
- '../../vendor/unity/src/'
- '../../vendor/unity/examples/example_3/helper/'
- './build/mocks/'
- [*tools_root, 'arm\inc\']
- *unit_tests_path
defines:
@@ -77,4 +77,5 @@ simulator:
:plugins: []
:includes:
- Types.h
:mock_path: ./build/mocks
+11 -1
View File
@@ -7,6 +7,11 @@ require './rakefile_helper'
include RakefileHelpers
REQUIRED_DIRS = [ './build', './build/mocks' ]
REQUIRED_DIRS.each do |v|
directory v
end
# Load default configuration, for now
DEFAULT_CONFIG_FILE = 'gcc.yml'
configure_toolchain(DEFAULT_CONFIG_FILE)
@@ -22,7 +27,7 @@ end
desc "Build and test Unity"
task :all => [:clean, :unit, :summary]
task :default => [:clobber, :all]
task :default => REQUIRED_DIRS + [:clobber, :all]
task :ci => [:default]
task :cruise => [:default]
@@ -30,3 +35,8 @@ desc "Load configuration"
task :config, :config_file do |t, args|
configure_toolchain(args[:config_file])
end
desc "Return error on Failures"
task :strict do
$return_error_on_failures = true
end
+12 -10
View File
@@ -1,11 +1,13 @@
require 'yaml'
require 'fileutils'
require '../vendor/unity/auto/unity_test_summary'
require '../vendor/unity/auto/generate_test_runner'
require '../vendor/unity/auto/colour_reporter'
require '../../vendor/unity/auto/unity_test_summary'
require '../../vendor/unity/auto/generate_test_runner'
require '../../vendor/unity/auto/colour_reporter'
module RakefileHelpers
$return_error_on_failures = false
C_EXTENSION = '.c'
def load_configuration(config_file)
@@ -145,11 +147,11 @@ module RakefileHelpers
return {:command => command, :pre_support => pre_support, :post_support => post_support}
end
def execute(command_string, verbose=true)
def execute(command_string, verbose=true, ok_to_fail=false)
report command_string
output = `#{command_string}`.chomp
report(output) if (verbose && !output.nil? && (output.length > 0))
if $?.exitstatus != 0
unless $?.exitstatus.zero? || ok_to_fail
raise "Command failed. (Returned #{$?.exitstatus})"
end
return output
@@ -157,13 +159,13 @@ module RakefileHelpers
def report_summary
summary = UnityTestSummary.new
summary.set_root_path(HERE)
summary.root = HERE
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
results_glob.gsub!(/\\/, '/')
results = Dir[results_glob]
summary.set_targets(results)
summary.targets = results
report summary.run
raise "There were failures" if (summary.failures > 0)
raise "There were failures" if (summary.failures > 0) && $return_error_on_failures
end
def run_tests(test_files)
@@ -188,7 +190,7 @@ module RakefileHelpers
#create mocks if needed
if (header =~ /Mock/)
require "../lib/cmock.rb"
require "../../lib/cmock.rb"
@cmock ||= CMock.new($cfg_file)
@cmock.setup_mocks([$cfg['compiler']['source_path']+header.gsub('Mock','')])
end
@@ -231,7 +233,7 @@ module RakefileHelpers
else
cmd_str = "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
end
output = execute(cmd_str)
output = execute(cmd_str, true, true)
test_results = $cfg['compiler']['build_path'] + test_base
if output.match(/OK$/m).nil?
test_results += '.testfail'