Fix failing tests
This commit is contained in:
parent
d438362971
commit
fe6bfc6f1b
|
@ -13,6 +13,7 @@ module Jekyll
|
|||
# Cleans up the site's destination directory
|
||||
def cleanup!
|
||||
FileUtils.rm_rf(obsolete_files)
|
||||
FileUtils.rm_rf(metadata_file) if @site.config["clean"]
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -21,7 +22,7 @@ module Jekyll
|
|||
#
|
||||
# Returns an Array of the file and directory paths
|
||||
def obsolete_files
|
||||
(existing_files - new_files - new_dirs + replaced_files + metadata_file).to_a
|
||||
(existing_files - new_files - new_dirs + replaced_files).to_a
|
||||
end
|
||||
|
||||
# Private: The metadata file storing dependency tree and build history
|
||||
|
|
|
@ -33,10 +33,18 @@ module Jekyll
|
|||
@cache[path] = true
|
||||
end
|
||||
|
||||
# Clear the metadata and cache
|
||||
#
|
||||
# Returns nothing
|
||||
def clear
|
||||
@metadata = {}
|
||||
@cache = {}
|
||||
end
|
||||
|
||||
# Checks if a path should be regenerated
|
||||
#
|
||||
# Returns a boolean.
|
||||
def regenerate?(path)
|
||||
def regenerate?(path, add = true)
|
||||
# Check for path in cache
|
||||
if @cache.has_key? path
|
||||
return @cache[path]
|
||||
|
@ -52,18 +60,19 @@ module Jekyll
|
|||
if data["mtime"] == File.mtime(path)
|
||||
return @cache[path] = false
|
||||
else
|
||||
return add(path)
|
||||
return !add || add(path)
|
||||
end
|
||||
end
|
||||
|
||||
# Path does not exist in metadata, add it
|
||||
return add(path)
|
||||
return !add || add(path)
|
||||
end
|
||||
|
||||
# Add a dependency of a path
|
||||
#
|
||||
# Returns nothing.
|
||||
def add_dependency(path, dependency)
|
||||
add(path) if @metadata[path].nil?
|
||||
@metadata[path]["deps"] << dependency unless @metadata[path]["deps"].include? dependency
|
||||
regenerate? dependency
|
||||
end
|
||||
|
|
|
@ -142,7 +142,7 @@ module Jekyll
|
|||
site.metadata.add_dependency(
|
||||
Jekyll.sanitized_path(site.source, document.path),
|
||||
Jekyll.sanitized_path(site.source, layout.path)
|
||||
)
|
||||
) if document.write?
|
||||
|
||||
if layout = site.layouts[layout.data["layout"]]
|
||||
if used.include?(layout)
|
||||
|
|
|
@ -53,7 +53,7 @@ module Jekyll
|
|||
read
|
||||
generate
|
||||
render
|
||||
cleanup if config['clean']
|
||||
cleanup
|
||||
write
|
||||
end
|
||||
|
||||
|
@ -294,10 +294,9 @@ module Jekyll
|
|||
collections.each do |label, collection|
|
||||
collection.docs.each do |document|
|
||||
document.output = Jekyll::Renderer.new(self, document).run if (
|
||||
@metadata.regenerate?(document.path) ||
|
||||
@metadata.regenerate?(document.path, document.write?) ||
|
||||
document.data['regenerate']
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -115,10 +115,12 @@ eos
|
|||
validate_path(path, dir, site.safe)
|
||||
|
||||
# Add include to dependency tree
|
||||
site.metadata.add_dependency(
|
||||
Jekyll.sanitized_path(site.source, context.registers[:page]["path"]),
|
||||
path
|
||||
)
|
||||
if context.registers[:page] and context.registers[:page].has_key? "path"
|
||||
site.metadata.add_dependency(
|
||||
Jekyll.sanitized_path(site.source, context.registers[:page]["path"]),
|
||||
path
|
||||
)
|
||||
end
|
||||
|
||||
begin
|
||||
partial = Liquid::Template.parse(source(path, context))
|
||||
|
|
|
@ -46,6 +46,7 @@ class Test::Unit::TestCase
|
|||
|
||||
def clear_dest
|
||||
FileUtils.rm_rf(dest_dir)
|
||||
FileUtils.rm_rf(source_dir('.jekyll-metadata'))
|
||||
end
|
||||
|
||||
def test_dir(*subdirs)
|
||||
|
|
|
@ -246,7 +246,8 @@ class TestDocument < Test::Unit::TestCase
|
|||
}
|
||||
},
|
||||
"source" => source_dir,
|
||||
"destination" => dest_dir
|
||||
"destination" => dest_dir,
|
||||
"clean" => true
|
||||
}))
|
||||
@site.process
|
||||
@document = @site.collections["slides"].files.find { |doc| doc.relative_path == "_slides/octojekyll.png" }
|
||||
|
|
|
@ -99,6 +99,7 @@ class TestSite < Test::Unit::TestCase
|
|||
should "write only modified static files" do
|
||||
clear_dest
|
||||
StaticFile.reset_cache
|
||||
@site.metadata.clear
|
||||
|
||||
@site.process
|
||||
some_static_file = @site.static_files[0].path
|
||||
|
@ -128,6 +129,7 @@ class TestSite < Test::Unit::TestCase
|
|||
should "write static files if not modified but missing in destination" do
|
||||
clear_dest
|
||||
StaticFile.reset_cache
|
||||
@site.metadata.clear
|
||||
|
||||
@site.process
|
||||
some_static_file = @site.static_files[0].path
|
||||
|
@ -241,6 +243,7 @@ class TestSite < Test::Unit::TestCase
|
|||
context 'with orphaned files in destination' do
|
||||
setup do
|
||||
clear_dest
|
||||
@site.metadata.clear
|
||||
@site.process
|
||||
# generate some orphaned files:
|
||||
# single file
|
||||
|
@ -328,7 +331,7 @@ class TestSite < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
bad_processor = "Custom::Markdown"
|
||||
s = Site.new(site_configuration('markdown' => bad_processor))
|
||||
s = Site.new(site_configuration('markdown' => bad_processor, 'clean' => true))
|
||||
assert_raise Jekyll::Errors::FatalException do
|
||||
s.process
|
||||
end
|
||||
|
@ -348,7 +351,7 @@ class TestSite < Test::Unit::TestCase
|
|||
|
||||
should 'throw FatalException at process time' do
|
||||
bad_processor = 'not a processor name'
|
||||
s = Site.new(site_configuration('markdown' => bad_processor))
|
||||
s = Site.new(site_configuration('markdown' => bad_processor, 'clean' => true))
|
||||
assert_raise Jekyll::Errors::FatalException do
|
||||
s.process
|
||||
end
|
||||
|
@ -418,7 +421,9 @@ class TestSite < Test::Unit::TestCase
|
|||
|
||||
context "manipulating the Jekyll environment" do
|
||||
setup do
|
||||
@site = Site.new(site_configuration)
|
||||
@site = Site.new(site_configuration({
|
||||
"clean" => true
|
||||
}))
|
||||
@site.process
|
||||
@page = @site.pages.find { |p| p.name == "environment.html" }
|
||||
end
|
||||
|
@ -430,7 +435,9 @@ class TestSite < Test::Unit::TestCase
|
|||
context "in production" do
|
||||
setup do
|
||||
ENV["JEKYLL_ENV"] = "production"
|
||||
@site = Site.new(site_configuration)
|
||||
@site = Site.new(site_configuration({
|
||||
"clean" => true
|
||||
}))
|
||||
@site.process
|
||||
@page = @site.pages.find { |p| p.name == "environment.html" }
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue