Merge pull request #862 from mojombo/fix-autogen-dest-prob
Stop DirectoryWatcher from watching the destination directory
This commit is contained in:
commit
6c1a08ce87
|
@ -3,7 +3,7 @@ module Jekyll
|
|||
def self.globs(source, destination)
|
||||
Dir.chdir(source) do
|
||||
dirs = Dir['*'].select { |x| File.directory?(x) }
|
||||
dirs -= [destination]
|
||||
dirs -= [destination, File.expand_path(destination), File.basename(destination)]
|
||||
dirs = dirs.map { |x| "#{x}/**/*" }
|
||||
dirs += ['*']
|
||||
end
|
||||
|
|
|
@ -28,17 +28,27 @@ class Test::Unit::TestCase
|
|||
include RR::Adapters::TestUnit
|
||||
|
||||
def dest_dir(*subdirs)
|
||||
File.join(File.dirname(__FILE__), 'dest', *subdirs)
|
||||
test_dir('dest', *subdirs)
|
||||
end
|
||||
|
||||
def source_dir(*subdirs)
|
||||
File.join(File.dirname(__FILE__), 'source', *subdirs)
|
||||
test_dir('source', *subdirs)
|
||||
end
|
||||
|
||||
def clear_dest
|
||||
FileUtils.rm_rf(dest_dir)
|
||||
end
|
||||
|
||||
def test_dir(*subdirs)
|
||||
File.join(File.dirname(__FILE__), *subdirs)
|
||||
end
|
||||
|
||||
def directory_with_contents(path)
|
||||
FileUtils.rm_rf(path)
|
||||
FileUtils.mkdir(path)
|
||||
File.open("#{path}/index.html", "w"){ |f| f.write("I was previously generated.") }
|
||||
end
|
||||
|
||||
def capture_stdout
|
||||
$old_stdout = $stdout
|
||||
$stdout = StringIO.new
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
require 'helper'
|
||||
|
||||
class TestCommand < Test::Unit::TestCase
|
||||
context "when calling .globs" do
|
||||
context "when non-default dest & source dirs" do
|
||||
setup do
|
||||
@source = source_dir
|
||||
@dest = dest_dir
|
||||
directory_with_contents(@dest)
|
||||
@globs = Command.globs(@source, @dest)
|
||||
end
|
||||
should "return an array without the destination dir" do
|
||||
assert @globs.is_a?(Array)
|
||||
assert !@globs.include?(@dest)
|
||||
end
|
||||
teardown do
|
||||
clear_dest
|
||||
end
|
||||
end
|
||||
context "when using default dest dir" do
|
||||
setup do
|
||||
@source = test_dir
|
||||
@dest = test_dir('_site')
|
||||
directory_with_contents(@dest)
|
||||
@globs = Command.globs(@source, @dest)
|
||||
end
|
||||
should "return an array without the destination dir" do
|
||||
assert @globs.is_a?(Array)
|
||||
assert !@globs.include?(@dest)
|
||||
@globs.each do |glob|
|
||||
assert !glob.include?(File.basename(@dest))
|
||||
end
|
||||
end
|
||||
teardown do
|
||||
FileUtils.rm_r(@dest)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue