ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects
http://throwtheswitch.org
Other
593 stars 247 forks source link

Improve Error Messages #778

Open informatimago opened 1 year ago

informatimago commented 1 year ago

Assume the user writes this in his project.yml file:

  :gcov_fixture:
    :executable: /some/executable
    :arguments: ${1}

then we'd get this error:

rake aborted!
NoMethodError: undefined method `flatten' for "${1}":String

    config.flatten.each do |element|
          ^^^^^^^^
/home/pbourguignon/works/harman/Ceedling/lib/ceedling/tool_executor.rb:107:in `build_arguments'
/home/pbourguignon/works/harman/Ceedling/lib/ceedling/tool_executor.rb:38:in `build_command_line'
/home/pbourguignon/works/harman/Ceedling/lib/ceedling/generator.rb:172:in `generate_test_results'
vendor/ceedling/plugins/gcov/gcov.rake:48:in `block in <top (required)>'
/home/pbourguignon/works/harman/Ceedling/lib/ceedling/task_invoker.rb:107:in `invoke_test_results'
/home/pbourguignon/works/harman/Ceedling/lib/ceedling/test_invoker.rb:125:in `block in setup_and_invoke'
/home/pbourguignon/works/harman/Ceedling/lib/ceedling/test_invoker.rb:51:in `each'
/home/pbourguignon/works/harman/Ceedling/lib/ceedling/test_invoker.rb:51:in `setup_and_invoke'
vendor/ceedling/plugins/gcov/gcov.rake:138:in `block (2 levels) in <top (required)>'
/home/pbourguignon/works/harman/Ceedling/bin/ceedling:361:in `block in <main>'
/home/pbourguignon/works/harman/Ceedling/bin/ceedling:348:in `<main>'

It should be possible to improve the error message issued in this kind of cases, and perhaps write something like:

While invoking gcov_fixture, the arguments to the executable "/some/executable" should be an array of strings instead of a flat string. Try ["${1}"] or put each argument on its line prefixed with a dash: - "${1}"

This should help new users to get on with ceedling.

mvandervoord commented 1 year ago

:) agreed.

Even better would be to just accept the alternative as a single argument.