ceedling 0.24.0 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ceedling +6 -1
- data/docs/CeedlingPacket.md +9 -0
- data/lib/ceedling/generator.rb +2 -2
- data/lib/ceedling/generator_test_runner.rb +32 -1
- data/lib/ceedling/rakefile.rb +1 -1
- data/lib/ceedling/system_wrapper.rb +13 -10
- data/lib/ceedling/tool_executor.rb +2 -2
- data/lib/ceedling/version.rb +1 -1
- data/plugins/command_hooks/README.md +52 -0
- data/plugins/command_hooks/lib/command_hooks.rb +71 -0
- data/plugins/module_generator/lib/module_generator.rb +10 -4
- data/plugins/module_generator/module_generator.rake +2 -2
- data/spec/spec_system_helper.rb +16 -11
- data/spec/system/deployment_spec.rb +2 -2
- data/vendor/c_exception/vendor/unity/auto/generate_module.rb +77 -34
- data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +1 -1
- data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +2 -2
- data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +3 -3
- data/vendor/c_exception/vendor/unity/src/unity.c +105 -105
- data/vendor/c_exception/vendor/unity/src/unity.h +8 -8
- data/vendor/c_exception/vendor/unity/src/unity_internals.h +139 -139
- data/vendor/c_exception/vendor/unity/test/tests/testunity.c +141 -142
- data/vendor/cmock/lib/cmock_generator.rb +2 -1
- data/vendor/cmock/test/c/TestCMockC.c +1 -1
- data/vendor/cmock/test/system/test_interactions/unity_64bit_support.yml +13 -13
- data/vendor/cmock/test/unit/cmock_generator_main_test.rb +4 -2
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_module.rb +77 -34
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +2 -2
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +3 -3
- data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.c +105 -105
- data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.h +8 -8
- data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity_internals.h +139 -139
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/testunity.c +141 -142
- data/vendor/cmock/vendor/unity/auto/generate_module.rb +77 -34
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.c +1 -1
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_internals.h +2 -2
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_Test.c +3 -3
- data/vendor/cmock/vendor/unity/src/unity.c +105 -105
- data/vendor/cmock/vendor/unity/src/unity.h +8 -8
- data/vendor/cmock/vendor/unity/src/unity_internals.h +139 -139
- data/vendor/cmock/vendor/unity/test/tests/testunity.c +141 -142
- data/vendor/unity/auto/generate_module.rb +77 -34
- data/vendor/unity/extras/fixture/src/unity_fixture.c +1 -1
- data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +2 -2
- data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +3 -3
- data/vendor/unity/src/unity.c +105 -105
- data/vendor/unity/src/unity.h +8 -8
- data/vendor/unity/src/unity_internals.h +139 -139
- data/vendor/unity/test/tests/testunity.c +141 -142
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 373d6a4981555897351460b57dc82e3d90a96d6d
|
4
|
+
data.tar.gz: ff091c1e3c1934718eb19fcab984c3bc169f5b92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0feea9fe999980ad018ea2ec89fb0af54537d3ed1b9b029fa24148f4d7c25fabdf4392a896723046a7b0af46533b8187fa2be902cf3a7a3d6fa633863294122e
|
7
|
+
data.tar.gz: 790254af22bb0d7d28efd37ed3df4d5de2aba82589c0c52abf585ad7732ea43dbff283e861286f34d865acb21870f9aeb25456d6897253a1085a3271d9d718a6
|
data/bin/ceedling
CHANGED
@@ -193,7 +193,12 @@ else
|
|
193
193
|
|
194
194
|
#if neither of these libraries were available, we can just shell out to the command and collect results
|
195
195
|
def spawn_command(cmd, &block)
|
196
|
-
|
196
|
+
results = `#{cmd}`
|
197
|
+
if ($?.exitstatus != 0)
|
198
|
+
block.call( StringIO.new("ERROR: Aborted with Exit Code #{$?.exitstatus.to_s}") )
|
199
|
+
else
|
200
|
+
block.call( StringIO.new(results) )
|
201
|
+
end
|
197
202
|
end
|
198
203
|
end
|
199
204
|
|
data/docs/CeedlingPacket.md
CHANGED
@@ -322,6 +322,15 @@ Ceedling (more on this later).
|
|
322
322
|
Sometimes you just need to assemble a single file doggonit. Example:
|
323
323
|
ceedling release:assemble:foo.s
|
324
324
|
|
325
|
+
* `ceedling module:create[Filename]`:
|
326
|
+
|
327
|
+
It's often helpful to create a file automatically. What's better than
|
328
|
+
that? Creating a source file, a header file, and a corresponding test
|
329
|
+
file all in one step!
|
330
|
+
|
331
|
+
There are also patterns which can be specified to automatically generate
|
332
|
+
a bunch of files. Try `ceedling module:create[Poodles,mch]` for example!
|
333
|
+
|
325
334
|
* `ceedling logging <tasks...>`:
|
326
335
|
|
327
336
|
Enable logging to <build path>/logs. Must come before test and release
|
data/lib/ceedling/generator.rb
CHANGED
@@ -95,7 +95,7 @@ class Generator
|
|
95
95
|
shell_result = @tool_executor.exec( command[:line], command[:options] )
|
96
96
|
rescue ShellExecutionException => ex
|
97
97
|
shell_result = ex.shell_result
|
98
|
-
raise
|
98
|
+
raise ex
|
99
99
|
ensure
|
100
100
|
arg_hash[:shell_result] = shell_result
|
101
101
|
@plugin_manager.post_compile_execute(arg_hash)
|
@@ -149,7 +149,7 @@ class Generator
|
|
149
149
|
command = @tool_executor.build_command_line(arg_hash[:tool], [], arg_hash[:executable])
|
150
150
|
command[:options][:boom] = false
|
151
151
|
shell_result = @tool_executor.exec( command[:line], command[:options] )
|
152
|
-
|
152
|
+
shell_result[:exit_code] = 0 #Don't Let The Failure Count Make Us Believe Things Aren't Working
|
153
153
|
@generator_helper.test_results_error_handler(executable, shell_result)
|
154
154
|
|
155
155
|
processed = @generator_test_results.process_and_write_results( shell_result,
|
@@ -4,13 +4,44 @@ class GeneratorTestRunner
|
|
4
4
|
constructor :configurator, :file_path_utils, :file_wrapper
|
5
5
|
|
6
6
|
def find_test_cases(test_file)
|
7
|
+
|
8
|
+
#Pull in Unity's Test Runner Generator
|
7
9
|
require 'generate_test_runner.rb'
|
8
10
|
@test_runner_generator ||= UnityTestRunnerGenerator.new( @configurator.get_runner_config )
|
9
|
-
|
11
|
+
|
12
|
+
if (@configurator.project_use_test_preprocessor)
|
13
|
+
|
14
|
+
#redirect to use the preprocessor file if we're doing that sort of thing
|
15
|
+
pre_test_file = @file_path_utils.form_preprocessed_file_filepath(test_file)
|
16
|
+
|
17
|
+
#actually look for the tests using Unity's test runner generator
|
18
|
+
tests_and_line_numbers = @test_runner_generator.find_tests(@file_wrapper.read(pre_test_file))
|
19
|
+
|
20
|
+
#look up the line numbers in the original file
|
21
|
+
source_lines = @file_wrapper.read(test_file).split("\n")
|
22
|
+
source_index = 0;
|
23
|
+
tests_and_line_numbers.size.times do |i|
|
24
|
+
source_lines[source_index..-1].each_with_index do |line, index|
|
25
|
+
if (line =~ /#{tests_and_line_numbers[i][:test]}/)
|
26
|
+
source_index += index
|
27
|
+
tests_and_line_numbers[i][:line_number] = source_index + 1
|
28
|
+
break
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
else
|
33
|
+
#Just look for the tests using Unity's test runner generator
|
34
|
+
tests_and_line_numbers = @test_runner_generator.find_tests(@file_wrapper.read(test_file))
|
35
|
+
end
|
36
|
+
|
37
|
+
return tests_and_line_numbers
|
10
38
|
end
|
11
39
|
|
12
40
|
def generate(module_name, runner_filepath, test_cases, mock_list, test_file_includes=[])
|
13
41
|
require 'generate_test_runner.rb'
|
42
|
+
|
43
|
+
#actually build the test runner using Unity's test runner generator
|
44
|
+
#(there is no need to use preprocessor here because we've already looked up test cases and are passing them in here)
|
14
45
|
@test_runner_generator ||= UnityTestRunnerGenerator.new( @configurator.get_runner_config )
|
15
46
|
@test_runner_generator.generate( module_name,
|
16
47
|
runner_filepath,
|
data/lib/ceedling/rakefile.rb
CHANGED
@@ -73,6 +73,6 @@ END {
|
|
73
73
|
# tell all our plugins the build is done and process results
|
74
74
|
@ceedling[:plugin_manager].post_build
|
75
75
|
@ceedling[:plugin_manager].print_plugin_failures
|
76
|
-
exit(1) if (@ceedling[:plugin_manager].plugins_failed?)
|
76
|
+
#exit(1) if (@ceedling[:plugin_manager].plugins_failed?) #do NOT call this. It will keep caller from reporting failures
|
77
77
|
end
|
78
78
|
}
|
@@ -12,7 +12,7 @@ class SystemWrapper
|
|
12
12
|
def windows?
|
13
13
|
return SystemWrapper.windows?
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def module_eval(string)
|
17
17
|
return Object.module_eval("\"" + string + "\"")
|
18
18
|
end
|
@@ -32,7 +32,7 @@ class SystemWrapper
|
|
32
32
|
def env_set(name, value)
|
33
33
|
ENV[name] = value
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def env_get(name)
|
37
37
|
return ENV[name]
|
38
38
|
end
|
@@ -41,36 +41,39 @@ class SystemWrapper
|
|
41
41
|
return Time.now.asctime
|
42
42
|
end
|
43
43
|
|
44
|
-
def shell_backticks(command)
|
44
|
+
def shell_backticks(command, boom = true)
|
45
|
+
retval = `#{command}`.freeze
|
46
|
+
$exit_code = ($?.exitstatus).freeze if boom
|
45
47
|
return {
|
46
|
-
:output =>
|
48
|
+
:output => retval.freeze,
|
47
49
|
:exit_code => ($?.exitstatus).freeze
|
48
50
|
}
|
49
51
|
end
|
50
52
|
|
51
|
-
def shell_system(command)
|
53
|
+
def shell_system(command, boom = true)
|
52
54
|
system( command )
|
55
|
+
$exit_code = ($?.exitstatus).freeze if boom
|
53
56
|
return {
|
54
|
-
:output =>
|
57
|
+
:output => "".freeze,
|
55
58
|
:exit_code => ($?.exitstatus).freeze
|
56
59
|
}
|
57
60
|
end
|
58
|
-
|
61
|
+
|
59
62
|
def add_load_path(path)
|
60
63
|
$LOAD_PATH.unshift(path)
|
61
64
|
end
|
62
|
-
|
65
|
+
|
63
66
|
def require_file(path)
|
64
67
|
require(path)
|
65
68
|
end
|
66
69
|
|
67
70
|
def ruby_success
|
68
|
-
return ($!.nil? || $!.is_a?(SystemExit) && $!.success?)
|
71
|
+
return ($exit_code == 0) && ($!.nil? || $!.is_a?(SystemExit) && $!.success?)
|
69
72
|
end
|
70
73
|
|
71
74
|
def constants_include?(item)
|
72
75
|
# forcing to strings provides consistency across Ruby versions
|
73
76
|
return Object.constants.map{|constant| constant.to_s}.include?(item.to_s)
|
74
77
|
end
|
75
|
-
|
78
|
+
|
76
79
|
end
|
@@ -63,9 +63,9 @@ class ToolExecutor
|
|
63
63
|
|
64
64
|
# depending on background exec option, we shell out differently
|
65
65
|
if (options[:background_exec] != BackgroundExec::NONE)
|
66
|
-
shell_result = @system_wrapper.shell_system( command_line )
|
66
|
+
shell_result = @system_wrapper.shell_system( command_line, options[:boom] )
|
67
67
|
else
|
68
|
-
shell_result = @system_wrapper.shell_backticks( command_line )
|
68
|
+
shell_result = @system_wrapper.shell_backticks( command_line, options[:boom] )
|
69
69
|
end
|
70
70
|
|
71
71
|
#scrub the string for illegal output
|
data/lib/ceedling/version.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
ceedling-command-hooks
|
2
|
+
======================
|
3
|
+
|
4
|
+
Plugin for easily calling command line tools at various points in the build process
|
5
|
+
|
6
|
+
Define any of these sections in :tools: to provide additional hooks to be called on demand:
|
7
|
+
|
8
|
+
```
|
9
|
+
:pre_mock_generate
|
10
|
+
:post_mock_generate
|
11
|
+
:pre_runner_generate
|
12
|
+
:post_runner_generate
|
13
|
+
:pre_compile_execute
|
14
|
+
:post_compile_execute
|
15
|
+
:pre_link_execute
|
16
|
+
:post_link_execute
|
17
|
+
:pre_test_fixture_execute
|
18
|
+
:pre_test_fixture_execute
|
19
|
+
:pre_test
|
20
|
+
:post_test
|
21
|
+
:pre_release
|
22
|
+
:post_release
|
23
|
+
:pre_build
|
24
|
+
:post_build
|
25
|
+
```
|
26
|
+
|
27
|
+
Each of these tools can support an :executable string and an :args list, like so:
|
28
|
+
|
29
|
+
```
|
30
|
+
:tools:
|
31
|
+
:post_link_execute:
|
32
|
+
:executable: objcopy.exe
|
33
|
+
:args:
|
34
|
+
- ${1} #This is replaced with the executable name
|
35
|
+
- output.srec
|
36
|
+
- --strip-all
|
37
|
+
```
|
38
|
+
|
39
|
+
You may also specify an array of executables to be called in a particular place, like so:
|
40
|
+
|
41
|
+
```
|
42
|
+
:tools:
|
43
|
+
:post_test:
|
44
|
+
- :executable: echo
|
45
|
+
:args: "${1} was glorious!"
|
46
|
+
- :executable: echo
|
47
|
+
:args:
|
48
|
+
- it kinda made me cry a little.
|
49
|
+
- you?
|
50
|
+
```
|
51
|
+
|
52
|
+
Happy Tweaking!
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'ceedling/plugin'
|
2
|
+
require 'ceedling/constants'
|
3
|
+
|
4
|
+
class CommandHooks < Plugin
|
5
|
+
|
6
|
+
attr_reader :config
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@config = {
|
10
|
+
:pre_mock_generate => ((defined? TOOLS_PRE_MOCK_GENERATE) ? TOOLS_PRE_MOCK_GENERATE : nil ),
|
11
|
+
:post_mock_generate => ((defined? TOOLS_POST_MOCK_GENERATE) ? TOOLS_POST_MOCK_GENERATE : nil ),
|
12
|
+
:pre_runner_generate => ((defined? TOOLS_PRE_RUNNER_GENERATE) ? TOOLS_PRE_RUNNER_GENERATE : nil ),
|
13
|
+
:post_runner_generate => ((defined? TOOLS_POST_RUNNER_GENERATE) ? TOOLS_POST_RUNNER_GENERATE : nil ),
|
14
|
+
:pre_compile_execute => ((defined? TOOLS_PRE_COMPILE_EXECUTE) ? TOOLS_PRE_COMPILE_EXECUTE : nil ),
|
15
|
+
:post_compile_execute => ((defined? TOOLS_POST_COMPILE_EXECUTE) ? TOOLS_POST_COMPILE_EXECUTE : nil ),
|
16
|
+
:pre_link_execute => ((defined? TOOLS_PRE_LINK_EXECUTE) ? TOOLS_PRE_LINK_EXECUTE : nil ),
|
17
|
+
:post_link_execute => ((defined? TOOLS_POST_LINK_EXECUTE) ? TOOLS_POST_LINK_EXECUTE : nil ),
|
18
|
+
:pre_test_fixture_execute => ((defined? TOOLS_PRE_TEST_FIXTURE_EXECUTE) ? TOOLS_PRE_TEST_FIXTURE_EXECUTE : nil ),
|
19
|
+
:post_test_fixture_execute => ((defined? TOOLS_POST_TEST_FIXTURE_EXECUTE) ? TOOLS_POST_TEST_FIXTURE_EXECUTE : nil ),
|
20
|
+
:pre_test => ((defined? TOOLS_PRE_TEST) ? TOOLS_PRE_TEST : nil ),
|
21
|
+
:post_test => ((defined? TOOLS_POST_TEST) ? TOOLS_POST_TEST : nil ),
|
22
|
+
:pre_release => ((defined? TOOLS_PRE_RELEASE) ? TOOLS_PRE_RELEASE : nil ),
|
23
|
+
:post_release => ((defined? TOOLS_POST_RELEASE) ? TOOLS_POST_RELEASE : nil ),
|
24
|
+
:pre_build => ((defined? TOOLS_PRE_BUILD) ? TOOLS_PRE_BUILD : nil ),
|
25
|
+
:post_build => ((defined? TOOLS_POST_BUILD) ? TOOLS_POST_BUILD : nil ),
|
26
|
+
}
|
27
|
+
@plugin_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
28
|
+
end
|
29
|
+
|
30
|
+
def pre_mock_generate(arg_hash); run_hook(:pre_mock_generate, arg_hash[:header_file] ); end
|
31
|
+
def post_mock_generate(arg_hash); run_hook(:post_mock_generate, arg_hash[:header_file] ); end
|
32
|
+
def pre_runner_generate(arg_hash); run_hook(:pre_runner_generate, arg_hash[:source ] ); end
|
33
|
+
def post_runner_generate(arg_hash); run_hook(:post_runner_generate, arg_hash[:runner_file] ); end
|
34
|
+
def pre_compile_execute(arg_hash); run_hook(:pre_compile_execute, arg_hash[:source_file] ); end
|
35
|
+
def post_compile_execute(arg_hash); run_hook(:post_compile_execute, arg_hash[:object_file] ); end
|
36
|
+
def pre_link_execute(arg_hash); run_hook(:pre_link_execute, arg_hash[:executable] ); end
|
37
|
+
def post_link_execute(arg_hash); run_hook(:post_link_execute, arg_hash[:executable] ); end
|
38
|
+
def pre_test_fixture_execute(arg_hash); run_hook(:pre_test_fixture_execute, arg_hash[:executable] ); end
|
39
|
+
def post_test_fixture_execute(arg_hash); run_hook(:post_test_fixture_execute, arg_hash[:executable] ); end
|
40
|
+
def pre_test(test); run_hook(:pre_test, test ); end
|
41
|
+
def post_test(test); run_hook(:post_test, test ); end
|
42
|
+
def pre_release; run_hook(:pre_release ); end
|
43
|
+
def post_release; run_hook(:post_release ); end
|
44
|
+
def pre_build; run_hook(:pre_build ); end
|
45
|
+
def post_build; run_hook(:post_build ); end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def run_hook_step(hook, name)
|
50
|
+
if (hook[:executable])
|
51
|
+
cmd = @ceedling[:tool_executor].build_command_line( hook, [], name )
|
52
|
+
shell_result = @ceedling[:tool_executor].exec( cmd[:line], cmd[:options] )
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def run_hook(which_hook, name="")
|
57
|
+
if (@config[which_hook])
|
58
|
+
@ceedling[:streaminator].stdout_puts("Running Hook #{which_hook}...", Verbosity::NORMAL)
|
59
|
+
if (@config[which_hook].is_a? Array)
|
60
|
+
@config[which_hook].each do |hook|
|
61
|
+
run_hook_step(hook, name)
|
62
|
+
end
|
63
|
+
elsif (@config[which_hook].is_a? Hash)
|
64
|
+
run_hook_step( @config[which_hook], name )
|
65
|
+
else
|
66
|
+
@ceedling[:streaminator].stdout_puts("Hook #{which_hook} was poorly formed", Verbosity::COMPLAINT)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
@@ -22,10 +22,16 @@ class ModuleGenerator < Plugin
|
|
22
22
|
|
23
23
|
def divine_options(optz={})
|
24
24
|
{
|
25
|
-
:path_src
|
26
|
-
:path_inc
|
27
|
-
:path_tst
|
28
|
-
:pattern
|
25
|
+
:path_src => ((defined? MODULE_GENERATOR_SOURCE_ROOT ) ? MODULE_GENERATOR_SOURCE_ROOT.gsub('\\', '/').sub(/^\//, '').sub(/\/$/, '') : "src" ),
|
26
|
+
:path_inc => ((defined? MODULE_GENERATOR_SOURCE_ROOT ) ? MODULE_GENERATOR_SOURCE_ROOT.gsub('\\', '/').sub(/^\//, '').sub(/\/$/, '') : "src" ),
|
27
|
+
:path_tst => ((defined? MODULE_GENERATOR_TEST_ROOT ) ? MODULE_GENERATOR_TEST_ROOT.gsub( '\\', '/').sub(/^\//, '').sub(/\/$/, '') : "test" ),
|
28
|
+
:pattern => optz[:pattern],
|
29
|
+
:test_prefix => ((defined? PROJECT_TEST_FILE_PREFIX ) ? PROJECT_TEST_FILE_PREFIX : "Test" ),
|
30
|
+
:mock_prefix => ((defined? CMOCK_MOCK_PREFIX ) ? CMOCK_MOCK_PREFIX : "Mock" ),
|
31
|
+
:includes => ((defined? MODULE_GENERATOR_INCLUDES ) ? MODULE_GENERATOR_INCLUDES : {} ),
|
32
|
+
:boilerplates => ((defined? MODULE_GENERATOR_BOILERPLATES) ? MODULE_GENERATOR_BOILERPLATES : {} ),
|
33
|
+
:naming => ((defined? MODULE_GENERATOR_NAMING ) ? MODULE_GENERATOR_NAMING : "snake" ),
|
34
|
+
:update_svn => ((defined? MODULE_GENERATOR_UPDATE_SVN ) ? MODULE_GENERATOR_UPDATE_SVN : false ),
|
29
35
|
}
|
30
36
|
end
|
31
37
|
|
@@ -5,7 +5,7 @@ namespace :module do
|
|
5
5
|
task :create, :module_path do |t, args|
|
6
6
|
files = [args[:module_path]] + (args.extras || [])
|
7
7
|
optz = {}
|
8
|
-
["dh", "dih", "mch", "mvp"].each do |pat|
|
8
|
+
["dh", "dih", "mch", "mvp", "src", "test"].each do |pat|
|
9
9
|
p = files.delete(pat)
|
10
10
|
optz[:pattern] = p unless p.nil?
|
11
11
|
end
|
@@ -16,7 +16,7 @@ namespace :module do
|
|
16
16
|
task :destroy, :module_path do |t, args|
|
17
17
|
files = [args[:module_path]] + (args.extras || [])
|
18
18
|
optz = { :destroy => true }
|
19
|
-
["dh", "dih", "mch", "mvp"].each do |pat|
|
19
|
+
["dh", "dih", "mch", "mvp", "src", "test"].each do |pat|
|
20
20
|
p = files.delete(pat)
|
21
21
|
optz[:pattern] = p unless p.nil?
|
22
22
|
end
|
data/spec/spec_system_helper.rb
CHANGED
@@ -168,14 +168,16 @@ module CeedlingTestCases
|
|
168
168
|
def can_test_projects
|
169
169
|
@c.with_context do
|
170
170
|
Dir.chdir @proj_name do
|
171
|
-
FileUtils.cp test_asset_path("example_file.h"), 'src'
|
172
|
-
FileUtils.cp test_asset_path("example_file.c"), 'src'
|
173
|
-
FileUtils.cp test_asset_path("test_example_file.c"), 'test'
|
174
|
-
|
175
|
-
output = `bundle exec ruby -S
|
176
|
-
expect(
|
177
|
-
expect(output).to match(/
|
178
|
-
expect(output).to match(/
|
171
|
+
FileUtils.cp test_asset_path("example_file.h"), 'src/'
|
172
|
+
FileUtils.cp test_asset_path("example_file.c"), 'src/'
|
173
|
+
FileUtils.cp test_asset_path("test_example_file.c"), 'test/'
|
174
|
+
|
175
|
+
output = `bundle exec ruby -S ceedling test:all`
|
176
|
+
expect($?.exitstatus).to match(0)
|
177
|
+
expect(output).to match(/TESTED:\s+\d/)
|
178
|
+
expect(output).to match(/PASSED:\s+\d/)
|
179
|
+
expect(output).to match(/FAILED:\s+\d/)
|
180
|
+
expect(output).to match(/IGNORED:\s+\d/)
|
179
181
|
end
|
180
182
|
end
|
181
183
|
end
|
@@ -183,9 +185,12 @@ module CeedlingTestCases
|
|
183
185
|
def can_use_the_module_plugin
|
184
186
|
@c.with_context do
|
185
187
|
Dir.chdir @proj_name do
|
186
|
-
`bundle exec ruby -S
|
187
|
-
|
188
|
-
expect(output).to match(/
|
188
|
+
output = `bundle exec ruby -S ceedling module:create[ponies]`
|
189
|
+
expect($?.exitstatus).to match(0)
|
190
|
+
expect(output).to match(/Generate Complete/i)
|
191
|
+
output = `bundle exec ruby -S ceedling test:all`
|
192
|
+
expect($?.exitstatus).to match(0)
|
193
|
+
expect(output).to match(/Need to Implement ponies/)
|
189
194
|
end
|
190
195
|
end
|
191
196
|
end
|
@@ -81,7 +81,7 @@ describe "Ceedling" do
|
|
81
81
|
it "should be testable" do
|
82
82
|
@c.with_context do
|
83
83
|
Dir.chdir "temp_sensor" do
|
84
|
-
@output = `bundle exec ruby -S
|
84
|
+
@output = `bundle exec ruby -S ceedling test:all`
|
85
85
|
expect(@output).to match(/TESTED:\s+47/)
|
86
86
|
expect(@output).to match(/PASSED:\s+47/)
|
87
87
|
end
|
@@ -104,7 +104,7 @@ describe "Ceedling" do
|
|
104
104
|
# it "should be testable" do
|
105
105
|
# @c.with_context do
|
106
106
|
# Dir.chdir "blinky" do
|
107
|
-
# @output = `bundle exec ruby -S
|
107
|
+
# @output = `bundle exec ruby -S ceedling test:all`
|
108
108
|
# expect(@output).to match(/TESTED:\s+7/)
|
109
109
|
# expect(@output).to match(/PASSED:\s+7/)
|
110
110
|
# end
|
@@ -10,6 +10,7 @@
|
|
10
10
|
|
11
11
|
require 'rubygems'
|
12
12
|
require 'fileutils'
|
13
|
+
require 'pathname'
|
13
14
|
|
14
15
|
#TEMPLATE_TST
|
15
16
|
TEMPLATE_TST ||= %q[#include "unity.h"
|
@@ -35,7 +36,8 @@ TEMPLATE_SRC ||= %q[%2$s#include "%1$s.h"
|
|
35
36
|
|
36
37
|
#TEMPLATE_INC
|
37
38
|
TEMPLATE_INC ||= %q[#ifndef _%3$s_H
|
38
|
-
#define _%3$s_H
|
39
|
+
#define _%3$s_H
|
40
|
+
%2$s
|
39
41
|
|
40
42
|
#endif // _%3$s_H
|
41
43
|
]
|
@@ -65,19 +67,20 @@ class UnityModuleGenerator
|
|
65
67
|
|
66
68
|
#Built in patterns
|
67
69
|
@patterns = { 'src' => {'' => { :inc => [] } },
|
68
|
-
'
|
70
|
+
'test'=> {'' => { :inc => [] } },
|
71
|
+
'dh' => {'Driver' => { :inc => [create_filename('%1$s','Hardware.h')] },
|
69
72
|
'Hardware' => { :inc => [] }
|
70
73
|
},
|
71
|
-
'dih' => {'Driver' => { :inc => ['%1$
|
72
|
-
'Interrupt'=> { :inc => ['%1$
|
74
|
+
'dih' => {'Driver' => { :inc => [create_filename('%1$s','Hardware.h'), create_filename('%1$s','Interrupt.h')] },
|
75
|
+
'Interrupt'=> { :inc => [create_filename('%1$s','Hardware.h')] },
|
73
76
|
'Hardware' => { :inc => [] }
|
74
77
|
},
|
75
78
|
'mch' => {'Model' => { :inc => [] },
|
76
|
-
'Conductor'=> { :inc => ['%1$
|
79
|
+
'Conductor'=> { :inc => [create_filename('%1$s','Model.h'), create_filename('%1$s','Hardware.h')] },
|
77
80
|
'Hardware' => { :inc => [] }
|
78
81
|
},
|
79
82
|
'mvp' => {'Model' => { :inc => [] },
|
80
|
-
'Presenter'=> { :inc => ['%1$
|
83
|
+
'Presenter'=> { :inc => [create_filename('%1$s','Model.h'), create_filename('%1$s','View.h')] },
|
81
84
|
'View' => { :inc => [] }
|
82
85
|
}
|
83
86
|
}
|
@@ -96,6 +99,7 @@ class UnityModuleGenerator
|
|
96
99
|
:update_svn => false,
|
97
100
|
:boilerplates => {},
|
98
101
|
:test_prefix => 'Test',
|
102
|
+
:mock_prefix => 'Mock',
|
99
103
|
}
|
100
104
|
end
|
101
105
|
|
@@ -113,30 +117,42 @@ class UnityModuleGenerator
|
|
113
117
|
|
114
118
|
############################
|
115
119
|
def files_to_operate_on(module_name, pattern=nil)
|
120
|
+
#strip any leading path information from the module name and save for later
|
121
|
+
subfolder = File.dirname(module_name)
|
122
|
+
module_name = File.basename(module_name)
|
123
|
+
|
116
124
|
#create triad definition
|
117
125
|
prefix = @options[:test_prefix] || 'Test'
|
118
|
-
triad = [ { :ext => '.c', :path => @options[:path_src],
|
119
|
-
{ :ext => '.h', :path => @options[:path_inc],
|
120
|
-
{ :ext => '.c', :path => @options[:path_tst]
|
126
|
+
triad = [ { :ext => '.c', :path => @options[:path_src], :prefix => "", :template => TEMPLATE_SRC, :inc => :src, :boilerplate => @options[:boilerplates][:src] },
|
127
|
+
{ :ext => '.h', :path => @options[:path_inc], :prefix => "", :template => TEMPLATE_INC, :inc => :inc, :boilerplate => @options[:boilerplates][:inc] },
|
128
|
+
{ :ext => '.c', :path => @options[:path_tst], :prefix => prefix, :template => TEMPLATE_TST, :inc => :tst, :boilerplate => @options[:boilerplates][:tst] },
|
121
129
|
]
|
122
130
|
|
123
131
|
#prepare the pattern for use
|
124
|
-
|
132
|
+
pattern = (pattern || @options[:pattern] || 'src').downcase
|
133
|
+
patterns = @patterns[pattern]
|
125
134
|
raise "ERROR: The design pattern '#{pattern}' specified isn't one that I recognize!" if patterns.nil?
|
126
135
|
|
136
|
+
#single file patterns (currently just 'test') can reject the other parts of the triad
|
137
|
+
if (pattern == 'test')
|
138
|
+
triad.reject!{|v| v[:inc] != :tst }
|
139
|
+
end
|
140
|
+
|
127
141
|
# Assemble the path/names of the files we need to work with.
|
128
142
|
files = []
|
129
|
-
triad.each do |
|
143
|
+
triad.each do |cfg|
|
130
144
|
patterns.each_pair do |pattern_file, pattern_traits|
|
145
|
+
submodule_name = create_filename(module_name, pattern_file)
|
146
|
+
filename = cfg[:prefix] + submodule_name + cfg[:ext]
|
131
147
|
files << {
|
132
|
-
:path => "#{
|
133
|
-
:name =>
|
134
|
-
:template =>
|
135
|
-
:boilerplate =>
|
136
|
-
:includes => case(
|
137
|
-
when :src then @options[:includes][:src] | pattern_traits[:inc].map{|f| f % [module_name]}
|
138
|
-
when :inc then @options[:includes][:inc]
|
139
|
-
when :tst then @options[:includes][:tst] | pattern_traits[:inc].map{|f| "
|
148
|
+
:path => (Pathname.new("#{cfg[:path]}#{subfolder}") + filename).cleanpath,
|
149
|
+
:name => submodule_name,
|
150
|
+
:template => cfg[:template],
|
151
|
+
:boilerplate => cfg[:boilerplate],
|
152
|
+
:includes => case(cfg[:inc])
|
153
|
+
when :src then (@options[:includes][:src] || []) | pattern_traits[:inc].map{|f| f % [module_name]}
|
154
|
+
when :inc then (@options[:includes][:inc] || [])
|
155
|
+
when :tst then (@options[:includes][:tst] || []) | pattern_traits[:inc].map{|f| "#{@options[:mock_prefix]}#{f}" % [module_name]}
|
140
156
|
end
|
141
157
|
}
|
142
158
|
end
|
@@ -145,6 +161,27 @@ class UnityModuleGenerator
|
|
145
161
|
return files
|
146
162
|
end
|
147
163
|
|
164
|
+
############################
|
165
|
+
def create_filename(part1, part2="")
|
166
|
+
if part2.empty?
|
167
|
+
case(@options[:naming])
|
168
|
+
when 'bumpy' then part1
|
169
|
+
when 'camel' then part1
|
170
|
+
when 'snake' then part1.downcase
|
171
|
+
when 'caps' then part1.upcase
|
172
|
+
else part1.downcase
|
173
|
+
end
|
174
|
+
else
|
175
|
+
case(@options[:naming])
|
176
|
+
when 'bumpy' then part1 + part2
|
177
|
+
when 'camel' then part1 + part2
|
178
|
+
when 'snake' then part1.downcase + "_" + part2.downcase
|
179
|
+
when 'caps' then part1.upcase + "_" + part2.upcase
|
180
|
+
else part1.downcase + "_" + part2.downcase
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
148
185
|
############################
|
149
186
|
def generate(module_name, pattern=nil)
|
150
187
|
|
@@ -157,8 +194,9 @@ class UnityModuleGenerator
|
|
157
194
|
|
158
195
|
# Create Source Modules
|
159
196
|
files.each_with_index do |file, i|
|
197
|
+
FileUtils.mkdir_p(File.dirname(file[:path]), :verbose => false) # Create the path first if necessary.
|
160
198
|
File.open(file[:path], 'w') do |f|
|
161
|
-
f.write(file[:boilerplate] % [file[:name]]) unless file[:boilerplate].nil?
|
199
|
+
f.write("#{file[:boilerplate]}\n" % [file[:name]]) unless file[:boilerplate].nil?
|
162
200
|
f.write(file[:template] % [ file[:name],
|
163
201
|
file[:includes].map{|f| "#include \"#{f}\"\n"}.join,
|
164
202
|
file[:name].upcase ]
|
@@ -210,13 +248,14 @@ if ($0 == __FILE__)
|
|
210
248
|
# Parse the command line parameters.
|
211
249
|
ARGV.each do |arg|
|
212
250
|
case(arg)
|
213
|
-
when /^-d/
|
214
|
-
when /^-u/
|
215
|
-
when /^-p(\w+)
|
216
|
-
when /^-s(.+)
|
217
|
-
when /^-i(.+)
|
218
|
-
when /^-t(.+)
|
219
|
-
when /^-
|
251
|
+
when /^-d/ then destroy = true
|
252
|
+
when /^-u/ then options[:update_svn] = true
|
253
|
+
when /^-p\"?(\w+)\"?/ then options[:pattern] = $1
|
254
|
+
when /^-s\"?(.+)\"?/ then options[:path_src] = $1
|
255
|
+
when /^-i\"?(.+)\"?/ then options[:path_inc] = $1
|
256
|
+
when /^-t\"?(.+)\"?/ then options[:path_tst] = $1
|
257
|
+
when /^-n\"?(.+)\"?/ then options[:naming] = $1
|
258
|
+
when /^-y\"?(.+)\"?/ then options = UnityModuleGenerator.grab_config($1)
|
220
259
|
when /^(\w+)/
|
221
260
|
raise "ERROR: You can't have more than one Module name specified!" unless module_name.nil?
|
222
261
|
module_name = arg
|
@@ -234,12 +273,18 @@ if ($0 == __FILE__)
|
|
234
273
|
" -s\"../src\" sets the path to output source to '../src' (DEFAULT ../src)",
|
235
274
|
" -t\"C:/test\" sets the path to output source to 'C:/test' (DEFAULT ../test)",
|
236
275
|
" -p\"MCH\" sets the output pattern to MCH.",
|
237
|
-
" dh
|
238
|
-
" dih
|
239
|
-
" mch
|
240
|
-
" mvp
|
241
|
-
" src
|
276
|
+
" dh - driver hardware.",
|
277
|
+
" dih - driver interrupt hardware.",
|
278
|
+
" mch - model conductor hardware.",
|
279
|
+
" mvp - model view presenter.",
|
280
|
+
" src - just a source module, header and test. (DEFAULT)",
|
281
|
+
" test - just a test file.",
|
242
282
|
" -d destroy module instead of creating it.",
|
283
|
+
" -n\"camel\" sets the file naming convention.",
|
284
|
+
" bumpy - BumpyCaseFilenames.",
|
285
|
+
" camel - camelCaseFilenames.",
|
286
|
+
" snake - snake_case_filenames. (DEFAULT)",
|
287
|
+
" caps - CAPS_CASE_FILENAMES.",
|
243
288
|
" -u update subversion too (requires subversion command line)",
|
244
289
|
" -y\"my.yml\" selects a different yaml config file for module generation",
|
245
290
|
"" ].join("\n")
|
@@ -254,5 +299,3 @@ if ($0 == __FILE__)
|
|
254
299
|
end
|
255
300
|
|
256
301
|
end
|
257
|
-
|
258
|
-
|
@@ -9,7 +9,7 @@
|
|
9
9
|
#include "unity_fixture.h"
|
10
10
|
#include "unity_internals.h"
|
11
11
|
|
12
|
-
struct
|
12
|
+
struct UNITY_FIXTURE_T UnityFixture;
|
13
13
|
|
14
14
|
/* If you decide to use the function pointer approach.
|
15
15
|
* Build with -D UNITY_OUTPUT_CHAR=outputChar and include <stdio.h>
|