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