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

sign: Hide tests behind feature #3100

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

julienvincent
Copy link
Contributor

@julienvincent julienvincent commented Feb 20, 2024

This adds a cargo feature signing-tests which is used to disable the gpg and ssh signing tests unless set.

This is done in order to avoid requiring all collaborators to have setup all the tools on their local machines that are required to test commit signing.


Not sure if this is the best way to address this.

Closes #3096

@julienvincent julienvincent force-pushed the jv/hide-signing-tests branch 2 times, most recently from 9052413 to 42c543c Compare February 20, 2024 10:44
@martinvonz
Copy link
Member

Not sure if this is the best way to address this.

I think I agree with @yuja's comment saying that this will mostly make people run these tests less (even if they have gpg and ssh installed) and not notice failures until CI.

@julienvincent
Copy link
Contributor Author

julienvincent commented Feb 20, 2024

I'll update this later this evening, and add some docs to the contributing section 👍🏻

@julienvincent
Copy link
Contributor Author

Sorry I didn't get a chance to address this today. Will tackle first thing in the morning.

@julienvincent
Copy link
Contributor Author

I updated to conditionally run only if gpg is installed. @yuja Please can you take a look.

Copy link
Contributor

@yuja yuja left a comment

Choose a reason for hiding this comment

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

Thanks!

lib/tests/test_gpg.rs Outdated Show resolved Hide resolved
lib/tests/test_gpg.rs Outdated Show resolved Hide resolved
}
test();
}

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: alternatively, this could be a declarative macro. I don't know which is better overall. Both approaches have pros and cons.

macro_rules! gpg_guard {
    () => {
        if Command::new("gpg").arg("--version").status().is_err() {
            eprintln!("Skipping because gpg is not installed on the system");
            return;
        }
    };
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice! Never used macros before. This looks nice to me will use this. Out of interest what would you consider the pros and cons in this context?

Copy link
Contributor

Choose a reason for hiding this comment

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

closure: + obvious control flow, - nesting
macro: + less noisy, - hidden return statement

This adds a guard to the gpg signing tests which will skip the test if
`gpg` is not installed on the system.

This is done in order to avoid requiring all collaborators to have setup
all the tools on their local machines that are required to test commit
signing.
@julienvincent julienvincent merged commit f97e929 into jj-vcs:main Feb 21, 2024
15 checks passed
@julienvincent julienvincent deleted the jv/hide-signing-tests branch February 21, 2024 13:22
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.

GPG signing tests fail on my machine (when gpg is not installed)
3 participants