mirror of https://github.com/tailix/libkernaux.git
mruby: generate tests for cmdline
This commit is contained in:
parent
51df4b9c20
commit
5c2f3bf92c
|
@ -25,6 +25,10 @@ Metrics/BlockLength:
|
||||||
- 'Rakefile'
|
- 'Rakefile'
|
||||||
- 'test/**/*.rb'
|
- 'test/**/*.rb'
|
||||||
|
|
||||||
|
Security/Eval:
|
||||||
|
Exclude:
|
||||||
|
- 'test/**/*.rb'
|
||||||
|
|
||||||
Security/YAMLLoad:
|
Security/YAMLLoad:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'test/**/*.rb'
|
- 'test/**/*.rb'
|
||||||
|
@ -39,6 +43,10 @@ Style/Documentation:
|
||||||
Style/DoubleNegation:
|
Style/DoubleNegation:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
Style/ExpandPathArguments:
|
||||||
|
# __dir__ is not available in mruby
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
Style/FrozenStringLiteralComment:
|
Style/FrozenStringLiteralComment:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ MRuby::Gem::Specification.new 'mruby-kernaux' do |spec|
|
||||||
Binding to libkernaux - auxiliary library for kernel development.
|
Binding to libkernaux - auxiliary library for kernel development.
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
|
|
||||||
|
spec.add_test_dependency 'mruby-eval'
|
||||||
spec.add_test_dependency 'mruby-io'
|
spec.add_test_dependency 'mruby-io'
|
||||||
spec.add_test_dependency 'mruby-random'
|
spec.add_test_dependency 'mruby-random'
|
||||||
spec.add_test_dependency 'mruby-yaml'
|
spec.add_test_dependency 'mruby-yaml'
|
||||||
|
|
|
@ -68,3 +68,22 @@ assert 'when args cause buffer overflow' do
|
||||||
KernAux.cmdline 'a' * 4096
|
KernAux.cmdline 'a' * 4096
|
||||||
end
|
end
|
||||||
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…
Reference in New Issue