Skip to content

Commit 444fbda

Browse files
committed
refactor self-test engine to match Ceedling's tool format
1 parent 324d062 commit 444fbda

18 files changed

Lines changed: 56 additions & 56 deletions

examples/example_3/rakefile_helper.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@ def build_command_string(tool_hash, values, defines = nil)
9191
args = []
9292
tool_hash[:arguments].each do |arg|
9393
if arg.include?('$')
94-
if arg.include?(': COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE')
94+
if arg.include?('${5}')
95+
all_paths = (($cfg[:paths][:support] || []) + ($cfg[:paths][:source] || []) + ($cfg[:paths][:test] || [])).uniq
96+
all_paths.each { |f| args << arg.gsub('${5}', f) }
97+
98+
elsif arg.include?('${6}')
99+
(($cfg.dig(:defines, :test) || []) + Array(defines)).uniq.compact.each { |f| args << arg.gsub('${6}', f) }
100+
101+
elsif arg.include?(': COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE')
95102
pattern = arg.gsub(': COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE', '')
96103
($cfg[:paths][:support] || []).each { |f| args << pattern.gsub(/\$/, f) }
97104

test/rakefile_helper.rb

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ module RakefileHelpers
1616
def load_configuration(config_file)
1717
return if $configured
1818

19-
unless config_file =~ /[\\|\/]/
19+
if config_file =~ /[\\|\/]/
20+
$cfg_file = config_file
21+
else
2022
$cfg_file_base = config_file
21-
$cfg_file = "targets/#{config_file}"
23+
$cfg_file = "targets/#{config_file}"
2224
end
2325
$cfg = YamlHelper.load_file($cfg_file)
2426
$cfg[:paths] ||= {}
25-
$cfg[:paths][:test] ||= ['src/', '../src/', 'testdata/', 'tests/']
27+
$cfg[:paths][:test] = (Array($cfg[:paths][:test]) + ['src/', '../src/', 'testdata/', 'tests/']).uniq
2628
$colour_output = false unless $cfg['colour']
2729
$configured = true if config_file != DEFAULT_CONFIG_FILE
2830
end
@@ -101,7 +103,14 @@ def build_command_string(hash, values, defines = nil)
101103
args = []
102104
hash[:arguments].each do |arg|
103105
if arg.include? '$'
104-
if arg.include? ': COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
106+
if arg.include? '${5}'
107+
all_paths = [ File.join('..','src'), $extra_paths, 'src', File.join('tests'), File.join('testdata'), $cfg[:paths][:support] ].flatten.uniq.compact
108+
all_paths.each { |f| args << arg.gsub('${5}', f) }
109+
110+
elsif arg.include? '${6}'
111+
[ $cfg[:defines][:test], $cfg.dig(:unity, :defines), defines ].flatten.uniq.compact.each { |f| args << arg.gsub('${6}', f) }
112+
113+
elsif arg.include? ': COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
105114
pattern = arg.gsub(': COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE','')
106115
[ File.join('..','src') ].each do |f|
107116
args << pattern.gsub(/\$/,f)
@@ -115,7 +124,7 @@ def build_command_string(hash, values, defines = nil)
115124

116125
elsif arg.include? ': COLLECTION_DEFINES_TEST_AND_VENDOR'
117126
pattern = arg.gsub(': COLLECTION_DEFINES_TEST_AND_VENDOR','')
118-
[ $cfg[:defines][:test], defines ].flatten.uniq.compact.each do |f|
127+
[ $cfg[:defines][:test], $cfg.dig(:unity, :defines), defines ].flatten.uniq.compact.each do |f|
119128
args << pattern.gsub(/\$/,f)
120129
end
121130

@@ -141,7 +150,7 @@ def build_command_string(hash, values, defines = nil)
141150
end
142151

143152
def compile(file, defines = [])
144-
out_file = File.join('build', File.basename(file, C_EXTENSION)) + $cfg[:extension][:object]
153+
out_file = File.join('build', File.basename(file, C_EXTENSION)) + ($cfg[:extension][:object] || '.o')
145154
cmd_str = build_command_string( $cfg[:tools][:test_compiler], [ file, out_file ], defines )
146155
execute(cmd_str)
147156
out_file
@@ -170,7 +179,7 @@ def run_astyle(style_what)
170179
"--style=allman --indent=spaces=4 --indent-switches --indent-preproc-define --indent-preproc-block " \
171180
"--pad-oper --pad-comma --unpad-paren --pad-header " \
172181
"--align-pointer=type --align-reference=name " \
173-
"--add-brackets --mode=c --suffix=none " \
182+
"--mode=c --suffix=none " \
174183
"#{style_what}"
175184
execute(command, false)
176185
report "Styling C:PASS"

test/targets/clang_file.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@
4747
- "-std=gnu99"
4848
- "-pedantic"
4949
- "-O0"
50-
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
51-
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
52-
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
50+
- '-I"${5}"'
51+
- "-D${6}"
5352
- "${1}"
5453
- "-o ${2}"
5554
:test_linker:

test/targets/clang_strict.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@
4646
- "-std=gnu99"
4747
- "-pedantic"
4848
- "-O0"
49-
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
50-
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
51-
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
49+
- '-I"${5}"'
50+
- "-D${6}"
5251
- "${1}"
5352
- "-o ${2}"
5453
:test_linker:

test/targets/gcc_32.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
- "-Wno-address"
1818
- "-std=c99"
1919
- "-pedantic"
20-
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
21-
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
22-
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
20+
- '-I"${5}"'
21+
- "-D${6}"
2322
- "${1}"
2423
- "-o ${2}"
2524
:test_linker:

test/targets/gcc_64.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
- "-Wno-address"
1818
- "-std=c99"
1919
- "-pedantic"
20-
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
21-
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
22-
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
20+
- '-I"${5}"'
21+
- "-D${6}"
2322
- "${1}"
2423
- "-o ${2}"
2524
:test_linker:

test/targets/gcc_64_ansi.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
- "-Wall"
1919
- "-Wno-address"
2020
- "-ansi"
21-
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
22-
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
23-
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
21+
- '-I"${5}"'
22+
- "-D${6}"
2423
- "${1}"
2524
- "-o ${2}"
2625
:test_linker:

test/targets/gcc_64_auto_limits.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
- "-Wno-address"
1818
- "-std=c99"
1919
- "-pedantic"
20-
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
21-
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
22-
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
20+
- '-I"${5}"'
21+
- "-D${6}"
2322
- "${1}"
2423
- "-o ${2}"
2524
:test_linker:

test/targets/gcc_64_auto_stdint.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@
3030
- "-Wstrict-prototypes"
3131
- "-Wundef"
3232
- "-Wold-style-definition"
33-
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
34-
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
35-
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
33+
- '-I"${5}"'
34+
- "-D${6}"
3635
- "${1}"
3736
- "-o ${2}"
3837
:test_linker:

test/targets/gcc_64_manual_math.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
- "-Wno-address"
1818
- "-std=c99"
1919
- "-pedantic"
20-
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
21-
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
22-
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
20+
- '-I"${5}"'
21+
- "-D${6}"
2322
- "${1}"
2423
- "-o ${2}"
2524
:test_linker:

0 commit comments

Comments
 (0)