Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
a22d431d
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a22d431d
编写于
11月 09, 2015
作者:
X
Xavier Noria
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
improves waiting in the file monitors suite
上级
9a59beac
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
21 addition
and
23 deletion
+21
-23
activesupport/test/file_evented_update_checker_test.rb
activesupport/test/file_evented_update_checker_test.rb
+10
-0
activesupport/test/file_update_checker_test.rb
activesupport/test/file_update_checker_test.rb
+9
-0
activesupport/test/file_update_checker_with_enumerable_test_cases.rb
...rt/test/file_update_checker_with_enumerable_test_cases.rb
+2
-23
未找到文件。
activesupport/test/file_evented_update_checker_test.rb
浏览文件 @
a22d431d
...
...
@@ -19,6 +19,16 @@ def teardown
def
wait
sleep
1
end
def
touch
(
files
)
super
wait
# wait for the events to fire
end
def
rm_f
(
files
)
super
wait
end
end
class
FileEventedUpdateCheckerPathHelperTest
<
ActiveSupport
::
TestCase
...
...
activesupport/test/file_update_checker_test.rb
浏览文件 @
a22d431d
...
...
@@ -7,4 +7,13 @@ class FileUpdateCheckerTest < ActiveSupport::TestCase
def
new_checker
(
files
=
[],
dirs
=
{},
&
block
)
ActiveSupport
::
FileUpdateChecker
.
new
(
files
,
dirs
,
&
block
)
end
def
wait
# noop
end
def
touch
(
files
)
sleep
1
# let's wait a bit to ensure there's a new mtime
super
end
end
activesupport/test/file_update_checker_with_enumerable_test_cases.rb
浏览文件 @
a22d431d
...
...
@@ -3,15 +3,6 @@
module
FileUpdateCheckerWithEnumerableTestCases
include
FileUtils
def
wait
# noop
end
def
touch
(
files
)
sleep
1
super
end
def
setup
@tmpdir
=
Dir
.
mktmpdir
(
nil
,
__dir__
)
...
...
@@ -20,7 +11,7 @@ def setup
end
def
teardown
rm_rf
(
@tmpdir
)
FileUtils
.
rm_rf
(
@tmpdir
)
end
def
test_should_not_execute_the_block_if_no_paths_are_given
...
...
@@ -47,7 +38,6 @@ def test_should_invoke_the_block_if_a_file_has_changed
checker
=
new_checker
(
@files
)
{
i
+=
1
}
touch
(
@files
)
wait
assert
checker
.
execute_if_updated
assert_equal
1
,
i
...
...
@@ -60,18 +50,16 @@ def test_updated_should_become_true_when_watched_files_are_deleted
assert
!
checker
.
updated?
rm_f
(
@files
)
wait
assert
checker
.
updated?
end
def
test_should_
be_robust_enough_to_handle
_deleted_files
def
test_should_
detect
_deleted_files
i
=
0
checker
=
new_checker
(
@files
)
{
i
+=
1
}
rm_f
(
@files
)
wait
assert
checker
.
execute_if_updated
assert_equal
1
,
i
...
...
@@ -87,7 +75,6 @@ def test_should_be_robust_to_handle_files_with_wrong_modified_time
checker
=
new_checker
(
@files
)
{
i
+=
1
}
touch
(
@files
[
1
..-
1
])
wait
assert
checker
.
execute_if_updated
assert_equal
1
,
i
...
...
@@ -100,7 +87,6 @@ def test_should_cache_updated_result_until_execute
assert
!
checker
.
updated?
touch
(
@files
)
wait
assert
checker
.
updated?
checker
.
execute
...
...
@@ -113,7 +99,6 @@ def test_should_invoke_the_block_if_a_watched_dir_changes
checker
=
new_checker
([],
@tmpdir
=>
:rb
)
{
i
+=
1
}
touch
(
@files
)
wait
assert
checker
.
execute_if_updated
assert_equal
1
,
i
...
...
@@ -125,7 +110,6 @@ def test_should_not_invoke_the_block_if_a_watched_dir_does_not_change
checker
=
new_checker
([],
@tmpdir
=>
:txt
)
{
i
+=
1
}
touch
(
@files
)
wait
assert
!
checker
.
execute_if_updated
assert_equal
0
,
i
...
...
@@ -138,7 +122,6 @@ def test_does_not_assume_files_exist_on_instantiation
checker
=
new_checker
([
non_existing
])
{
i
+=
1
}
touch
(
non_existing
)
wait
assert
checker
.
execute_if_updated
assert_equal
1
,
i
...
...
@@ -157,7 +140,6 @@ def test_detects_files_in_new_subdirectories
assert_equal
0
,
i
touch
(
"
#{
subdir
}
/nested.rb"
)
wait
assert
checker
.
execute_if_updated
assert_equal
1
,
i
...
...
@@ -172,20 +154,17 @@ def test_looked_up_extensions_are_inherited_in_subdirectories_not_listening_to_t
checker
=
new_checker
([],
@tmpdir
=>
:rb
,
subdir
=>
:txt
)
{
i
+=
1
}
touch
(
"
#{
@tmpdir
}
/new.txt"
)
wait
assert
!
checker
.
execute_if_updated
assert_equal
0
,
i
# subdir does not look for Ruby files, but its parent @tmpdir does.
touch
(
"
#{
subdir
}
/nested.rb"
)
wait
assert
checker
.
execute_if_updated
assert_equal
1
,
i
touch
(
"
#{
subdir
}
/nested.txt"
)
wait
assert
checker
.
execute_if_updated
assert_equal
2
,
i
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录