提交 d0d5ec5d 编写于 作者: M mvandervoord

- 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
上级 3a82e1ee
...@@ -79,16 +79,17 @@ class UnityTestSummary ...@@ -79,16 +79,17 @@ class UnityTestSummary
end end
def usage(err_msg=nil) def usage(err_msg=nil)
puts "\nERROR: "
puts err_msg if err_msg 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 exit 1
end end
protected protected
@@targets=nil
@@path=nil
@@root=nil
def get_details(result_file, lines) def get_details(result_file, lines)
results = { :failures => [], :ignores => [], :successes => [] } results = { :failures => [], :ignores => [], :successes => [] }
...@@ -117,10 +118,22 @@ class UnityTestSummary ...@@ -117,10 +118,22 @@ class UnityTestSummary
end end
if $0 == __FILE__ if $0 == __FILE__
script = UnityTestSummary.new uts = UnityTestSummary.new
begin 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 rescue Exception => e
script.usage e.message uts.usage e.message
end end
end end
...@@ -87,10 +87,11 @@ module RakefileHelpers ...@@ -87,10 +87,11 @@ module RakefileHelpers
def compile(file, defines=[]) def compile(file, defines=[])
compiler = build_compiler_fields compiler = build_compiler_fields
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " + cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " +
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" + "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
"#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
execute(cmd_str) execute(cmd_str + obj_file)
return obj_file
end end
def build_linker_fields def build_linker_fields
...@@ -181,8 +182,7 @@ module RakefileHelpers ...@@ -181,8 +182,7 @@ module RakefileHelpers
# Compile corresponding source file if it exists # Compile corresponding source file if it exists
src_file = find_source_file(header, include_dirs) src_file = find_source_file(header, include_dirs)
if !src_file.nil? if !src_file.nil?
compile(src_file, test_defines) obj_list << compile(src_file, test_defines)
obj_list << header.ext($cfg['compiler']['object_files']['extension'])
end end
end end
...@@ -197,12 +197,10 @@ module RakefileHelpers ...@@ -197,12 +197,10 @@ module RakefileHelpers
runner_path = $cfg['compiler']['runner_path'] + runner_name runner_path = $cfg['compiler']['runner_path'] + runner_name
end end
compile(runner_path, test_defines) obj_list << compile(runner_path, test_defines)
obj_list << runner_name.ext($cfg['compiler']['object_files']['extension'])
# Build the test module # Build the test module
compile(test, test_defines) obj_list << compile(test, test_defines)
obj_list << test_base.ext($cfg['compiler']['object_files']['extension'])
# Link the test executable # Link the test executable
link_it(test_base, obj_list) link_it(test_base, obj_list)
...@@ -239,15 +237,13 @@ module RakefileHelpers ...@@ -239,15 +237,13 @@ module RakefileHelpers
extract_headers(main_path).each do |header| extract_headers(main_path).each do |header|
src_file = find_source_file(header, include_dirs) src_file = find_source_file(header, include_dirs)
if !src_file.nil? if !src_file.nil?
compile(src_file) obj_list << compile(src_file)
obj_list << header.ext($cfg['compiler']['object_files']['extension'])
end end
end end
# Build the main source file # Build the main source file
main_base = File.basename(main_path, C_EXTENSION) main_base = File.basename(main_path, C_EXTENSION)
compile(main_path) obj_list << compile(main_path)
obj_list << main_base.ext($cfg['compiler']['object_files']['extension'])
# Create the executable # Create the executable
link_it(main_base, obj_list) link_it(main_base, obj_list)
......
...@@ -19,7 +19,7 @@ int verbose = 0; ...@@ -19,7 +19,7 @@ int verbose = 0;
void setUp(void) { /*does nothing*/ } void setUp(void) { /*does nothing*/ }
void tearDown(void) { /*does nothing*/ } void tearDown(void) { /*does nothing*/ }
void announceTestRun(int runNumber) void announceTestRun(unsigned int runNumber)
{ {
UnityPrint("Unity test run "); UnityPrint("Unity test run ");
UnityPrintNumber(runNumber+1); UnityPrintNumber(runNumber+1);
...@@ -31,7 +31,7 @@ void announceTestRun(int runNumber) ...@@ -31,7 +31,7 @@ void announceTestRun(int runNumber)
int UnityMain(int argc, char* argv[], void (*runAllTests)()) int UnityMain(int argc, char* argv[], void (*runAllTests)())
{ {
int result = UnityGetCommandLineOptions(argc, argv); int result = UnityGetCommandLineOptions(argc, argv);
int r; unsigned int r;
if (result != 0) if (result != 0)
return result; return result;
......
...@@ -98,10 +98,11 @@ module RakefileHelpers ...@@ -98,10 +98,11 @@ module RakefileHelpers
def compile(file, defines=[]) def compile(file, defines=[])
compiler = build_compiler_fields compiler = build_compiler_fields
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " + cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " +
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" + "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
"#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
execute(cmd_str) execute(cmd_str + obj_file)
return obj_file
end end
def build_linker_fields def build_linker_fields
...@@ -190,8 +191,7 @@ module RakefileHelpers ...@@ -190,8 +191,7 @@ module RakefileHelpers
# Compile corresponding source file if it exists # Compile corresponding source file if it exists
src_file = find_source_file(header, include_dirs) src_file = find_source_file(header, include_dirs)
if !src_file.nil? if !src_file.nil?
compile(src_file, test_defines) obj_list << compile(src_file, test_defines)
obj_list << header.ext($cfg['compiler']['object_files']['extension'])
end end
end end
...@@ -210,13 +210,10 @@ module RakefileHelpers ...@@ -210,13 +210,10 @@ module RakefileHelpers
options = $cfg[:unity] options = $cfg[:unity]
options[:use_param_tests] = (test =~ /parameterized/) ? true : false options[:use_param_tests] = (test =~ /parameterized/) ? true : false
UnityTestRunnerGenerator.new(options).run(test, runner_path) UnityTestRunnerGenerator.new(options).run(test, runner_path)
obj_list << compile(runner_path, test_defines)
compile(runner_path, test_defines)
obj_list << runner_name.ext($cfg['compiler']['object_files']['extension'])
# Build the test module # Build the test module
compile(test, test_defines) obj_list << compile(test, test_defines)
obj_list << test_base.ext($cfg['compiler']['object_files']['extension'])
# Link the test executable # Link the test executable
link_it(test_base, obj_list) link_it(test_base, obj_list)
......
...@@ -44,6 +44,9 @@ const _U_UINT UnitySizeMask[] = ...@@ -44,6 +44,9 @@ const _U_UINT UnitySizeMask[] =
#endif #endif
}; };
void UnityPrintFail(void);
void UnityPrintOk(void);
//----------------------------------------------- //-----------------------------------------------
// Pretty Printers & Test Result Output Handlers // Pretty Printers & Test Result Output Handlers
//----------------------------------------------- //-----------------------------------------------
...@@ -219,6 +222,18 @@ void UnityPrintFloat(_UF number) ...@@ -219,6 +222,18 @@ void UnityPrintFloat(_UF number)
} }
#endif #endif
//-----------------------------------------------
void UnityPrintFail(void)
{
UnityPrint("FAIL");
}
void UnityPrintOk(void)
{
UnityPrint("OK");
}
//----------------------------------------------- //-----------------------------------------------
void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line) void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
{ {
...@@ -880,7 +895,7 @@ void UnityFail(const char* msg, const UNITY_LINE_TYPE line) ...@@ -880,7 +895,7 @@ void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
UNITY_SKIP_EXECUTION; UNITY_SKIP_EXECUTION;
UnityTestResultsBegin(Unity.TestFile, line); UnityTestResultsBegin(Unity.TestFile, line);
UnityPrint("FAIL"); UnityPrintFail();
if (msg != NULL) if (msg != NULL)
{ {
UNITY_OUTPUT_CHAR(':'); UNITY_OUTPUT_CHAR(':');
...@@ -953,11 +968,11 @@ int UnityEnd(void) ...@@ -953,11 +968,11 @@ int UnityEnd(void)
UNITY_PRINT_EOL; UNITY_PRINT_EOL;
if (Unity.TestFailures == 0U) if (Unity.TestFailures == 0U)
{ {
UnityPrint("OK"); UnityPrintOk();
} }
else else
{ {
UnityPrint("FAIL"); UnityPrintFail();
} }
UNITY_PRINT_EOL; UNITY_PRINT_EOL;
return Unity.TestFailures; return Unity.TestFailures;
......
...@@ -163,11 +163,11 @@ extern int UNITY_OUTPUT_CHAR(int); ...@@ -163,11 +163,11 @@ extern int UNITY_OUTPUT_CHAR(int);
//------------------------------------------------------- //-------------------------------------------------------
#ifndef UNITY_LINE_TYPE #ifndef UNITY_LINE_TYPE
#define UNITY_LINE_TYPE unsigned short #define UNITY_LINE_TYPE _U_UINT
#endif #endif
#ifndef UNITY_COUNTER_TYPE #ifndef UNITY_COUNTER_TYPE
#define UNITY_COUNTER_TYPE unsigned short #define UNITY_COUNTER_TYPE _U_UINT
#endif #endif
//------------------------------------------------------- //-------------------------------------------------------
...@@ -219,7 +219,7 @@ struct _Unity ...@@ -219,7 +219,7 @@ struct _Unity
{ {
const char* TestFile; const char* TestFile;
const char* CurrentTestName; const char* CurrentTestName;
_UU32 CurrentTestLineNumber; UNITY_LINE_TYPE CurrentTestLineNumber;
UNITY_COUNTER_TYPE NumberOfTests; UNITY_COUNTER_TYPE NumberOfTests;
UNITY_COUNTER_TYPE TestFailures; UNITY_COUNTER_TYPE TestFailures;
UNITY_COUNTER_TYPE TestIgnores; UNITY_COUNTER_TYPE TestIgnores;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册