mruby: generate tests for cmdline

This commit is contained in:
Alex Kotov 2022-06-08 02:31:43 +03:00
parent 51df4b9c20
commit 5c2f3bf92c
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
3 changed files with 28 additions and 0 deletions

View File

@ -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

View File

@ -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'

View File

@ -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