Merge pull request #1556 from maul-esel/dest-match
Fix up matching against source and destination when the two locations are similar.
This commit is contained in:
commit
de49342324
|
@ -18,6 +18,27 @@ Feature: Site configuration
|
||||||
Then the _mysite directory should exist
|
Then the _mysite directory should exist
|
||||||
And I should see "Changing destination directory" in "_mysite/index.html"
|
And I should see "Changing destination directory" in "_mysite/index.html"
|
||||||
|
|
||||||
|
Scenario Outline: Similarly named source and destination
|
||||||
|
Given I have a blank site in "<source>"
|
||||||
|
And I have an "<source>/index.md" page that contains "markdown"
|
||||||
|
And I have a configuration file with:
|
||||||
|
| key | value |
|
||||||
|
| source | <source> |
|
||||||
|
| destination | <dest> |
|
||||||
|
When I run jekyll
|
||||||
|
Then the <source> directory should exist
|
||||||
|
And the "<dest>/index.html" file should <file_exist> exist
|
||||||
|
And I should see "markdown" in "<source>/index.md"
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| source | dest | file_exist |
|
||||||
|
| mysite_source | mysite | |
|
||||||
|
| mysite | mysite_dest | |
|
||||||
|
| mysite/ | mysite | not |
|
||||||
|
| mysite | ./mysite | not |
|
||||||
|
| mysite/source | mysite | not |
|
||||||
|
| mysite | mysite/dest | |
|
||||||
|
|
||||||
Scenario: Exclude files inline
|
Scenario: Exclude files inline
|
||||||
Given I have an "Rakefile" file that contains "I want to be excluded"
|
Given I have an "Rakefile" file that contains "I want to be excluded"
|
||||||
And I have an "README" file that contains "I want to be excluded"
|
And I have an "README" file that contains "I want to be excluded"
|
||||||
|
|
|
@ -7,7 +7,7 @@ end
|
||||||
World(Test::Unit::Assertions)
|
World(Test::Unit::Assertions)
|
||||||
|
|
||||||
Given /^I have a blank site in "(.*)"$/ do |path|
|
Given /^I have a blank site in "(.*)"$/ do |path|
|
||||||
FileUtils.mkdir(path)
|
FileUtils.mkdir_p(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^I do not have a "(.*)" directory$/ do |path|
|
Given /^I do not have a "(.*)" directory$/ do |path|
|
||||||
|
@ -137,10 +137,14 @@ When /^I delete the file "(.*)"$/ do |file|
|
||||||
File.delete(file)
|
File.delete(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the (.*) directory should exist$/ do |dir|
|
Then /^the (.*) directory should +exist$/ do |dir|
|
||||||
assert File.directory?(dir), "The directory \"#{dir}\" does not exist"
|
assert File.directory?(dir), "The directory \"#{dir}\" does not exist"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then /^the (.*) directory should not exist$/ do |dir|
|
||||||
|
assert !File.directory?(dir), "The directory \"#{dir}\" exists"
|
||||||
|
end
|
||||||
|
|
||||||
Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
|
Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
|
||||||
assert Regexp.new(text).match(File.open(file).readlines.join)
|
assert Regexp.new(text).match(File.open(file).readlines.join)
|
||||||
end
|
end
|
||||||
|
@ -157,12 +161,12 @@ Then /^I should see escaped "(.*)" in "(.*)"$/ do |text, file|
|
||||||
assert Regexp.new(Regexp.escape(text)).match(File.open(file).readlines.join)
|
assert Regexp.new(Regexp.escape(text)).match(File.open(file).readlines.join)
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the "(.*)" file should exist$/ do |file|
|
Then /^the "(.*)" file should +exist$/ do |file|
|
||||||
assert File.file?(file)
|
assert File.file?(file), "The file \"#{file}\" does not exist"
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the "(.*)" file should not exist$/ do |file|
|
Then /^the "(.*)" file should not exist$/ do |file|
|
||||||
assert !File.exists?(file)
|
assert !File.exists?(file), "The file \"#{file}\" exists"
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see today's time in "(.*)"$/ do |file|
|
Then /^I should see today's time in "(.*)"$/ do |file|
|
||||||
|
|
|
@ -63,11 +63,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
def setup
|
def setup
|
||||||
# Check that the destination dir isn't the source dir or a directory
|
ensure_not_in_dest
|
||||||
# parent to the source dir.
|
|
||||||
if self.source =~ /^#{self.dest}/
|
|
||||||
raise FatalException.new "Destination directory cannot be or contain the Source directory."
|
|
||||||
end
|
|
||||||
|
|
||||||
# If safe mode is off, load in any Ruby files under the plugins
|
# If safe mode is off, load in any Ruby files under the plugins
|
||||||
# directory.
|
# directory.
|
||||||
|
@ -83,6 +79,17 @@ module Jekyll
|
||||||
self.generators = instantiate_subclasses(Jekyll::Generator)
|
self.generators = instantiate_subclasses(Jekyll::Generator)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Check that the destination dir isn't the source dir or a directory
|
||||||
|
# parent to the source dir.
|
||||||
|
def ensure_not_in_dest
|
||||||
|
dest = Pathname.new(self.dest)
|
||||||
|
Pathname.new(self.source).ascend do |path|
|
||||||
|
if path == dest
|
||||||
|
raise FatalException.new "Destination directory cannot be or contain the Source directory."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Internal: Setup the plugin search path
|
# Internal: Setup the plugin search path
|
||||||
#
|
#
|
||||||
# Returns an Array of plugin search paths
|
# Returns an Array of plugin search paths
|
||||||
|
|
Loading…
Reference in New Issue