robotframework-difflibrary icon indicating copy to clipboard operation
robotframework-difflibrary copied to clipboard

Diff command outputs against text file

Open petercelentano opened this issue 9 years ago • 6 comments

Instead of diffing two text files against each other, I am attempting to diff the output of a command against a text file. The following excerpt from a robot file does not seem to work:

Diff Files <(cat foo.txt) bar.txt

The output of this robot file excerpt is:

test | FAIL | <(cat foo.txt) doesn't exist

Should this usage work out of the box, or is it necessary to add this functionality?

Thank you!

petercelentano avatar Sep 14 '16 16:09 petercelentano

@petercelentano i would suggest like this

Diff two files with content as the second file is different
    ${filename} =  Generate Random String   8  [LOWER]
    ${content} =  Get File  ${datadir}/loremipsum.txt
    Create File  ${TEMPDIR}/${filename}.txt  ${content}
    Run Keyword And Expect Error  *differences*   Diff Files  ${TEMPDIR}/${filename}.txt   ${datadir}/${/}loremipsum3.txt

vkosuri avatar Oct 18 '16 06:10 vkosuri

@petercelentano any updates?

vkosuri avatar Oct 20 '16 04:10 vkosuri

@vkosuri This was the solution I came up with:

Run Process ls - la /home/user > /opt/test/ls-la.test.txt shell=True
Diff Files /opt/test/ls-la.test.txt /opt/expected/ls-la.txt

I'm first running the command I want to diff and sending stout to a file. Then I'm running the diff of that file against an expected output.

I would prefer to diff without having to create a file from the command output first though.

petercelentano avatar Oct 20 '16 20:10 petercelentano

@petercelentano are looking something like this feature? You could try with pull #7

vkosuri avatar Oct 21 '16 04:10 vkosuri

@petercelentano any updates?

vkosuri avatar Oct 25 '16 06:10 vkosuri

What is the syntax for using this feature? Is it any different than what is posted above?

petercelentano avatar Oct 25 '16 13:10 petercelentano