Skip to content

Loading…

Add :phony task #101

Merged
merged 2 commits into from

3 participants

@jimweirich
Owner

Example use? Test Cases?

@zenspider
@zenspider

Test added... I had to dupe the :phony creation inside the test because of helper's setup method...

@damphyr

Why not extend the DSL with phony to achieve the same end instead of requiring a => :phony dependency?

So you'd have

phony :isolate => [:whatever]

But I'm still not sure how you use :isolate tbh

@damphyr

Maybe this should be Rake::EARLY to be consistent?

@zenspider

That doesn't make sense. EARLY isn't even a task.

Eh, that was a comment in the commit on the code for the timestamp method. Where Time.at 0 it should return Rake::EARLY.
The way it appeared as a comment on the pull request was confusing.

@zenspider

PING

@zenspider

I'm tired of non-communication. I've released this in makerakeworkwell.

@jimweirich jimweirich merged commit b61bbb5 into jimweirich:master
@jimweirich
Owner

Catching up on the backlog, sorry for the long delay.

Added this as an optional require. Use

require 'rake/phony'

in your Rakefile to enable.

I'm still not sure what value the isolate task provides in your example. If you would care to elucidate, it would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 30 additions and 0 deletions.
  1. +11 −0 lib/rake.rb
  2. +19 −0 test/test_rake_file_task.rb
View
11 lib/rake.rb
@@ -68,3 +68,14 @@
FileList = Rake::FileList
RakeFileUtils = Rake::FileUtilsExt
+
+##
+# Defines a :phony task that you can use as a dependency. This allows
+# file-based tasks to use non-file-based tasks as prerequisites
+# without forcing them to rebuild.
+#
+# See FileTask#out_of_date? and Task#timestamp for more info.
+
+def (Rake::Task.define_task(:phony)).timestamp
+ Time.at 0
+end
View
19 test/test_rake_file_task.rb
@@ -41,6 +41,25 @@ def test_file_times_new_depends_on_old
assert ! t1.needed?, "Should not need to rebuild new file because of old"
end
+ def test_file_times_new_depend_on_regular_task_timestamps
+ name = "dummy"
+ task name
+
+ create_timed_files(NEWFILE)
+
+ t1 = Rake.application.intern(FileTask, NEWFILE).enhance([name])
+
+ assert t1.needed?, "depending on non-file task uses Time.now"
+
+ def (Rake::Task.define_task(:phony)).timestamp
+ Time.at 0
+ end
+
+ task(name => :phony)
+
+ assert ! t1.needed?, "unless the non-file task has a timestamp"
+ end
+
def test_file_times_old_depends_on_new
create_timed_files(OLDFILE, NEWFILE)
Something went wrong with that request. Please try again.