mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-18 21:08:31 +08:00
Merge pull request #79 from markmccrum/generate_test_runner_fixes
Fixed script unit tests. Fixed generate_test_runner configuration loadin... (Thanks Mark McCrum. You are awesome!)
This commit is contained in:
@ -10,7 +10,7 @@ File.expand_path(File.join(File.dirname(__FILE__),'colour_prompt'))
|
|||||||
class UnityTestRunnerGenerator
|
class UnityTestRunnerGenerator
|
||||||
|
|
||||||
def initialize(options = nil)
|
def initialize(options = nil)
|
||||||
@options = self.default_options
|
@options = UnityTestRunnerGenerator.default_options
|
||||||
case(options)
|
case(options)
|
||||||
when NilClass then @options
|
when NilClass then @options
|
||||||
when String then @options.merge!(UnityTestRunnerGenerator.grab_config(options))
|
when String then @options.merge!(UnityTestRunnerGenerator.grab_config(options))
|
||||||
@ -19,7 +19,7 @@ class UnityTestRunnerGenerator
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_options
|
def self.default_options
|
||||||
{
|
{
|
||||||
:includes => [],
|
:includes => [],
|
||||||
:plugins => [],
|
:plugins => [],
|
||||||
@ -31,7 +31,7 @@ class UnityTestRunnerGenerator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.grab_config(config_file)
|
def self.grab_config(config_file)
|
||||||
options = default_options
|
options = self.default_options
|
||||||
unless (config_file.nil? or config_file.empty?)
|
unless (config_file.nil? or config_file.empty?)
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
yaml_guts = YAML.load_file(config_file)
|
yaml_guts = YAML.load_file(config_file)
|
||||||
|
@ -48,8 +48,7 @@ void resetTest()
|
|||||||
//=======MAIN=====
|
//=======MAIN=====
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
UnityBegin();
|
UnityBegin("testdata/testsample.c");
|
||||||
Unity.TestFile = "test/testdata/testsample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||||
|
|
||||||
|
@ -44,8 +44,7 @@ void resetTest()
|
|||||||
//=======MAIN=====
|
//=======MAIN=====
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
UnityBegin();
|
UnityBegin("testdata/testsample.c");
|
||||||
Unity.TestFile = "test/testdata/testsample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||||
|
|
||||||
|
@ -69,8 +69,7 @@ void resetTest()
|
|||||||
//=======MAIN=====
|
//=======MAIN=====
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
UnityBegin();
|
UnityBegin("testdata/mocksample.c");
|
||||||
Unity.TestFile = "test/testdata/mocksample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||||
|
|
||||||
|
@ -65,8 +65,7 @@ void resetTest()
|
|||||||
//=======MAIN=====
|
//=======MAIN=====
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
UnityBegin();
|
UnityBegin("testdata/mocksample.c");
|
||||||
Unity.TestFile = "test/testdata/mocksample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||||
|
|
||||||
|
@ -78,8 +78,7 @@ void resetTest()
|
|||||||
//=======MAIN=====
|
//=======MAIN=====
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
UnityBegin();
|
UnityBegin("testdata/mocksample.c");
|
||||||
Unity.TestFile = "test/testdata/mocksample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||||
|
|
||||||
|
@ -78,8 +78,7 @@ void resetTest()
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
suite_setup();
|
suite_setup();
|
||||||
UnityBegin();
|
UnityBegin("testdata/mocksample.c");
|
||||||
Unity.TestFile = "test/testdata/mocksample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||||
|
|
||||||
|
@ -66,8 +66,7 @@ void resetTest()
|
|||||||
//=======MAIN=====
|
//=======MAIN=====
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
UnityBegin();
|
UnityBegin("testdata/mocksample.c");
|
||||||
Unity.TestFile = "test/testdata/mocksample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS);
|
RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS);
|
RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS);
|
||||||
|
|
||||||
|
@ -78,8 +78,7 @@ void resetTest()
|
|||||||
//=======MAIN=====
|
//=======MAIN=====
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
UnityBegin();
|
UnityBegin("testdata/mocksample.c");
|
||||||
Unity.TestFile = "test/testdata/mocksample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||||
|
|
||||||
|
@ -78,8 +78,7 @@ void resetTest()
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
suite_setup();
|
suite_setup();
|
||||||
UnityBegin();
|
UnityBegin("testdata/mocksample.c");
|
||||||
Unity.TestFile = "test/testdata/mocksample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||||
|
|
||||||
|
@ -79,8 +79,7 @@ void resetTest()
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
suite_setup();
|
suite_setup();
|
||||||
UnityBegin();
|
UnityBegin("testdata/mocksample.c");
|
||||||
Unity.TestFile = "test/testdata/mocksample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||||
|
|
||||||
|
@ -54,8 +54,7 @@ void resetTest()
|
|||||||
//=======MAIN=====
|
//=======MAIN=====
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
UnityBegin();
|
UnityBegin("testdata/testsample.c");
|
||||||
Unity.TestFile = "test/testdata/testsample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||||
|
|
||||||
|
@ -57,8 +57,7 @@ void resetTest()
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
suite_setup();
|
suite_setup();
|
||||||
UnityBegin();
|
UnityBegin("testdata/testsample.c");
|
||||||
Unity.TestFile = "test/testdata/testsample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||||
|
|
||||||
|
@ -45,8 +45,7 @@ void resetTest()
|
|||||||
//=======MAIN=====
|
//=======MAIN=====
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
UnityBegin();
|
UnityBegin("testdata/testsample.c");
|
||||||
Unity.TestFile = "test/testdata/testsample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS);
|
RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS);
|
RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS);
|
||||||
|
|
||||||
|
@ -54,8 +54,7 @@ void resetTest()
|
|||||||
//=======MAIN=====
|
//=======MAIN=====
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
UnityBegin();
|
UnityBegin("testdata/testsample.c");
|
||||||
Unity.TestFile = "test/testdata/testsample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||||
|
|
||||||
|
@ -57,8 +57,7 @@ void resetTest()
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
suite_setup();
|
suite_setup();
|
||||||
UnityBegin();
|
UnityBegin("testdata/testsample.c");
|
||||||
Unity.TestFile = "test/testdata/testsample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||||
|
|
||||||
|
@ -58,8 +58,7 @@ void resetTest()
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
suite_setup();
|
suite_setup();
|
||||||
UnityBegin();
|
UnityBegin("testdata/testsample.c");
|
||||||
Unity.TestFile = "test/testdata/testsample.c";
|
|
||||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ end
|
|||||||
|
|
||||||
desc "Test unity's helper scripts"
|
desc "Test unity's helper scripts"
|
||||||
task :scripts => [:prepare_for_tests] do
|
task :scripts => [:prepare_for_tests] do
|
||||||
Dir['test/test_*.rb'].each do |scriptfile|
|
Dir['tests/test_*.rb'].each do |scriptfile|
|
||||||
require "./"+scriptfile
|
require "./"+scriptfile
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,12 +4,12 @@
|
|||||||
# [Released under MIT License. Please refer to license.txt for details]
|
# [Released under MIT License. Please refer to license.txt for details]
|
||||||
# ==========================================
|
# ==========================================
|
||||||
|
|
||||||
require './auto/generate_test_runner.rb'
|
require '../auto/generate_test_runner.rb'
|
||||||
|
|
||||||
TEST_FILE = 'test/testdata/testsample.c'
|
TEST_FILE = 'testdata/testsample.c'
|
||||||
TEST_MOCK = 'test/testdata/mocksample.c'
|
TEST_MOCK = 'testdata/mocksample.c'
|
||||||
OUT_FILE = 'build/testsample_'
|
OUT_FILE = 'build/testsample_'
|
||||||
EXP_FILE = 'test/expectdata/testsample_'
|
EXP_FILE = 'expectdata/testsample_'
|
||||||
|
|
||||||
$generate_test_runner_failures = 0
|
$generate_test_runner_failures = 0
|
||||||
|
|
||||||
@ -53,22 +53,22 @@ end
|
|||||||
|
|
||||||
should "GenerateARunnerByPullingYamlOptions" do
|
should "GenerateARunnerByPullingYamlOptions" do
|
||||||
subtest = 'yaml'
|
subtest = 'yaml'
|
||||||
cmdstr = "ruby auto/generate_test_runner.rb test/testdata/sample.yml \"#{TEST_FILE}\" \"#{OUT_FILE + subtest + '.c'}\""
|
cmdstr = "ruby ../auto/generate_test_runner.rb testdata/sample.yml \"#{TEST_FILE}\" \"#{OUT_FILE + subtest + '.c'}\""
|
||||||
`#{cmdstr}`
|
`#{cmdstr}`
|
||||||
verify_output_equal(subtest)
|
verify_output_equal(subtest)
|
||||||
|
|
||||||
cmdstr = "ruby auto/generate_test_runner.rb test/testdata/sample.yml \"#{TEST_MOCK}\" \"#{OUT_FILE + 'mock_' + subtest + '.c'}\""
|
cmdstr = "ruby ../auto/generate_test_runner.rb testdata/sample.yml \"#{TEST_MOCK}\" \"#{OUT_FILE + 'mock_' + subtest + '.c'}\""
|
||||||
`#{cmdstr}`
|
`#{cmdstr}`
|
||||||
verify_output_equal('mock_' + subtest)
|
verify_output_equal('mock_' + subtest)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "GenerateARunnerByPullingCommandlineOptions" do
|
should "GenerateARunnerByPullingCommandlineOptions" do
|
||||||
subtest = 'cmd'
|
subtest = 'cmd'
|
||||||
cmdstr = "ruby auto/generate_test_runner.rb -cexception \"#{TEST_FILE}\" \"#{OUT_FILE + subtest + '.c'}\""
|
cmdstr = "ruby ../auto/generate_test_runner.rb -cexception \"#{TEST_FILE}\" \"#{OUT_FILE + subtest + '.c'}\""
|
||||||
`#{cmdstr}`
|
`#{cmdstr}`
|
||||||
verify_output_equal(subtest)
|
verify_output_equal(subtest)
|
||||||
|
|
||||||
cmdstr = "ruby auto/generate_test_runner.rb -cexception \"#{TEST_MOCK}\" \"#{OUT_FILE + 'mock_' + subtest + '.c'}\""
|
cmdstr = "ruby ../auto/generate_test_runner.rb -cexception \"#{TEST_MOCK}\" \"#{OUT_FILE + 'mock_' + subtest + '.c'}\""
|
||||||
`#{cmdstr}`
|
`#{cmdstr}`
|
||||||
verify_output_equal('mock_' + subtest)
|
verify_output_equal('mock_' + subtest)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user