Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help hints at JSON formatting output with --out-file option #537

Closed
wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 2, 2024

Changelog

Documents JSON-formatted output in CLI's help.

- description: |
    <insert-changelog-description-here>
# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
  # - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  - improvement    # QoL changes e.g. refactoring
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

This is a very minor change to the documentation whose presence could have a saved me a few hours of head-banging. I wasn't aware (or forgot) one could get JSON-formatted output from the query utxo command and therefore coded a parser for UTxOs 🤦

I am not sure where this information is readily available, but having it as part of the command-line help seems useful.

How to trust this PR

🤔

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

Copy link
Contributor

@carbolymer carbolymer left a comment

Choose a reason for hiding this comment

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

Thanks. You need to delete and regenerate golden file test/cardano-cli-golden/files/golden/help/shelley_address_key-hash.cli to make the test pass:

CREATE_GOLDEN_FILES=1 cabal test

@ghost
Copy link
Author

ghost commented Jan 3, 2024

@carbolymer I am trying to fix the golden files but it's slightly annoying because I need to run the test, check the error, remove the file, and run again to get the next error. I wanted to refactor the test to use conjoin so that all golden checks are checked as a single property, in the hope of being able to get all the errors at once but this function is specific to QuickCheck.
What would be the right way to do this with Hedgehog/Tasty?

@newhoggy
Copy link
Contributor

newhoggy commented Jan 3, 2024

I propose to use RECREATE_GOLDEN_FILES=1 cabal test, the support for which is provided by this PR input-output-hk/hedgehog-extras#54

This way you should be able to run the test once and manually spot check every golden file that was changed to check if the change was intended.

@ghost
Copy link
Author

ghost commented Jan 3, 2024

🤔 Does RECREATE_GOLDEN_FILES recreates only the failing golden files, or does it recreate all of them? Should I wait for the change to be merged, released and the library updated here to fix the PR?

Copy link
Contributor

@carbolymer carbolymer left a comment

Choose a reason for hiding this comment

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

I'm sorry, but I have to block this change. Our current serialization is in a bit messy state, so we're not guaranteeing that file will contain JSON and stdout will be human readable.

The description you're proposing would be misleading for some commands. An example: cardano-cli query ledger-state:

which behaves in an opposite way.

@ghost
Copy link
Author

ghost commented Jan 3, 2024

@carbolymer I completely understand, no worries. Let me just close this and revisit at better times.

@ghost ghost closed this Jan 3, 2024
@newhoggy
Copy link
Contributor

newhoggy commented Jan 4, 2024

🤔 Does RECREATE_GOLDEN_FILES recreates only the failing golden files, or does it recreate all of them?

It will recreate all of them, but the effect should be the same because passing golden tests will generate golden files that are identical to what is already there anyway.

@ghost
Copy link
Author

ghost commented Jan 4, 2024

It will recreate all of them, but the effect should be the same because passing golden tests will generate golden files that are identical to what is already there anyway.

Oh right, they are using the same seed 🤦

This pull request was closed.
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