Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reintroduce last_manifest/manifest

I had previously removed the 2 manifest concept from the code. I thought
this was ok because the tests were passing. There weren't enough tests
to cover all use cases. Two manifests are needed for tracking changes in
dynamic prerequisites between invocations. Here's the use case: you have
a file dynamic file A that imports B. Inovking A will _always_ update
B's mtime in the manifest. This causes dependency modification check
results to be false positives.
  • Loading branch information...
commit 596b8a1b004d588535d1e776e921a97212166c6d 1 parent 2bd0211
twinturbo authored
View
5 lib/rake-pipeline.rb
@@ -409,6 +409,11 @@ def manifest
project.manifest
end
+ # the Manifest used in this pipeline
+ def last_manifest
+ project.last_manifest
+ end
+
protected
# Generate a new temporary directory name.
#
View
18 lib/rake-pipeline/dynamic_file_task.rb
@@ -26,7 +26,7 @@ def to_s
end
end
- attr_accessor :manifest
+ attr_accessor :manifest, :last_manifest
# @return [Boolean] true if the task has a block to invoke
# for dynamic dependencies, false otherwise.
@@ -49,6 +49,10 @@ def manifest_entry=(new_entry)
manifest[name] = new_entry
end
+ def last_manifest_entry
+ last_manifest[name]
+ end
+
# Invoke this task. This method only checks to see if there
# is a manifest then delegates to super
def invoke(*args)
@@ -67,12 +71,12 @@ def needed?
return true if prerequisites_needed?
# if we have no manifest, this file task is needed
- return true unless manifest_entry
+ return true unless last_manifest_entry
# If any of this task's dynamic dependencies have changed,
# this file task is needed
- manifest_entry.deps.each do |dep, time|
- return true if File.mtime(dep) > time || time > timestamp
+ last_manifest_entry.deps.each do |dep, time|
+ return true if File.mtime(dep) > time
end
# Otherwise, it's not needed
@@ -167,8 +171,8 @@ def dynamic_prerequisites_from_manifest
# Try to avoid invoking the dynamic block if this file
# is not needed. If so, we may have all the information
# we need in the manifest file.
- if !needed? && manifest_entry
- mtime = manifest_entry.mtime
+ if !needed? && last_manifest_entry
+ mtime = last_manifest_entry.mtime
end
# If the output file of this task still exists and
@@ -177,7 +181,7 @@ def dynamic_prerequisites_from_manifest
# come from the return value of the dynamic block
# in a previous run.
if File.exist?(name) && mtime == File.mtime(name)
- return manifest_entry.deps.map { |k,v| k }
+ return last_manifest_entry.deps.map { |k,v| k }
end
end
View
7 lib/rake-pipeline/filter.rb
@@ -72,7 +72,7 @@ class Filter
# this filter.
attr_accessor :pipeline
- attr_writer :manifest
+ attr_writer :manifest, :last_manifest
attr_writer :file_wrapper_class
@@ -91,6 +91,10 @@ def manifest
@manifest || pipeline.manifest
end
+ def last_manifest
+ @last_manifest || pipeline.last_manifest
+ end
+
# Invoke this method in a subclass of Filter to declare that
# it expects to work with BINARY data, and that data that is
# not valid UTF-8 should be allowed.
@@ -224,6 +228,7 @@ def encoding
def create_file_task(output, deps=[], &block)
task = rake_application.define_task(Rake::Pipeline::DynamicFileTask, output => deps, &block)
task.manifest = manifest
+ task.last_manifest = last_manifest
task
end
View
8 lib/rake-pipeline/project.rb
@@ -117,7 +117,7 @@ def invoke
end
end
- manifest.read_manifest
+ last_manifest.read_manifest
pipelines.each(&:invoke)
manifest.write_manifest
end
@@ -215,6 +215,12 @@ def manifest
@manifest ||= Rake::Pipeline::Manifest.new(manifest_path)
end
+ # @return [Manifest] the manifest to write dependency information
+ # to
+ def last_manifest
+ @last_manifest ||= Rake::Pipeline::Manifest.new(manifest_path)
+ end
+
# @return [String] the path to the dynamic dependency manifest
def manifest_path
File.join(digested_tmpdir, "manifest.json")
View
1  spec/concat_filter_spec.rb
@@ -12,6 +12,7 @@
it "generates output" do
filter = Rake::Pipeline::ConcatFilter.new { "application.js" }
filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.file_wrapper_class = MemoryFileWrapper
filter.output_root = "/path/to/output"
filter.input_files = input_files
View
2  spec/dynamic_file_task_spec.rb
@@ -115,7 +115,7 @@ def make_file(name, mtime=nil)
})
task.dynamic { %w[] }
- task.stub(:manifest_entry) { manifest_entry }
+ task.stub(:last_manifest_entry) { manifest_entry }
task.should_not_receive(:invoke_dynamic_block)
task.dynamic_prerequisites.should == %w[blinky]
end
View
4 spec/filter_spec.rb
@@ -1,4 +1,6 @@
describe "Rake::Pipeline::Filter" do
+ MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
+
after do
# Clean out all defined tasks after each test runs
Rake.application = Rake::Application.new
@@ -287,6 +289,7 @@ def write_input_file(filename, contents='', root=input_root)
def invoke_filter(filter)
mkdir_p output_root
filter.pipeline = pipeline
+ filter.last_manifest = MemoryManifest.new
filter.output_root = output_root
filter.input_files = input_files
tasks = filter.generate_rake_tasks
@@ -318,6 +321,7 @@ def invoke_filter(filter)
it "rebuilds the main file when a dynamic dependency changes" do
invoke_filter(filter)
sleep 1
+ $LATCH = true
File.open(header.fullpath, 'w') { |f| f.puts 'PEANUTS' }
filter.rake_tasks.each { |t| t.recursively_reenable(Rake.application) }
invoke_filter(filter)
View
3  spec/gsub_filter_spec.rb
@@ -16,6 +16,7 @@
filter.file_wrapper_class = MemoryFileWrapper
filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.output_root = "/path/to/output"
filter.input_files = input_files
@@ -38,6 +39,7 @@
filter.rake_application = rake_application
filter.file_wrapper_class = MemoryFileWrapper
filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.output_root = "/path/to/output"
filter.input_files = input_files
@@ -60,6 +62,7 @@
filter.rake_application = rake_application
filter.file_wrapper_class = MemoryFileWrapper
filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.output_root = "/path/to/output"
filter.input_files = input_files
View
1  spec/ordering_concat_filter_spec.rb
@@ -23,6 +23,7 @@
def make_filter(ordering)
filter = Rake::Pipeline::OrderingConcatFilter.new(ordering, "all.txt")
filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.file_wrapper_class = MemoryFileWrapper
filter.input_files = input_files
filter.output_root = "/path/to/output"
View
18 spec/project_spec.rb
@@ -104,7 +104,7 @@ def modify_assetfile
file.write(MODIFIED_ASSETFILE_SOURCE)
end
end
-
+
it "creates output files" do
output_files.each { |file| file.should_not exist }
project.invoke
@@ -117,11 +117,11 @@ def modify_assetfile
end
it "updates the manifest" do
- project.manifest.should_receive(:read_manifest)
+ project.last_manifest.should_receive(:read_manifest)
project.manifest.should_receive(:write_manifest)
project.invoke
end
-
+
it "rebuilds its pipeline when the Assetfile changes" do
project.invoke
original_pipeline = project.pipelines.last
@@ -146,18 +146,6 @@ def modify_assetfile
end
end
- describe "#invoke" do
- context "if the Assetfile contents have changed" do
-
- end
-
- it "updates the manifest" do
- project.manifest.should_receive(:read_manifest)
- project.manifest.should_receive(:write_manifest)
- project.invoke
- end
- end
-
describe "#cleanup_tmpdir" do
it "cleans old rake-pipeline-* dirs out of the pipeline's tmp dir" do
File.exist?(old_tmpdir).should be_true
View
8 spec/rake_acceptance_spec.rb
@@ -107,12 +107,14 @@ def copy_files
it "can successfully apply filters" do
concat = concat_filter.new
concat.manifest = memory_manifest.new
+ concat.last_manifest = memory_manifest.new
concat.input_files = INPUTS.keys.select { |key| key =~ /javascript/ }.map { |file| input_wrapper(file) }
concat.output_root = File.join(tmp, "temporary", "concat_filter")
concat.output_name_generator = proc { |input| "javascripts/application.js" }
strip_asserts = strip_asserts_filter.new
strip_asserts.manifest = memory_manifest.new
+ strip_asserts.last_manifest = memory_manifest.new
strip_asserts.input_files = concat.output_files
strip_asserts.output_root = File.join(tmp, "public")
strip_asserts.output_name_generator = proc { |input| input }
@@ -127,12 +129,14 @@ def copy_files
it "supports filters with multiple outputs per input" do
concat = concat_filter.new
concat.manifest = memory_manifest.new
+ concat.last_manifest = memory_manifest.new
concat.input_files = INPUTS.keys.select { |key| key =~ /javascript/ }.map { |file| input_wrapper(file) }
concat.output_root = File.join(tmp, "temporary", "concat_filter")
concat.output_name_generator = proc { |input| [ "javascripts/application.js", input.sub(/^app\//, '') ] }
strip_asserts = strip_asserts_filter.new
strip_asserts.manifest = memory_manifest.new
+ strip_asserts.last_manifest = memory_manifest.new
strip_asserts.input_files = concat.output_files
strip_asserts.output_root = File.join(tmp, "public")
strip_asserts.output_name_generator = proc { |input| input }
@@ -165,10 +169,12 @@ def copy_files
concat = concat_filter.new
concat.manifest = memory_manifest.new
+ concat.last_manifest = memory_manifest.new
concat.output_name_generator = proc { |input| "javascripts/application.js" }
strip_asserts = strip_asserts_filter.new
strip_asserts.manifest = memory_manifest.new
+ strip_asserts.last_manifest = memory_manifest.new
strip_asserts.output_name_generator = proc { |input| input }
pipeline.add_filters(concat, strip_asserts)
@@ -619,7 +625,7 @@ def output_should_exist(expected=EXPECTED_JS_OUTPUT)
end
end
- project.invoke_clean
+ project.invoke
output_should_exist
end
Please sign in to comment.
Something went wrong with that request. Please try again.