mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-23 08:25:58 +01:00
- unity_test_summary script callable from command line again
- fixed obj_file sorting in rakefiles - gave better anchors for gcc to grab on test pass/fail by breaking them out as functions - fixed minor type issues git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@137 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
This commit is contained in:
@@ -79,16 +79,17 @@ class UnityTestSummary
|
||||
end
|
||||
|
||||
def usage(err_msg=nil)
|
||||
puts "\nERROR: "
|
||||
puts err_msg if err_msg
|
||||
puts "Usage: unity_test_summary.rb"
|
||||
puts "\nUsage: unity_test_summary.rb result_file_directoy/ root_path/"
|
||||
puts " result_file_directory - The location of your relults files."
|
||||
puts " Defaults to current directory if not specified."
|
||||
puts " Should end in / if specified."
|
||||
puts " root_path - Helpful for producing more verbose output if using relative paths."
|
||||
exit 1
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
@@targets=nil
|
||||
@@path=nil
|
||||
@@root=nil
|
||||
|
||||
def get_details(result_file, lines)
|
||||
results = { :failures => [], :ignores => [], :successes => [] }
|
||||
@@ -117,10 +118,22 @@ class UnityTestSummary
|
||||
end
|
||||
|
||||
if $0 == __FILE__
|
||||
script = UnityTestSummary.new
|
||||
uts = UnityTestSummary.new
|
||||
begin
|
||||
script.run
|
||||
#look in the specified or current directory for result files
|
||||
ARGV[0] ||= './'
|
||||
targets = "#{ARGV[0].gsub(/\\/, '/')}*.test*"
|
||||
results = Dir[targets]
|
||||
raise "No *.testpass or *.testfail files found in '#{targets}'" if results.empty?
|
||||
uts.set_targets(results)
|
||||
|
||||
#set the root path
|
||||
ARGV[1] ||= File.expand_path(File.dirname(__FILE__)) + '/'
|
||||
uts.set_root_path(ARGV[1])
|
||||
|
||||
#run the summarizer
|
||||
puts uts.run
|
||||
rescue Exception => e
|
||||
script.usage e.message
|
||||
uts.usage e.message
|
||||
end
|
||||
end
|
||||
|
||||
@@ -87,10 +87,11 @@ module RakefileHelpers
|
||||
|
||||
def compile(file, defines=[])
|
||||
compiler = build_compiler_fields
|
||||
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " +
|
||||
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" +
|
||||
"#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
||||
execute(cmd_str)
|
||||
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " +
|
||||
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
|
||||
obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
||||
execute(cmd_str + obj_file)
|
||||
return obj_file
|
||||
end
|
||||
|
||||
def build_linker_fields
|
||||
@@ -181,8 +182,7 @@ module RakefileHelpers
|
||||
# Compile corresponding source file if it exists
|
||||
src_file = find_source_file(header, include_dirs)
|
||||
if !src_file.nil?
|
||||
compile(src_file, test_defines)
|
||||
obj_list << header.ext($cfg['compiler']['object_files']['extension'])
|
||||
obj_list << compile(src_file, test_defines)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -197,12 +197,10 @@ module RakefileHelpers
|
||||
runner_path = $cfg['compiler']['runner_path'] + runner_name
|
||||
end
|
||||
|
||||
compile(runner_path, test_defines)
|
||||
obj_list << runner_name.ext($cfg['compiler']['object_files']['extension'])
|
||||
obj_list << compile(runner_path, test_defines)
|
||||
|
||||
# Build the test module
|
||||
compile(test, test_defines)
|
||||
obj_list << test_base.ext($cfg['compiler']['object_files']['extension'])
|
||||
obj_list << compile(test, test_defines)
|
||||
|
||||
# Link the test executable
|
||||
link_it(test_base, obj_list)
|
||||
@@ -239,15 +237,13 @@ module RakefileHelpers
|
||||
extract_headers(main_path).each do |header|
|
||||
src_file = find_source_file(header, include_dirs)
|
||||
if !src_file.nil?
|
||||
compile(src_file)
|
||||
obj_list << header.ext($cfg['compiler']['object_files']['extension'])
|
||||
obj_list << compile(src_file)
|
||||
end
|
||||
end
|
||||
|
||||
# Build the main source file
|
||||
main_base = File.basename(main_path, C_EXTENSION)
|
||||
compile(main_path)
|
||||
obj_list << main_base.ext($cfg['compiler']['object_files']['extension'])
|
||||
obj_list << compile(main_path)
|
||||
|
||||
# Create the executable
|
||||
link_it(main_base, obj_list)
|
||||
|
||||
@@ -19,7 +19,7 @@ int verbose = 0;
|
||||
void setUp(void) { /*does nothing*/ }
|
||||
void tearDown(void) { /*does nothing*/ }
|
||||
|
||||
void announceTestRun(int runNumber)
|
||||
void announceTestRun(unsigned int runNumber)
|
||||
{
|
||||
UnityPrint("Unity test run ");
|
||||
UnityPrintNumber(runNumber+1);
|
||||
@@ -31,7 +31,7 @@ void announceTestRun(int runNumber)
|
||||
int UnityMain(int argc, char* argv[], void (*runAllTests)())
|
||||
{
|
||||
int result = UnityGetCommandLineOptions(argc, argv);
|
||||
int r;
|
||||
unsigned int r;
|
||||
if (result != 0)
|
||||
return result;
|
||||
|
||||
|
||||
@@ -98,10 +98,11 @@ module RakefileHelpers
|
||||
|
||||
def compile(file, defines=[])
|
||||
compiler = build_compiler_fields
|
||||
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " +
|
||||
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" +
|
||||
"#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
||||
execute(cmd_str)
|
||||
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " +
|
||||
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
|
||||
obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
||||
execute(cmd_str + obj_file)
|
||||
return obj_file
|
||||
end
|
||||
|
||||
def build_linker_fields
|
||||
@@ -190,8 +191,7 @@ module RakefileHelpers
|
||||
# Compile corresponding source file if it exists
|
||||
src_file = find_source_file(header, include_dirs)
|
||||
if !src_file.nil?
|
||||
compile(src_file, test_defines)
|
||||
obj_list << header.ext($cfg['compiler']['object_files']['extension'])
|
||||
obj_list << compile(src_file, test_defines)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -210,13 +210,10 @@ module RakefileHelpers
|
||||
options = $cfg[:unity]
|
||||
options[:use_param_tests] = (test =~ /parameterized/) ? true : false
|
||||
UnityTestRunnerGenerator.new(options).run(test, runner_path)
|
||||
|
||||
compile(runner_path, test_defines)
|
||||
obj_list << runner_name.ext($cfg['compiler']['object_files']['extension'])
|
||||
obj_list << compile(runner_path, test_defines)
|
||||
|
||||
# Build the test module
|
||||
compile(test, test_defines)
|
||||
obj_list << test_base.ext($cfg['compiler']['object_files']['extension'])
|
||||
obj_list << compile(test, test_defines)
|
||||
|
||||
# Link the test executable
|
||||
link_it(test_base, obj_list)
|
||||
|
||||
21
src/unity.c
21
src/unity.c
@@ -44,6 +44,9 @@ const _U_UINT UnitySizeMask[] =
|
||||
#endif
|
||||
};
|
||||
|
||||
void UnityPrintFail(void);
|
||||
void UnityPrintOk(void);
|
||||
|
||||
//-----------------------------------------------
|
||||
// Pretty Printers & Test Result Output Handlers
|
||||
//-----------------------------------------------
|
||||
@@ -219,6 +222,18 @@ void UnityPrintFloat(_UF number)
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------
|
||||
|
||||
void UnityPrintFail(void)
|
||||
{
|
||||
UnityPrint("FAIL");
|
||||
}
|
||||
|
||||
void UnityPrintOk(void)
|
||||
{
|
||||
UnityPrint("OK");
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
|
||||
{
|
||||
@@ -880,7 +895,7 @@ void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
|
||||
UNITY_SKIP_EXECUTION;
|
||||
|
||||
UnityTestResultsBegin(Unity.TestFile, line);
|
||||
UnityPrint("FAIL");
|
||||
UnityPrintFail();
|
||||
if (msg != NULL)
|
||||
{
|
||||
UNITY_OUTPUT_CHAR(':');
|
||||
@@ -953,11 +968,11 @@ int UnityEnd(void)
|
||||
UNITY_PRINT_EOL;
|
||||
if (Unity.TestFailures == 0U)
|
||||
{
|
||||
UnityPrint("OK");
|
||||
UnityPrintOk();
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityPrint("FAIL");
|
||||
UnityPrintFail();
|
||||
}
|
||||
UNITY_PRINT_EOL;
|
||||
return Unity.TestFailures;
|
||||
|
||||
@@ -163,11 +163,11 @@ extern int UNITY_OUTPUT_CHAR(int);
|
||||
//-------------------------------------------------------
|
||||
|
||||
#ifndef UNITY_LINE_TYPE
|
||||
#define UNITY_LINE_TYPE unsigned short
|
||||
#define UNITY_LINE_TYPE _U_UINT
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_COUNTER_TYPE
|
||||
#define UNITY_COUNTER_TYPE unsigned short
|
||||
#define UNITY_COUNTER_TYPE _U_UINT
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
@@ -219,7 +219,7 @@ struct _Unity
|
||||
{
|
||||
const char* TestFile;
|
||||
const char* CurrentTestName;
|
||||
_UU32 CurrentTestLineNumber;
|
||||
UNITY_LINE_TYPE CurrentTestLineNumber;
|
||||
UNITY_COUNTER_TYPE NumberOfTests;
|
||||
UNITY_COUNTER_TYPE TestFailures;
|
||||
UNITY_COUNTER_TYPE TestIgnores;
|
||||
|
||||
Reference in New Issue
Block a user