Skip to content

Conversation

@szg251
Copy link
Collaborator

@szg251 szg251 commented Jul 20, 2022

CLI commands are pretty long, and can be hard to find the differences, so I added some pretty diff there.
Example result:

    Send ada to address without change:                            FAIL (0.09s)
      test/Spec/BotPlutusInterface/Contract.hs:907:
      command at index 8 was incorrect:

      Expected:
                                          ▼ ▼▼▼▼▼
      cardano-cli transaction build-raw --babbage-era --tx-in e406b0cf676fc2b1a9edb061
      7f259ad025c20ea6f0333820aa7cef1bfe7302e5#0 --tx-out addr1vyxk54m7j3q6mrkevcunryr
      wf4p7e68c93cjk8gzxkhlkpsjpczl2+1000 --required-signer ./signing-keys/signing-key
      -cb9358529df4729c3246a2a033cb9821abbfd16de4888005904abc41.skey --fee 200 --proto
                                                          ▼
      col-params-file ./protocol.json --out-file ./txs/tx-?.raw
      Got:
      cardano-cli transaction build-raw --alonzo-era --tx-in e406b0cf676fc2b1a9edb0617
                                           ▲▲▲▲▲
      f259ad025c20ea6f0333820aa7cef1bfe7302e5#0 --tx-out addr1vyxk54m7j3q6mrkevcunryrw
      f4p7e68c93cjk8gzxkhlkpsjpczl2+1000 --required-signer ./signing-keys/signing-key-
      cb9358529df4729c3246a2a033cb9821abbfd16de4888005904abc41.skey --fee 200 --protoc
      ol-params-file ./protocol.json --out-file ./txs/tx-4862b799cba361cb2df20a66daf4d
                                                         ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
      d04190cbd1cb73e4b9562a5e891493345e5.raw
      ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲

@szg251 szg251 requested a review from zmrocze July 20, 2022 07:34
prettyPrintDiff :: Text -> Text -> String
prettyPrintDiff expected actual =
"\nExpected:\n"
++ Text.unpack (Diff.above (Wrap 80) FullContext (Text.replace "\n" " " expected) actual)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are "\n" being removed only from the expected?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual doesn't include any new lines. Of course we could add it, but it wouldn't have any effect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that this function will only be used to compare CLI commands.

@szg251 szg251 requested a review from nazrhom July 21, 2022 09:24
@szg251 szg251 merged commit 2983fdb into master Jul 21, 2022
@szg251 szg251 deleted the gergely/pretty-print-test-diff branch July 21, 2022 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants