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

feat: forest-cli car concat #3150

Merged
merged 44 commits into from
Jul 17, 2023
Merged

feat: forest-cli car concat #3150

merged 44 commits into from
Jul 17, 2023

Conversation

hanabi1224
Copy link
Contributor

@hanabi1224 hanabi1224 commented Jul 7, 2023

Summary of changes

As part of #3081

Changes introduced in this pull request:

  • Impl forest-cli car concat subcommand

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Copy link
Contributor

@lemmih lemmih left a comment

Choose a reason for hiding this comment

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

Looks good. Soon we'll have more CAR commands: #3141

src/cli/subcommands/car_cmd.rs Outdated Show resolved Hide resolved
src/cli/subcommands/car_cmd.rs Outdated Show resolved Hide resolved
src/cli/subcommands/car_cmd.rs Outdated Show resolved Hide resolved
tests/car_tests.rs Outdated Show resolved Hide resolved
tests/car_tests.rs Outdated Show resolved Hide resolved
#[derive(Debug, Subcommand)]
pub enum CarCommands {
Concat {
first: PathBuf,
Copy link
Member

Choose a reason for hiding this comment

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

In general, what is preventing us from being more flexible here? That is to say, accept an arbitrary number of files, like the regular cat command. It should be straightforward to do with the existing code at no extra mental overhead cost.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this is feasible, fixed

src/cli/subcommands/car_cmd.rs Outdated Show resolved Hide resolved
src/cli/subcommands/car_cmd.rs Outdated Show resolved Hide resolved
use crate::common::cli;

#[tokio::test]
async fn forest_cli_car_concat() -> Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think these tests are useful. Correct me if I'm wrong, but they just check if the output file is a valid CAR file, right? I can imagine lots of incorrect implementations that would pass these tests.

Let's either remove the tests or make them more rigorous.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unlike unit tests, the main purpose of these bin tests ensure the executable runs without failures, and the assertions ensure the output file exists and can be parsed by CarReader. Any suggestions on adding more checks of the output car file?

Copy link
Contributor

Choose a reason for hiding this comment

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

Would love unit tests that didn't use any files at all.

This PR is about a function that computes the union of a list of sets. We can test that thoroughly with quickcheck. Generate arbitrary sets of data and verify that the union contains all the elements of the input sets with no duplicates.

∀AB. A⊆(A∪B)
∀AB. B⊆(A∪B)
∀AB. A∪B = B∪A
∀ABC. (A ∪ B) ∪ C = A ∪ (B ∪ C)
∀A. A∪A = A

Copy link
Contributor

Choose a reason for hiding this comment

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

asides:

  • I think we should invest in some mock IPLD/ car creation utils rather than checking in test files
  • I think we should have better guidelines on when and where to write integration tests. Part of the "engineering values" piece

hanabi1224 and others added 2 commits July 13, 2023 18:40
Co-authored-by: David Himmelstrup <david.himmelstrup@chainsafe.io>
CHANGELOG.md Outdated Show resolved Hide resolved
@aatifsyed aatifsyed removed the request for review from ruseinov July 14, 2023 08:39
hanabi1224 and others added 2 commits July 17, 2023 20:51
Co-authored-by: David Himmelstrup <david.himmelstrup@chainsafe.io>
@hanabi1224 hanabi1224 requested a review from a team as a code owner July 17, 2023 12:52
@hanabi1224 hanabi1224 added this pull request to the merge queue Jul 17, 2023
Merged via the queue into main with commit 1b21b3c Jul 17, 2023
20 checks passed
@hanabi1224 hanabi1224 deleted the hm/car-concat branch July 17, 2023 13:46
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.

None yet

4 participants