Open mattmc3 opened 1 year ago
Your specific example worked for me, because by default the prompt is identified by $
(note the extra space).
This is the contents for the foo
file:
$ echo $HOME/.config/f* | sed "s|$HOME|\$HOME|"
$HOME/.config/fish
$
And then the clitest
run:
$ ./clitest foo
#1 echo $HOME/.config/f* | sed "s|$HOME|\$HOME|"
OK: 1 of 1 test passed
Adding an extra space to the output, makes it break:
$ echo $HOME/.config/f* | sed "s|$HOME|\$ HOME|"
$ HOME/.config/fish
$
But this is expected, since now the output line starts with a "prompt".
I guess there's only two options here:
Change the prompt to a string that is unique and won't appear in any output. Try something longer, e.g.: prompt$
.
Tweak the offending command output with sed
, making sure no prompt string appears in the line beginning.
On a side note, the idea of using sed
to tweak some special command outputs is already there in clitest own tests:
I have the following tests:
The first one works, but the second one fails because the output begins with a '$'. I could change the prompt symbol, but that doesn't seem viable for other output.
I'm wondering if there's a feature like adding leading backslash that would allow for this sort of test??