Skip to content

Commit

Permalink
sign: Hide tests behind feature
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
julienvincent committed Feb 20, 2024
1 parent 84685a4 commit 42c543c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Build
run: cargo build --workspace --all-targets --verbose ${{ matrix.cargo_flags }}
- name: Test
run: cargo test --workspace --all-targets --verbose ${{ matrix.cargo_flags }}
run: cargo test --workspace --all-targets --features signing-tests --verbose ${{ matrix.cargo_flags }}
env:
RUST_BACKTRACE: 1

Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
version = "unstable-${self.shortRev or "dirty"}";

buildFeatures = [ "packaging" ];
checkFeatures = [ "packaging" "signing-tests" ];
cargoBuildFlags = ["--bin" "jj"]; # don't build and install the fake editors
useNextest = true;
src = filterSrc ./. [
Expand Down
1 change: 1 addition & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ testutils = { workspace = true }
tokio = { workspace = true, features = ["full"] }

[features]
signing-tests = []
default = []
vendored-openssl = ["git2/vendored-openssl"]
watchman = ["dep:tokio", "dep:watchman_client"]
Expand Down
15 changes: 15 additions & 0 deletions lib/tests/test_gpg.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright 2023 The Jujutsu Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#![cfg(feature = "signing-tests")]

#[cfg(unix)]
use std::fs::Permissions;
use std::io::Write;
Expand Down
1 change: 1 addition & 0 deletions lib/tests/test_ssh_signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#![cfg(feature = "signing-tests")]

use std::fs;
#[cfg(unix)]
Expand Down

0 comments on commit 42c543c

Please sign in to comment.