aiiie / cram

Functional tests for command line applications
GNU General Public License v2.0
199 stars 51 forks source link

Are "here documents" supported? #46

Open srasku opened 2 years ago

srasku commented 2 years ago

This didn't work but maybe I setup something wrong.

$ cat test/here-doc.t
  $ ls -a
  .
  ..
  $ cat >> config <<-EOF
        [section]
        name=value
  EOF
  $ cat config
  [section]
  name=value

$ cram -i test/here-doc.t
!
--- test/here-doc.t
+++ test/here-doc.t.err
@@ -4,7 +4,4 @@
   $ cat >> config <<-EOF
        [section]
        name=value
-  EOF
   $ cat config
-  [section]
-  name=value
Accept this change? [yN]

I have version 0.7 installed via pip

$ cram --version
Cram CLI testing framework (version 0.7)

Copyright (C) 2010-2016 Brodie Rao <brodie@bitheap.org> and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
tsibley commented 2 years ago

@srasku Ran across this and have an answer for you since I'd figured out heredocs in cram a while back.

$ cat /tmp/heredoc.t 
Heredocs are supported, but you must still use cram's command continuation char (>):

  $ cat >config <<-EOF
  > [section]
  > name=value
  > EOF

  $ cat config
  [section]
  name=value
$ cram /tmp/heredoc.t 
.
# Ran 1 tests, 0 skipped, 0 failed.