Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Intro
Thank you @mity for a great tool that I use for every bit of C I work with.
I wanted to get into contributing to open source projects for practice and internet points. Working on something I have a passion for and am familiar with seemed like a good place to start.
I have implemented the cmd line option for changing message output limit at run-time.
Resolves #33
New features
Added run-time option to change the max output message length without having to recompile. Features:
--max-msg=NUMBER
TEST_MSG_MAXSIZE
is kept and used as default. It can still be defined before acutest include.--help
line for--max-msg
usageTested with:
x64 Windows: gcc -Wall -Wextra -pedantic.
Recreate issue and Verify solution
A test rig was setup to recreate a character limited test message.
Length of test message was larger than
TEST_MSG_MAXSIZE
(1024), increased to (1024 + 200 - 24) = 1200 characters (for a nice round number).On a failing test, as shown below, the # symbols represent long
TEST_MSG
output. As expected, the character count is 1024 - 1 (null terminated), defined byTEST_MSG_MAXSIZE
. It does not show the final sentence, confirming the long message output is limited by the compile-time defined value.Normal default length limited output:
Using the new run-time option
--max-msg=1200
, the full message can be seen without having to recompile. It includes the closing words right up to the final period, verifying intended behaviour.Run-time option extended output:
Re-compiling with pre-defined
TEST_MSG_MAXSIZE 1200
is confirmed to still operate as expected, needing no option to show full message.Compile-time define extended output:
Bad input argument behaviour
There are several possible arg errors, nonsense input or genuine user misunderstanding. eg. user could misinterpret "--max-msg" is to set max possible etc. To handle these type of cases, the
acutest_cmdline_options_
argument field was set toACUTEST_CMDLINE_OPTFLAG_REQUIREDARG_
. Other bad input is handled by setting exit value and usage hint output, matching other options.Bad arg outputs:
--help
options output includes--max-msg
line:Conclusion
This implementation meets requirements and is sufficiently verified for expected behaviour and error handling (IMO). I have not tested on other machines although I do not see these changes causing any problem. I will provide an update if anything arises from that testing.
Issue #34 is an equivalent feature for TEST_DUMP_MAXSIZE. I think it would be best to have that implemented for consistency. I'm happy to do that one next.