mirror of
https://github.com/tailix/libkernaux.git
synced 2025-04-21 17:42:26 -04:00
mruby: generate tests for cmdline
This commit is contained in:
parent
51df4b9c20
commit
5c2f3bf92c
3 changed files with 28 additions and 0 deletions
|
@ -25,6 +25,10 @@ Metrics/BlockLength:
|
|||
- 'Rakefile'
|
||||
- 'test/**/*.rb'
|
||||
|
||||
Security/Eval:
|
||||
Exclude:
|
||||
- 'test/**/*.rb'
|
||||
|
||||
Security/YAMLLoad:
|
||||
Exclude:
|
||||
- 'test/**/*.rb'
|
||||
|
@ -39,6 +43,10 @@ Style/Documentation:
|
|||
Style/DoubleNegation:
|
||||
Enabled: false
|
||||
|
||||
Style/ExpandPathArguments:
|
||||
# __dir__ is not available in mruby
|
||||
Enabled: false
|
||||
|
||||
Style/FrozenStringLiteralComment:
|
||||
Enabled: false
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ MRuby::Gem::Specification.new 'mruby-kernaux' do |spec|
|
|||
Binding to libkernaux - auxiliary library for kernel development.
|
||||
DESCRIPTION
|
||||
|
||||
spec.add_test_dependency 'mruby-eval'
|
||||
spec.add_test_dependency 'mruby-io'
|
||||
spec.add_test_dependency 'mruby-random'
|
||||
spec.add_test_dependency 'mruby-yaml'
|
||||
|
|
|
@ -68,3 +68,22 @@ assert 'when args cause buffer overflow' do
|
|||
KernAux.cmdline 'a' * 4096
|
||||
end
|
||||
end
|
||||
|
||||
assert 'usign common tests' do
|
||||
cmdline_yml = File.expand_path('../../../../common/cmdline.yml', __FILE__)
|
||||
|
||||
YAML.load(File.read(cmdline_yml)).each do |test|
|
||||
next unless test['argv_count_max'].nil? && test['buffer_size'].nil?
|
||||
|
||||
escape_str = lambda do |str|
|
||||
eval "\"#{str}\"", nil, __FILE__, __LINE__ # "str"
|
||||
end
|
||||
|
||||
cmdline = escape_str.call test['cmdline']
|
||||
result = test['result'].map(&escape_str)
|
||||
|
||||
assert "transforms #{cmdline.inspect} to #{result.inspect}" do
|
||||
assert_equal KernAux.cmdline(cmdline), result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue