Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
ee02e388
T
Third Party Unity
项目概览
OpenHarmony
/
Third Party Unity
1 年多 前同步成功
通知
36
Star
144
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Unity
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ee02e388
编写于
12月 12, 2016
作者:
M
Mark VanderVoord
提交者:
GitHub
12月 12, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #233 from mchernosky/generate-partial-triads
Module generator finishes for partially existing files
上级
8e31f5d8
df2d3745
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
181 addition
and
4 deletion
+181
-4
.gitignore
.gitignore
+1
-0
.travis.yml
.travis.yml
+1
-0
auto/generate_module.rb
auto/generate_module.rb
+13
-3
test/rakefile
test/rakefile
+8
-1
test/spec/generate_module_existing_file_spec.rb
test/spec/generate_module_existing_file_spec.rb
+158
-0
未找到文件。
.gitignore
浏览文件 @
ee02e388
build/
build/
test/sandbox
.DS_Store
.DS_Store
examples/example_1/test1.out
examples/example_1/test1.out
examples/example_1/test2.out
examples/example_1/test2.out
...
...
.travis.yml
浏览文件 @
ee02e388
...
@@ -11,6 +11,7 @@ matrix:
...
@@ -11,6 +11,7 @@ matrix:
before_install
:
before_install
:
-
if [ "$TRAVIS_OS_NAME" == "osx" ]; then rvm install 2.1 && rvm use 2.1 && ruby -v; fi
-
if [ "$TRAVIS_OS_NAME" == "osx" ]; then rvm install 2.1 && rvm use 2.1 && ruby -v; fi
install
:
gem install rspec
script
:
script
:
-
cd test && rake ci
-
cd test && rake ci
-
make -s
-
make -s
...
...
auto/generate_module.rb
浏览文件 @
ee02e388
...
@@ -187,14 +187,24 @@ class UnityModuleGenerator
...
@@ -187,14 +187,24 @@ class UnityModuleGenerator
files
=
files_to_operate_on
(
module_name
,
pattern
)
files
=
files_to_operate_on
(
module_name
,
pattern
)
#Abort if any module already exists
#Abort if all of the module files already exist
all_files_exist
=
true
files
.
each
do
|
file
|
files
.
each
do
|
file
|
raise
"ERROR: File
#{
file
[
:name
]
}
already exists. Exiting."
if
File
.
exist?
(
file
[
:path
])
if
not
File
.
exist?
(
file
[
:path
])
all_files_exist
=
false
end
end
end
raise
"ERROR: File
#{
files
[
0
][
:name
]
}
already exists. Exiting."
if
all_files_exist
# Create Source Modules
# Create Source Modules
files
.
each_with_index
do
|
file
,
i
|
files
.
each_with_index
do
|
file
,
i
|
FileUtils
.
mkdir_p
(
File
.
dirname
(
file
[
:path
]),
:verbose
=>
false
)
# Create the path first if necessary.
# If this file already exists, don't overwrite it.
if
File
.
exist?
(
file
[
:path
])
puts
"File
#{
file
[
:path
]
}
already exists!"
next
end
# Create the path first if necessary.
FileUtils
.
mkdir_p
(
File
.
dirname
(
file
[
:path
]),
:verbose
=>
false
)
File
.
open
(
file
[
:path
],
'w'
)
do
|
f
|
File
.
open
(
file
[
:path
],
'w'
)
do
|
f
|
f
.
write
(
"
#{
file
[
:boilerplate
]
}
\n
"
%
[
file
[
:name
]])
unless
file
[
:boilerplate
].
nil?
f
.
write
(
"
#{
file
[
:boilerplate
]
}
\n
"
%
[
file
[
:name
]])
unless
file
[
:boilerplate
].
nil?
f
.
write
(
file
[
:template
]
%
[
file
[
:name
],
f
.
write
(
file
[
:template
]
%
[
file
[
:name
],
...
...
test/rakefile
浏览文件 @
ee02e388
...
@@ -10,9 +10,11 @@ $verbose = false
...
@@ -10,9 +10,11 @@ $verbose = false
require
'rake'
require
'rake'
require
'rake/clean'
require
'rake/clean'
require
UNITY_ROOT
+
'rakefile_helper'
require
UNITY_ROOT
+
'rakefile_helper'
require
'rspec/core/rake_task'
TEMP_DIRS
=
[
TEMP_DIRS
=
[
File
.
join
(
UNITY_ROOT
,
'build'
)
File
.
join
(
UNITY_ROOT
,
'build'
),
File
.
join
(
UNITY_ROOT
,
'sandbox'
)
]
]
TEMP_DIRS
.
each
do
|
dir
|
TEMP_DIRS
.
each
do
|
dir
|
...
@@ -40,6 +42,11 @@ task :scripts => [:prepare_for_tests] do
...
@@ -40,6 +42,11 @@ task :scripts => [:prepare_for_tests] do
end
end
end
end
desc
"Run all rspecs"
RSpec
::
Core
::
RakeTask
.
new
(
:spec
)
do
|
t
|
t
.
pattern
=
'spec/**/*_spec.rb'
end
desc
"Generate test summary"
desc
"Generate test summary"
task
:summary
do
task
:summary
do
report_summary
report_summary
...
...
test/spec/generate_module_existing_file_spec.rb
0 → 100644
浏览文件 @
ee02e388
require
'../auto/generate_module.rb'
require
'fileutils'
def
touch_src
(
file
)
FileUtils
.
touch
"sandbox/src/
#{
file
}
"
end
def
touch_test
(
file
)
FileUtils
.
touch
"sandbox/test/
#{
file
}
"
end
def
create_src_with_known_content
(
file
)
File
.
open
(
"sandbox/src/
#{
file
}
"
,
"w"
)
{
|
f
|
f
.
write
(
"the original
#{
file
}
"
)}
end
def
create_test_with_known_content
(
file
)
File
.
open
(
"sandbox/test/
#{
file
}
"
,
"w"
)
{
|
f
|
f
.
write
(
"the original
#{
file
}
"
)}
end
def
expect_src_content_didnt_change
(
file
)
expect
(
File
.
read
(
"sandbox/src/
#{
file
}
"
)).
to
eq
(
"the original
#{
file
}
"
)
end
def
expect_test_content_didnt_change
(
file
)
expect
(
File
.
read
(
"sandbox/test/
#{
file
}
"
)).
to
eq
(
"the original
#{
file
}
"
)
end
def
expect_src_file_to_exist
(
file
)
expect
(
File
.
exist?
(
"sandbox/src/
#{
file
}
"
)).
to
be
true
end
def
expect_test_file_to_exist
(
file
)
expect
(
File
.
exist?
(
"sandbox/test/
#{
file
}
"
)).
to
be
true
end
describe
"UnityModuleGenerator"
do
before
do
# clean sandbox and setup our "project" folders
FileUtils
.
rm_rf
"sandbox"
FileUtils
.
mkdir_p
"sandbox"
FileUtils
.
mkdir_p
"sandbox/src"
FileUtils
.
mkdir_p
"sandbox/test"
@options
=
{
:path_src
=>
"sandbox/src"
,
:path_tst
=>
"sandbox/test"
,
}
end
context
"with src pattern"
do
before
do
@options
[
:pattern
]
=
"src"
end
it
"fails when all files already exist"
do
# create an existing triad of files
touch_src
"meh.c"
touch_src
"meh.h"
touch_test
"Testmeh.c"
expect
{
UnityModuleGenerator
.
new
(
@options
).
generate
(
"meh"
)
}.
to
raise_error
(
"ERROR: File meh already exists. Exiting."
)
end
it
"creates the test file if the source and header files exist"
do
# Create the existing files.
touch_src
"meh.c"
touch_src
"meh.h"
UnityModuleGenerator
.
new
(
@options
).
generate
(
"meh"
)
expect_test_file_to_exist
"Testmeh.c"
end
it
"does not alter existing files"
do
# Create some files with known content.
create_src_with_known_content
"meh.c"
create_src_with_known_content
"meh.h"
UnityModuleGenerator
.
new
(
@options
).
generate
(
"meh"
)
expect_src_content_didnt_change
"meh.c"
expect_src_content_didnt_change
"meh.c"
end
it
"does not alter existing test files"
do
# Create some files with known content.
create_test_with_known_content
"Testmeh.c"
UnityModuleGenerator
.
new
(
@options
).
generate
(
"meh"
)
expect_test_content_didnt_change
"Testmeh.c"
end
end
context
"with mch pattern"
do
before
do
@options
[
:pattern
]
=
"mch"
end
it
"fails when all files exist"
do
touch_src
"meh_model.c"
touch_src
"meh_conductor.c"
touch_src
"meh_hardware.c"
touch_src
"meh_model.h"
touch_src
"meh_conductor.h"
touch_src
"meh_hardware.h"
touch_test
"Testmeh_model.c"
touch_test
"Testmeh_conductor.c"
touch_test
"Testmeh_hardware.c"
expect
{
UnityModuleGenerator
.
new
(
@options
).
generate
(
"meh"
)
}.
to
raise_error
(
"ERROR: File meh_model already exists. Exiting."
)
end
it
"creates files that don't exist"
do
touch_src
"meh_model.c"
touch_src
"meh_conductor.c"
touch_src
"meh_hardware.c"
touch_src
"meh_model.h"
touch_src
"meh_conductor.h"
UnityModuleGenerator
.
new
(
@options
).
generate
(
"meh"
)
expect_src_file_to_exist
"meh_hardware.h"
expect_test_file_to_exist
"Testmeh_model.c"
expect_test_file_to_exist
"Testmeh_conductor.c"
expect_test_file_to_exist
"Testmeh_hardware.c"
end
it
"does not alter existing source files"
do
create_src_with_known_content
"meh_model.c"
create_src_with_known_content
"meh_model.c"
create_src_with_known_content
"meh_model.c"
create_src_with_known_content
"meh_model.h"
create_src_with_known_content
"meh_model.c"
UnityModuleGenerator
.
new
(
@options
).
generate
(
"meh"
)
expect_src_content_didnt_change
"meh_model.c"
expect_src_content_didnt_change
"meh_model.c"
expect_src_content_didnt_change
"meh_model.c"
expect_src_content_didnt_change
"meh_model.c"
end
it
"does not alter existing test files"
do
create_test_with_known_content
"Testmeh_model.c"
UnityModuleGenerator
.
new
(
@options
).
generate
(
"meh"
)
expect_test_content_didnt_change
"Testmeh_model.c"
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录