mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-30 03:34:27 +01:00
make fixtures and examples compatible with new UnityBegin method.
This commit is contained in:
@@ -33,8 +33,7 @@ void resetTest()
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
Unity.TestFile = "test/TestProductionCode2.c";
|
UnityBegin("test/TestProductionCode2.c");
|
||||||
UnityBegin();
|
|
||||||
|
|
||||||
// RUN_TEST calls runTest
|
// RUN_TEST calls runTest
|
||||||
RUN_TEST(test_IgnoredTest, 13);
|
RUN_TEST(test_IgnoredTest, 13);
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ void resetTest()
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
Unity.TestFile = "test/TestProductionCode.c";
|
UnityBegin("test/TestProductionCode.c");
|
||||||
UnityBegin();
|
|
||||||
|
|
||||||
// RUN_TEST calls runTest
|
// RUN_TEST calls runTest
|
||||||
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20);
|
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20);
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ void resetTest()
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
Unity.TestFile = "test/TestProductionCode2.c";
|
UnityBegin("test/TestProductionCode2.c");
|
||||||
UnityBegin();
|
|
||||||
|
|
||||||
// RUN_TEST calls runTest
|
// RUN_TEST calls runTest
|
||||||
RUN_TEST(test_IgnoredTest, 13);
|
RUN_TEST(test_IgnoredTest, 13);
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ void resetTest()
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
Unity.TestFile = "test/TestProductionCode.c";
|
UnityBegin("test/TestProductionCode.c");
|
||||||
UnityBegin();
|
|
||||||
|
|
||||||
// RUN_TEST calls runTest
|
// RUN_TEST calls runTest
|
||||||
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20);
|
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Unity Project - A Test Framework for C
|
# Unity Project - A Test Framework for C
|
||||||
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||||
# [Released under MIT License. Please refer to license.txt for details]
|
# [Released under MIT License. Please refer to license.txt for details]
|
||||||
# ==========================================
|
# ==========================================
|
||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
@@ -13,27 +13,27 @@ require HERE+'../../auto/colour_reporter'
|
|||||||
module RakefileHelpers
|
module RakefileHelpers
|
||||||
|
|
||||||
C_EXTENSION = '.c'
|
C_EXTENSION = '.c'
|
||||||
|
|
||||||
def load_configuration(config_file)
|
def load_configuration(config_file)
|
||||||
unless ($configured)
|
unless ($configured)
|
||||||
$cfg_file = HERE+"../../targets/#{config_file}" unless (config_file =~ /[\\|\/]/)
|
$cfg_file = HERE+"../../test/targets/#{config_file}" unless (config_file =~ /[\\|\/]/)
|
||||||
$cfg = YAML.load(File.read($cfg_file))
|
$cfg = YAML.load(File.read($cfg_file))
|
||||||
$colour_output = false unless $cfg['colour']
|
$colour_output = false unless $cfg['colour']
|
||||||
$configured = true if (config_file != DEFAULT_CONFIG_FILE)
|
$configured = true if (config_file != DEFAULT_CONFIG_FILE)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_clean
|
def configure_clean
|
||||||
CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil?
|
CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_toolchain(config_file=DEFAULT_CONFIG_FILE)
|
def configure_toolchain(config_file=DEFAULT_CONFIG_FILE)
|
||||||
config_file += '.yml' unless config_file =~ /\.yml$/
|
config_file += '.yml' unless config_file =~ /\.yml$/
|
||||||
config_file = config_file unless config_file =~ /[\\|\/]/
|
config_file = config_file unless config_file =~ /[\\|\/]/
|
||||||
load_configuration(config_file)
|
load_configuration(config_file)
|
||||||
configure_clean
|
configure_clean
|
||||||
end
|
end
|
||||||
|
|
||||||
def tackit(strings)
|
def tackit(strings)
|
||||||
if strings.is_a?(Array)
|
if strings.is_a?(Array)
|
||||||
result = "\"#{strings.join}\""
|
result = "\"#{strings.join}\""
|
||||||
@@ -42,7 +42,7 @@ module RakefileHelpers
|
|||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
def squash(prefix, items)
|
def squash(prefix, items)
|
||||||
result = ''
|
result = ''
|
||||||
items.each { |item| result += " #{prefix}#{tackit(item)}" }
|
items.each { |item| result += " #{prefix}#{tackit(item)}" }
|
||||||
@@ -70,7 +70,7 @@ module RakefileHelpers
|
|||||||
"#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
"#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
||||||
execute(cmd_str)
|
execute(cmd_str)
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_linker_fields
|
def build_linker_fields
|
||||||
command = tackit($cfg['linker']['path'])
|
command = tackit($cfg['linker']['path'])
|
||||||
if $cfg['linker']['options'].nil?
|
if $cfg['linker']['options'].nil?
|
||||||
@@ -86,7 +86,7 @@ module RakefileHelpers
|
|||||||
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
||||||
return {:command => command, :options => options, :includes => includes}
|
return {:command => command, :options => options, :includes => includes}
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_it(exe_name, obj_list)
|
def link_it(exe_name, obj_list)
|
||||||
linker = build_linker_fields
|
linker = build_linker_fields
|
||||||
cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
|
cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
|
||||||
@@ -96,7 +96,7 @@ module RakefileHelpers
|
|||||||
exe_name + $cfg['linker']['bin_files']['extension']
|
exe_name + $cfg['linker']['bin_files']['extension']
|
||||||
execute(cmd_str)
|
execute(cmd_str)
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_simulator_fields
|
def build_simulator_fields
|
||||||
return nil if $cfg['simulator'].nil?
|
return nil if $cfg['simulator'].nil?
|
||||||
if $cfg['simulator']['path'].nil?
|
if $cfg['simulator']['path'].nil?
|
||||||
@@ -116,7 +116,7 @@ module RakefileHelpers
|
|||||||
end
|
end
|
||||||
return {:command => command, :pre_support => pre_support, :post_support => post_support}
|
return {:command => command, :pre_support => pre_support, :post_support => post_support}
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute(command_string, verbose=true)
|
def execute(command_string, verbose=true)
|
||||||
report command_string
|
report command_string
|
||||||
output = `#{command_string}`.chomp
|
output = `#{command_string}`.chomp
|
||||||
@@ -126,7 +126,7 @@ module RakefileHelpers
|
|||||||
end
|
end
|
||||||
return output
|
return output
|
||||||
end
|
end
|
||||||
|
|
||||||
def report_summary
|
def report_summary
|
||||||
summary = UnityTestSummary.new
|
summary = UnityTestSummary.new
|
||||||
summary.set_root_path(HERE)
|
summary.set_root_path(HERE)
|
||||||
@@ -136,29 +136,29 @@ module RakefileHelpers
|
|||||||
summary.set_targets(results)
|
summary.set_targets(results)
|
||||||
summary.run
|
summary.run
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_tests
|
def run_tests
|
||||||
report 'Running Unity system tests...'
|
report 'Running Unity system tests...'
|
||||||
|
|
||||||
# Tack on TEST define for compiling unit tests
|
# Tack on TEST define for compiling unit tests
|
||||||
load_configuration($cfg_file)
|
load_configuration($cfg_file)
|
||||||
test_defines = ['TEST']
|
test_defines = ['TEST']
|
||||||
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
||||||
|
|
||||||
# Get a list of all source files needed
|
# Get a list of all source files needed
|
||||||
src_files = Dir[HERE+'src/*.c']
|
src_files = Dir[HERE+'src/*.c']
|
||||||
src_files += Dir[HERE+'test/*.c']
|
src_files += Dir[HERE+'test/*.c']
|
||||||
src_files += Dir[HERE+'test/main/*.c']
|
src_files += Dir[HERE+'test/main/*.c']
|
||||||
src_files << '../../src/unity.c'
|
src_files << '../../src/unity.c'
|
||||||
|
|
||||||
# Build object files
|
# Build object files
|
||||||
src_files.each { |f| compile(f, test_defines) }
|
src_files.each { |f| compile(f, test_defines) }
|
||||||
obj_list = src_files.map {|f| File.basename(f.ext($cfg['compiler']['object_files']['extension'])) }
|
obj_list = src_files.map {|f| File.basename(f.ext($cfg['compiler']['object_files']['extension'])) }
|
||||||
|
|
||||||
# Link the test executable
|
# Link the test executable
|
||||||
test_base = "framework_test"
|
test_base = "framework_test"
|
||||||
link_it(test_base, obj_list)
|
link_it(test_base, obj_list)
|
||||||
|
|
||||||
# Execute unit test and generate results file
|
# Execute unit test and generate results file
|
||||||
simulator = build_simulator_fields
|
simulator = build_simulator_fields
|
||||||
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ int UnityMain(int argc, char* argv[], void (*runAllTests)(void))
|
|||||||
for (r = 0; r < UnityFixture.RepeatCount; r++)
|
for (r = 0; r < UnityFixture.RepeatCount; r++)
|
||||||
{
|
{
|
||||||
announceTestRun(r);
|
announceTestRun(r);
|
||||||
UnityBegin();
|
UnityBegin(argv[0]);
|
||||||
runAllTests();
|
runAllTests();
|
||||||
UNITY_OUTPUT_CHAR('\n');
|
UNITY_OUTPUT_CHAR('\n');
|
||||||
UnityEnd();
|
UnityEnd();
|
||||||
|
|||||||
Reference in New Issue
Block a user