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

Separate tar archive and tar flags #492

Merged
merged 2 commits into from
Apr 18, 2021

Conversation

deantvv
Copy link
Contributor

@deantvv deantvv commented Apr 11, 2021

It used to have one flag (-r) to enable both tar archive and tar.
Now it has two flags [ -r: for tar, -g: for tar archive].

Related to #451

It used to have one flag (-r) to enable both tar archive and tar.
Now it has two flags [ -r: for tar, -g: for tar archive].

Related to svenstaro#451
@deantvv deantvv closed this Apr 12, 2021
@deantvv deantvv reopened this Apr 12, 2021
@deantvv
Copy link
Contributor Author

deantvv commented Apr 14, 2021

@svenstaro Could you take a look at this? Thanks in advance.

@svenstaro
Copy link
Owner

Will do, sorry, pretty busy these days.

Copy link
Owner

@svenstaro svenstaro left a comment

Choose a reason for hiding this comment

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

I really like this and would basically accept it as is code-wise but I'd really like to distinguish the terminology here: Let's call uncompressed tarballs uncompressed tar archives and compressed ones gz-compressed tar archives for the sake of being able to add on more compression methods later on without it being to confusing sounding.

Keep in mind: tar are always archives, whether they are compressed or not.

Copy link
Owner

@svenstaro svenstaro left a comment

Choose a reason for hiding this comment

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

As per my other longer comment, I gave you some in-code hints for what I mean. Could you change that code and the rest of your changes to conform to those suggestions?

src/archive.rs Outdated Show resolved Hide resolved
src/args.rs Outdated Show resolved Hide resolved
src/args.rs Outdated Show resolved Hide resolved
Use following terminology:
	uncompressed tarballs => `uncompressed tar archives`
	compressed ones => `gz-compressed tar archives`
match self {
CompressionMethod::TarGz => tar_gz_enabled,
Copy link
Owner

Choose a reason for hiding this comment

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

Come to think of it, it probably wasn't proper of me to go with CompressionMethod here as it should really have been ArchiveMethod from the beginning. Oh well, might change this after merging your PR. :)

@deantvv
Copy link
Contributor Author

deantvv commented Apr 18, 2021

I really like this and would basically accept it as is code-wise but I'd really like to distinguish the terminology here: Let's call uncompressed tarballs uncompressed tar archives and compressed ones gz-compressed tar archives for the sake of being able to add on more compression methods later on without it being to confusing sounding.

Keep in mind: tar are always archives, whether they are compressed or not.

Thanks for the suggestions and fixing the wrong terminology. It is now fixed in c9506c7.

@svenstaro
Copy link
Owner

Cool stuff! Will merge right once CI passes.


sleep(Duration::from_secs(1));

// Ensure the links to the tar archive exists and tar not exists
Copy link
Owner

Choose a reason for hiding this comment

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

One small thing I just found:
// Ensure the links to the compressed tar archive exists and link to plain tar doesn't exist

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am happy to fix this. But since you already merge this, should I still change this?

assert!(parsed.find(Text).any(|x| x.text() == "Download .tar.gz"));
assert!(parsed.find(Text).all(|x| x.text() != "Download .tar"));

// Try to download, only tar_gz should works
Copy link
Owner

Choose a reason for hiding this comment

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

// Try to download, only tar.gz should work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above.

@@ -51,3 +51,44 @@ fn archives_are_disabled(tmpdir: TempDir, port: u16) -> Result<(), Error> {

Ok(())
}

#[rstest]
Copy link
Owner

Choose a reason for hiding this comment

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

If you wanna do something cool here, you could use rstest for test parameterization to test -p and -g with very little test code overhead. Want to give that a try?

Copy link
Owner

Choose a reason for hiding this comment

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

Actually, on second thought, I want to more properly clean up these tests anyhow. I'll just do that after merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can try in maybe another PR?

Copy link
Owner

Choose a reason for hiding this comment

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

Sure, if you like, that'd be much appreciated. So what I'm thinking here: Have a single parametrized test in tests/archive.rs that would test for all possible combinations of compression flags whether the path is reachable whether the links are being rendered. Thanks to rstest, we'd end up with a bunch of separately generated distinct tests. I think that'd be rather clean and make quite a bit of sense. Wanna give it a shot?

Take a look at: https://docs.rs/rstest/0.7.0/rstest/attr.rstest.html#test-parametrized-cases

@svenstaro svenstaro merged commit f645c2b into svenstaro:master Apr 18, 2021
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.

2 participants