forked from ThrowTheSwitch/Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Examples and main tests can be run on GCC or IAR now
git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@5 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
- Loading branch information
mvandervoord
committed
Oct 29, 2008
1 parent
d1550d8
commit 8fb0204
Showing
6 changed files
with
180 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#This rakefile sets you up to use GCC as your compiler for tests | ||
module RakefileConstants | ||
|
||
C_EXTENSION = '.c' | ||
OBJ_EXTENSION = '.obj' | ||
BIN_EXTENSION = '.exe' | ||
|
||
UNIT_TEST_PATH = 'test' | ||
UNITY_PATH = '../src' | ||
SOURCE_PATH = 'src' | ||
BUILD_PATH = 'build' | ||
|
||
UNITY_SRC = UNITY_PATH + '\unity.c' | ||
UNITY_HDR = UNITY_PATH + '\unity.h' | ||
|
||
COMPILER = 'gcc.exe' | ||
LINKER = 'gcc.exe' | ||
|
||
end | ||
|
||
module RakefileHelpers | ||
include RakefileConstants | ||
|
||
def flush_output | ||
$stderr.flush | ||
$stdout.flush | ||
end | ||
|
||
def report message | ||
puts message | ||
flush_output | ||
end | ||
|
||
def compile src, obj | ||
execute "#{COMPILER} -c -I#{SOURCE_PATH} -I#{UNITY_PATH} -DTEST #{src} -o#{obj}" | ||
end | ||
|
||
def link prerequisites, executable | ||
execute "#{LINKER} -DTEST #{prerequisites.join(' ')} -o#{executable}" | ||
end | ||
|
||
def run_test executable | ||
execute "\"#{executable}\"" | ||
end | ||
|
||
def write_result_file filename, results | ||
if (results.include?("OK\n")) | ||
output_file = filename.gsub(BIN_EXTENSION, '.testpass') | ||
else | ||
output_file = filename.gsub(BIN_EXTENSION, '.testfail') | ||
end | ||
File.open(output_file, 'w') do |f| | ||
f.print results | ||
end | ||
end | ||
|
||
private ##################### | ||
|
||
def execute command_string | ||
report command_string | ||
output = `#{command_string}` | ||
report output | ||
output | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#This rakefile sets you up to use GCC as your compiler for tests | ||
module RakefileConstants | ||
|
||
C_EXTENSION = '.c' | ||
OBJ_EXTENSION = '.obj' | ||
BIN_EXTENSION = '.exe' | ||
|
||
UNIT_TEST_PATH = 'test' | ||
UNITY_PATH = 'src' | ||
SOURCE_PATH = 'src' | ||
BUILD_PATH = 'build' | ||
|
||
UNITY_SRC = UNITY_PATH + '\unity.c' | ||
UNITY_HDR = UNITY_PATH + '\unity.h' | ||
BIN_PATH = 'build' | ||
UNITY_TEST_SRC = UNIT_TEST_PATH + '\testunity.c' | ||
UNITY_TEST_RUNNER_SRC = UNIT_TEST_PATH + '\testunity_Runner.c' | ||
UNITY_OBJ = BIN_PATH + '\unity' + OBJ_EXTENSION | ||
UNITY_TEST_OBJ = BIN_PATH + '\testunity' + OBJ_EXTENSION | ||
UNITY_TEST_RUNNER_OBJ = BIN_PATH + '\testunity_Runner' + OBJ_EXTENSION | ||
UNITY_TEST_EXEC = UNITY_TEST_OBJ.ext BIN_EXTENSION | ||
TEST_RESULTS = UNITY_TEST_OBJ.ext '.testpass' | ||
|
||
COMPILER = 'gcc.exe' | ||
LINKER = 'gcc.exe' | ||
|
||
end | ||
|
||
module RakefileHelpers | ||
include RakefileConstants | ||
|
||
def flush_output | ||
$stderr.flush | ||
$stdout.flush | ||
end | ||
|
||
def report message | ||
puts message | ||
flush_output | ||
end | ||
|
||
def compile src, obj | ||
execute "#{COMPILER} -c -I#{SOURCE_PATH} -I#{UNITY_PATH} -DTEST #{src} -o#{obj}" | ||
end | ||
|
||
def link prerequisites, executable | ||
execute "#{LINKER} -DTEST #{prerequisites.join(' ')} -o#{executable}" | ||
end | ||
|
||
def run_test executable | ||
execute "\"#{executable}\"" | ||
end | ||
|
||
def write_result_file filename, results | ||
if (results.include?("OK\n")) | ||
output_file = filename.gsub(BIN_EXTENSION, '.testpass') | ||
else | ||
output_file = filename.gsub(BIN_EXTENSION, '.testfail') | ||
end | ||
File.open(output_file, 'w') do |f| | ||
f.print results | ||
end | ||
end | ||
|
||
private ##################### | ||
|
||
def execute command_string | ||
report command_string | ||
output = `#{command_string}` | ||
report output | ||
output | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters