outputting full path when file does not parse
This commit is contained in:
parent
dd0e208daa
commit
ba48870ead
|
@ -33,9 +33,9 @@ module Jekyll
|
||||||
self.data = YAML.load($1)
|
self.data = YAML.load($1)
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
puts "Error reading file #{name}: #{e.message}"
|
puts "Error reading file #{File.join(base,name)}: #{e.message}"
|
||||||
rescue SyntaxError => e
|
rescue SyntaxError => e
|
||||||
puts "YAML Exception reading #{name}: #{e.message}"
|
puts "YAML Exception reading #{File.join(base,name)}: #{e.message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
self.data ||= {}
|
self.data ||= {}
|
||||||
|
|
|
@ -20,20 +20,26 @@ class TestConvertible < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not parse if there is syntax error in front-matter" do
|
should "not parse if there is syntax error in front-matter" do
|
||||||
|
@name = 'broken_front_matter2.erb'
|
||||||
out = capture_stdout do
|
out = capture_stdout do
|
||||||
ret = @convertible.read_yaml(@base, 'broken_front_matter2.erb')
|
ret = @convertible.read_yaml(@base, @name)
|
||||||
assert_equal({}, ret)
|
assert_equal({}, ret)
|
||||||
end
|
end
|
||||||
assert_match(/YAML Exception|syntax error/, out)
|
assert_match(/YAML Exception|syntax error/, out)
|
||||||
|
assert_match(/#{@base}/, out)
|
||||||
|
assert_match(/#{@name}/, out)
|
||||||
end
|
end
|
||||||
|
|
||||||
if RUBY_VERSION >= '1.9.2'
|
if RUBY_VERSION >= '1.9.2'
|
||||||
should "not parse if there is encoding error in file" do
|
should "not parse if there is encoding error in file" do
|
||||||
|
@name = 'broken_front_matter3.erb'
|
||||||
out = capture_stdout do
|
out = capture_stdout do
|
||||||
ret = @convertible.read_yaml(@base, 'broken_front_matter3.erb')
|
ret = @convertible.read_yaml(@base, @name)
|
||||||
assert_equal({}, ret)
|
assert_equal({}, ret)
|
||||||
end
|
end
|
||||||
assert_match(/invalid byte sequence in UTF-8/, out)
|
assert_match(/invalid byte sequence in UTF-8/, out)
|
||||||
|
assert_match(/#{@base}/, out)
|
||||||
|
assert_match(/#{@name}/, out)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue