mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-23 08:25:58 +01:00
- added hitech_picc18 sample target
- added ability to do suite_setup and suite_teardown to runner git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@94 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
This commit is contained in:
@@ -12,8 +12,8 @@ class UnityTestRunnerGenerator
|
||||
@options = { :includes => [], :framework => :unity }
|
||||
case(options)
|
||||
when NilClass then @options
|
||||
when String then @options = UnityTestRunnerGenerator.grab_config(options)
|
||||
when Hash then @options = options
|
||||
when String then @options.merge!(UnityTestRunnerGenerator.grab_config(options))
|
||||
when Hash then @options.merge!(options)
|
||||
else raise "If you specify arguments, it should be a filename or a hash of options"
|
||||
end
|
||||
end
|
||||
@@ -54,6 +54,7 @@ class UnityTestRunnerGenerator
|
||||
create_header(output, used_mocks)
|
||||
create_externs(output, tests, used_mocks)
|
||||
create_mock_management(output, used_mocks)
|
||||
create_suite_setup_and_teardown(output)
|
||||
create_runtest(output, used_mocks)
|
||||
create_reset(output, used_mocks)
|
||||
create_main(output, input_file, tests)
|
||||
@@ -180,6 +181,20 @@ class UnityTestRunnerGenerator
|
||||
end
|
||||
end
|
||||
|
||||
def create_suite_setup_and_teardown(output)
|
||||
unless (@options[:suite_setup].nil?)
|
||||
output.puts("static int suite_setup(void)")
|
||||
output.puts("{")
|
||||
output.puts(@options[:suite_setup])
|
||||
output.puts("}")
|
||||
end
|
||||
unless (@options[:suite_teardown].nil?)
|
||||
output.puts("static int suite_teardown(int num_failures)")
|
||||
output.puts("{")
|
||||
output.puts(@options[:suite_teardown])
|
||||
output.puts("}")
|
||||
end
|
||||
end
|
||||
|
||||
def create_runtest(output, used_mocks)
|
||||
output.puts("static void runTest(UnityTestFunction test)")
|
||||
@@ -218,17 +233,16 @@ class UnityTestRunnerGenerator
|
||||
output.puts()
|
||||
output.puts("int main(void)")
|
||||
output.puts("{")
|
||||
output.puts(" suite_setup();") unless @options[:suite_setup].nil?
|
||||
output.puts(" Unity.TestFile = \"#{filename}\";")
|
||||
output.puts(" UnityBegin();")
|
||||
output.puts()
|
||||
|
||||
output.puts(" // RUN_TEST calls runTest")
|
||||
output.puts(" // RUN_TEST calls runTest")
|
||||
tests.each do |test|
|
||||
output.puts(" RUN_TEST(#{test[:name]}, #{test[:line_number]});")
|
||||
end
|
||||
|
||||
output.puts()
|
||||
output.puts(" return UnityEnd();")
|
||||
output.puts(" return #{@options[:suite_teardown].nil? ? "" : "suite_teardown"}(UnityEnd());")
|
||||
output.puts("}")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -205,6 +205,7 @@ module RakefileHelpers
|
||||
runner_path = $cfg['compiler']['runner_path'] + runner_name
|
||||
end
|
||||
|
||||
#UnityTestRunnerGenerator.new(:suite_setup => 'puts("\nStarting Test Suite!\n");', :suite_teardown => 'return num_failures;').run(test, runner_path)
|
||||
UnityTestRunnerGenerator.new.run(test, runner_path)
|
||||
|
||||
compile(runner_path, test_defines)
|
||||
|
||||
96
targets/hitech_picc18.yml
Normal file
96
targets/hitech_picc18.yml
Normal file
@@ -0,0 +1,96 @@
|
||||
compiler:
|
||||
path: cd build && picc18
|
||||
source_path: 'c:\Projects\NexGen\Prototypes\CMockTest\src\'
|
||||
unit_tests_path: &unit_tests_path 'c:\Projects\NexGen\Prototypes\CMockTest\test\'
|
||||
build_path: &build_path 'c:\Projects\NexGen\Prototypes\CMockTest\build\'
|
||||
options:
|
||||
- --chip=18F87J10
|
||||
- --ide=hitide
|
||||
- --please
|
||||
- --asmlist
|
||||
- --codeoffset=0
|
||||
- --emi=wordwrite # External memory interface protocol
|
||||
- --warn=0 # allow all normal warning messages
|
||||
- --errors=10 # Number of errors before aborting compile
|
||||
- --char=unsigned
|
||||
- -Bl # Large memory model
|
||||
- -G # generate symbol file
|
||||
- --cp=24 # 24-bit pointers
|
||||
- --double=24
|
||||
- -N255 # 255-char symbol names
|
||||
- --opt=none # Do not use any compiler optimziations
|
||||
- -c # compile only
|
||||
includes:
|
||||
prefix: '-I'
|
||||
items:
|
||||
- 'c:/Projects/NexGen/Prototypes/CMockTest/src/'
|
||||
- 'c:/Projects/NexGen/Prototypes/CMockTest/mocks/'
|
||||
- 'c:/CMock/src/'
|
||||
- 'c:/CMock/examples/src/'
|
||||
- 'c:/CMock/vendor/unity/src/'
|
||||
- 'c:/CMock/vendor/unity/examples/helper/'
|
||||
- *unit_tests_path
|
||||
defines:
|
||||
prefix: '-D'
|
||||
items:
|
||||
- UNITY_INT_WIDTH=16
|
||||
- UNITY_POINTER_WIDTH=32
|
||||
- CMOCK_MEM_STATIC
|
||||
- CMOCK_MEM_SIZE=3000
|
||||
- __PICC18__
|
||||
object_files:
|
||||
# prefix: '-O' # Hi-Tech doesn't want a prefix. They key off of filename .extensions, instead
|
||||
extension: '.obj'
|
||||
destination: *build_path
|
||||
|
||||
linker:
|
||||
path: cd build && picc18
|
||||
options:
|
||||
- --chip=18F87J10
|
||||
- --ide=hitide
|
||||
- --cp=24 # 24-bit pointers. Is this needed for linker??
|
||||
- --double=24 # Is this needed for linker??
|
||||
- -Lw # Scan the pic87*w.lib in the lib/ of the compiler installation directory
|
||||
- --summary=mem,file # info listing
|
||||
- --summary=+psect
|
||||
- --summary=+hex
|
||||
- --output=+intel
|
||||
- --output=+mcof
|
||||
- --runtime=+init # Directs startup code to copy idata, ibigdata and ifardata psects from ROM to RAM.
|
||||
- --runtime=+clear # Directs startup code to clear bss, bigbss, rbss and farbss psects
|
||||
- --runtime=+clib # link in the c-runtime
|
||||
- --runtime=+keep # Keep the generated startup src after its obj is linked
|
||||
- -G # Generate src-level symbol file
|
||||
- -MIWasTheLastToBuild.map
|
||||
- --warn=0 # allow all normal warning messages
|
||||
- -Bl # Large memory model (probably not needed for linking)
|
||||
includes:
|
||||
prefix: '-I'
|
||||
object_files:
|
||||
path: *build_path
|
||||
extension: '.obj'
|
||||
bin_files:
|
||||
prefix: '-O'
|
||||
extension: '.hex'
|
||||
destination: *build_path
|
||||
|
||||
simulator:
|
||||
path:
|
||||
pre_support:
|
||||
- 'java -client -jar ' # note space
|
||||
- ['C:\Program Files\HI-TECH Software\HI-TIDE\3.15\lib\', 'simpic18.jar']
|
||||
- 18F87J10
|
||||
post_support:
|
||||
|
||||
:cmock:
|
||||
:plugins: []
|
||||
:includes:
|
||||
- Types.h
|
||||
:suite_teardown: |
|
||||
if (num_failures)
|
||||
_FAILED_TEST();
|
||||
else
|
||||
_PASSED_TESTS();
|
||||
return 0;
|
||||
|
||||
colour: true
|
||||
Reference in New Issue
Block a user