mirror of
https://github.com/tailix/libkernaux.git
synced 2025-03-03 16:04:29 -05:00
Ruby: generate tests for cmdline
This commit is contained in:
parent
619f7004e0
commit
51df4b9c20
2 changed files with 23 additions and 0 deletions
|
@ -42,6 +42,10 @@ RSpec/FilePath:
|
|||
RSpec/ExampleLength:
|
||||
CountAsOne: ['array', 'hash', 'heredoc']
|
||||
|
||||
Security/Eval:
|
||||
Exclude:
|
||||
- 'spec/**/*_spec.rb'
|
||||
|
||||
Style/AndOr:
|
||||
EnforcedStyle: conditionals
|
||||
|
||||
|
|
|
@ -90,4 +90,23 @@ KernAux::Version.supports_cmdline? and RSpec.describe KernAux, '.cmdline' do
|
|||
raise_error described_class::CmdlineError, 'buffer overflow'
|
||||
end
|
||||
end
|
||||
|
||||
context 'using common tests' do
|
||||
cmdline_yml = File.expand_path('../../../../../common/cmdline.yml', __dir__)
|
||||
|
||||
YAML.safe_load_file(cmdline_yml).each do |test|
|
||||
next unless test['argv_count_max'].nil? && test['buffer_size'].nil?
|
||||
|
||||
escape_str = lambda do |str|
|
||||
eval "\"#{str}\"", binding, __FILE__, __LINE__ # "str"
|
||||
end
|
||||
|
||||
cmdline = escape_str.call test['cmdline']
|
||||
result = test['result'].map(&escape_str)
|
||||
|
||||
it "transforms #{cmdline.inspect} to #{result.inspect}" do
|
||||
expect(described_class.cmdline(cmdline)).to eq result
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue