ext/readline: write test for readline CLI - #22994
Conversation
|
looks good but please wait for someone else review, I m definitely not the most appropriate person for this extension. |
|
One of them is masking a real bug.
|
| proc_close($proc); | ||
| ?> | ||
| --EXPECTF-- | ||
| %Apager output%A |
There was a problem hiding this comment.
This expectation cannot fail. Set cli.pager to a command that never runs and pager output still appears, echoed from the input line.
A pager that transforms its input pins it instead:
-d cli.pager='tr a-z A-Z'
with %APAGER OUTPUT%A, which nothing but the pager can produce.
| proc_close($proc); | ||
| ?> | ||
| --EXPECTF-- | ||
| %AInteractive shell%Asingle%Adouble%APAREN%A3%Ablock%Acomment%Aattribute%Aoutside-%Ainside%A |
There was a problem hiding this comment.
single, double, block, comment, attribute, inside and outside- all appear in the lines written to stdin, so they match the echo whether or not the shell evaluates anything.
PAREN is the one that holds, because strtoupper() makes the output differ from the source. Same trick on the rest would make the file assert what it says it does.
%A3%A is also thin on its own, since a single digit matches a line number or a version string. echo 6/2 + 100; and 103 is harder to hit by accident.
| public static function completionMethod() { echo "method\n"; } | ||
| } | ||
| echo ReadlineCliCompletionCla ::class . "\n"; | ||
| echo ReadlineCliCompletionClass::COMPLETION_CLASS_CON ; |
There was a problem hiding this comment.
The class constant case does not complete. This run leaves Uncaught Error: Undefined constant ReadlineCliCompletionClass::COMPLETION_CLASS_CON in the output and the test still passes, since class constant is matched against the echoed public const line above it.
Giving the constant a value that differs from its declaration, say "CLASSCONST_OK\n", separates the two. The underlying completion bug is noted in the main thread.
There was a problem hiding this comment.
This is a bug in the readline extension. I will deal this in a separate PR to make git log useful, as the main purpose of this PR is to add behavioral tests to the readline CLI.
ext/readline/readline_cli.c has little tests resulting to a 42% test coverage. There ain't any (or very few) behavioral tests to the whole CLI system. The test coverage is only coming from bug regression tests.
This PR offers basic behavior tests for ext/readline/readline_cli.c