Skip to content

Commit

Permalink
fixup! Add StaticConfigAnalysis
Browse files Browse the repository at this point in the history
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
  • Loading branch information
ganmacs committed Dec 18, 2019
1 parent ce616a0 commit 4ea8f1c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/fluent/static_config_analysis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ def static_label_analyse(conf)
ret = []
conf.elements(name: 'label').each do |e|
name = e.arg
if name.empty?
raise ConfigError, 'Missing symbol argument on <label> directive'
end

if @labels[name]
raise ConfigError, "Section <label #{name}> appears twice"
end
Expand Down
13 changes: 13 additions & 0 deletions test/test_static_config_analysis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ class StaticConfigAnalysisTest < ::Test::Unit::TestCase
end
end

test 'empty label' do
conf_data = <<-CONF
<label>
</label>
CONF

c = Fluent::Config.parse(conf_data, '(test)', '(test_dir)', true)
assert_raise(Fluent::ConfigError.new('Missing symbol argument on <label> directive')) do
Fluent::StaticConfigAnalysis.call(c, workers: 2)
end
end


data(
'in filter' => 'filter',
'in source' => 'source',
Expand Down

0 comments on commit 4ea8f1c

Please sign in to comment.