ruby / ruby/rake

Rake executes file task when prerequisites have older timestamp

未关闭
#246 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Ruby
星标
2.5k
派生
650
平均合并
6 分钟
30 天内合并 PR
3

描述

When a file task depends on some non-file task indirectly,
Rake executes the file task even if its immediate prerequisite files have older timestamp.

It looks like the behavior changed at 12.1.0.

Example
require "rake/clean"

CLEAN.include("config.yml", "component")

task "setup" do
  puts Rake::VERSION
  touch "config.yml" unless File.exist?("config.yml")
end

file "config.yml" => "setup"

file "component" => "config.yml" do |t|
  puts "[config.yml] #{File.mtime(t.prerequisites[0])}"
  puts "[component]  #{File.exist?(t.name) && File.mtime(t.name)}"
  sleep 1
  touch t.name
end

Based on the above Rakefile, clean up and create the "component" first.

$ rake clean && rake component

The next rake component results in different behavior as follows.
On 12.0.0:

$ rake component --trace
(in /path/to/Rakefile-directory)
** Invoke component (first_time, not_needed)
** Invoke config.yml (first_time)
** Invoke setup (first_time)
** Execute setup
12.0.0
** Execute config.yml

On 12.1.0:

$ rake component --trace
(in /path/to/Rakefile-directory)
** Invoke component (first_time)
** Invoke config.yml (first_time)
** Invoke setup (first_time)
** Execute setup
12.1.0
** Execute config.yml
** Execute component
[config.yml] 2018-01-01 15:13:19 +0900
[component]  2018-01-01 15:13:20 +0900
touch component

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用 Rakefile 示例重现该问题,并比较受影响行为与 12.0 之间的 --trace 输出。首先跟踪文件任务的前置条件和时间戳是如何评估的;当 rake component 在其直接前置文件较旧时不再执行文件任务,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
ruby
领域
build-system
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。