- Handle filenames with spaces in them

This commit is contained in:
unknown
2012-11-25 14:56:15 -05:00
parent 27cad7c9b7
commit 9e1d77a94a
2 changed files with 9 additions and 10 deletions
+4 -5
View File
@@ -28,7 +28,7 @@ class CMockGenerator
def create_mock(module_name, parsed_stuff)
@module_name = module_name
@mock_name = @prefix + @module_name
@clean_mock_name = @mock_name.gsub(/-/, "_")
@clean_mock_name = @mock_name.gsub(/(?:-|\s+)/, "_")
create_mock_header_file(parsed_stuff)
create_mock_source_file(parsed_stuff)
end
@@ -63,12 +63,11 @@ class CMockGenerator
end
def create_mock_header_header(file, filename)
define_name = filename.gsub(/\.h/, "_h").upcase
define_name = define_name.gsub(/-/, "_")
define_name = @clean_mock_name.gsub(/\.h/, "_h").upcase
orig_filename = filename.gsub(@config.mock_prefix, "")
file << "/* AUTOGENERATED FILE. DO NOT EDIT. */\n"
file << "#ifndef _#{define_name}\n"
file << "#define _#{define_name}\n\n"
file << "#ifndef _#{define_name}_H\n"
file << "#define _#{define_name}_H\n\n"
@includes_h_pre_orig_header.each {|inc| file << "#include #{inc}\n"}
file << "#include \"#{orig_filename}\"\n"
@includes_h_post_orig_header.each {|inc| file << "#include #{inc}\n"}
+5 -5
View File
@@ -102,7 +102,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
assert_equal(expected, output)
end
should "handle dashes in the module name" do
should "handle dashes and spaces in the module name" do
#no strict handling
@config.expect.mock_prefix.returns("Mock")
@config.expect.enforce_strict_ordering.returns(nil)
@@ -112,12 +112,12 @@ class CMockGeneratorTest < Test::Unit::TestCase
@config.expect.includes_c_pre_header.returns(nil)
@config.expect.includes_c_post_header.returns(nil)
@cmock_generator2 = CMockGenerator.new(@config, @file_writer, @utils, @plugins)
@cmock_generator2.module_name = "Pout-Pout-Fish"
@cmock_generator2.mock_name = "MockPout-Pout-Fish"
@cmock_generator2.module_name = "Pout-Pout Fish"
@cmock_generator2.mock_name = "MockPout-Pout Fish"
@cmock_generator2.clean_mock_name = "MockPout_Pout_Fish"
@config.expect.mock_prefix.returns("Mock")
orig_filename = "Pout-Pout-Fish.h"
orig_filename = "Pout-Pout Fish.h"
define_name = "MOCKPOUT_POUT_FISH_H"
mock_name = "MockPout_Pout_Fish"
output = []
@@ -133,7 +133,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
@plugins.expect.run(:include_files).returns("#include \"PluginRequiredHeader.h\"\n")
@cmock_generator.create_mock_header_header(output, "MockPout-Pout-Fish.h")
@cmock_generator2.create_mock_header_header(output, "MockPout-Pout Fish.h")
assert_equal(expected, output)
end