Skip to content

Commit e0a46fa

Browse files
committed
sign: move TestSigningBackend to lib
We need to make `TestSigningBackend` available for cli tests, as we are implementing the `jj sign` command in following changes.
1 parent b70c700 commit e0a46fa

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

lib/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ pub mod stacked_table;
8686
pub mod store;
8787
pub mod str_util;
8888
pub mod submodule_store;
89+
#[cfg(feature = "testing")]
90+
pub mod test_signing_backend;
8991
pub mod time_util;
9092
pub mod transaction;
9193
pub mod tree;

lib/src/signing.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ use crate::backend::CommitId;
2525
use crate::gpg_signing::GpgBackend;
2626
use crate::settings::UserSettings;
2727
use crate::ssh_signing::SshBackend;
28+
#[cfg(feature = "testing")]
29+
use crate::test_signing_backend::TestSigningBackend;
2830

2931
/// A status of the signature, part of the [Verification] type.
3032
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -167,6 +169,9 @@ impl Signer {
167169
// Box::new(X509Backend::from_settings(settings)?) as Box<dyn SigningBackend>,
168170
];
169171

172+
#[cfg(feature = "testing")]
173+
backends.push(Box::new(TestSigningBackend) as Box<dyn SigningBackend>);
174+
170175
let main_backend = settings
171176
.signing_backend()
172177
.map(|backend| {

lib/testutils/src/test_signing_backend.rs renamed to lib/src/test_signing_backend.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// Copyright 2023 The Jujutsu Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
//! Generic APIs to work with cryptographic signatures created and verified by
16+
//! various backends.
17+
118
use hex::ToHex;
219
use jj_lib::content_hash::blake2b_hash;
320
use jj_lib::signing::SigStatus;
@@ -6,6 +23,7 @@ use jj_lib::signing::SignResult;
623
use jj_lib::signing::SigningBackend;
724
use jj_lib::signing::Verification;
825

26+
/// A test signing backend that uses a simple hash-based signature format.
927
#[derive(Debug)]
1028
pub struct TestSigningBackend;
1129

lib/tests/test_signing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use jj_lib::signing::SigStatus;
77
use jj_lib::signing::SignBehavior;
88
use jj_lib::signing::Signer;
99
use jj_lib::signing::Verification;
10+
use jj_lib::test_signing_backend::TestSigningBackend;
1011
use test_case::test_case;
1112
use testutils::create_random_commit;
12-
use testutils::test_signing_backend::TestSigningBackend;
1313
use testutils::write_random_commit;
1414
use testutils::TestRepoBackend;
1515
use testutils::TestWorkspace;

lib/testutils/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ use tempfile::TempDir;
6464
use crate::test_backend::TestBackendFactory;
6565

6666
pub mod test_backend;
67-
pub mod test_signing_backend;
6867

6968
pub fn hermetic_libgit2() {
7069
// libgit2 respects init.defaultBranch (and possibly other config

0 commit comments

Comments
 (0)