Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions .justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

clippy := "cargo clippy --quiet --workspace --no-deps --all-targets"
clippy_args := "-D warnings"
nextest_args := "--locked --workspace"
udeps_args := "--quiet --workspace --all-features --all-targets"

# Perform all checks
[parallel]
check: spell fmt fmt-readme doc lints deps unused-deps recipes test integration-test
check: spell fmt fmt-readme doc lints deps unused-deps recipes test readme-shell

# Check spelling
[group('ci')]
Expand Down Expand Up @@ -94,23 +93,24 @@ unused-deps:
cargo +nightly machete

# Run unit tests
[metadata('pacman', 'cargo-nextest')]
[metadata('pacman', 'maturin', 'python', 'uv')]
test:
#!/usr/bin/bash
set -euxo pipefail

uv venv .venv
# shellcheck disable=SC1091
source .venv/bin/activate
maturin develop
if [ "${CI:-}" = "true" ]; then
PROFILE=ci
mkdir -p target/pytest
uv run --group test -- pytest --junit-xml=target/pytest/junit.xml tests/
else
PROFILE=default
uv run --group test -- pytest tests/
fi

cargo +nightly nextest run {{ nextest_args }} --profile "$PROFILE"
cargo +nightly nextest run --no-default-features {{ nextest_args }} --profile "$PROFILE"

# Run integration tests
# Run readme shell snippets
[metadata('pacman', 'git', 'jq', 'openssh', 'tangler', 'tree')]
integration-test:
readme-shell:
#!/usr/bin/bash
set -euo pipefail
cargo +nightly build --locked
Expand All @@ -119,8 +119,8 @@ integration-test:

# Report on all tests
[group('ci')]
[metadata('gitlabci-job', '{"coverage":"/Line coverage: ([0-9.]*)%/","artifacts":{"when":"always","reports":{"junit":"target/nextest/ci/junit.xml","metrics":"target/metrics.txt","coverage_report":{"coverage_format":"cobertura","path":"target/coverage.xml"}}}}')]
[metadata('pacman', 'rust', 'cargo-llvm-cov', 'rustup', 'python')]
[metadata('gitlabci-job', '{"coverage":"/Line coverage: ([0-9.]*)%/","artifacts":{"when":"always","reports":{"junit":"target/pytest/junit.xml","metrics":"target/metrics.txt","coverage_report":{"coverage_format":"cobertura","path":"target/coverage.xml"}}}}')]
[metadata('pacman', 'rust', 'cargo-llvm-cov', 'rustup', 'maturin', 'python', 'uv')]
report-test:
#!/usr/bin/bash
# enabling "x" here will garble text output that's parsed by GitLab for code coverage
Expand All @@ -129,10 +129,10 @@ report-test:
rustup component add --toolchain nightly llvm-tools-preview

# shellcheck disable=SC1090
source <(cargo +nightly llvm-cov show-env --export-prefix --doctests --branch)
source <(cargo +nightly llvm-cov show-env --export-prefix --branch)
cargo +nightly llvm-cov clean

just test integration-test
RUSTUP_TOOLCHAIN=nightly just test

# explicitly use "target" (even if CARGO_TARGET_DIR is somewhere else) so that
# local tools (such as https://github.com/ryanluker/vscode-coverage-gutters) can find the file
Expand Down Expand Up @@ -233,10 +233,10 @@ fix:
# fmt must be last as clippy changes may break formatting
cargo +nightly fmt --all

# Run README integration tests
# Run README code snippets
[group('ci')]
[metadata('pacman', 'rust', 'python', 'tangler')]
readme:
readme-python:
#!/usr/bin/env bash
set -euo pipefail

Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ repository = "https://github.com/wiktor-k/pysequoia"
issues = "https://github.com/wiktor-k/pysequoia/issues"
funding = "https://github.com/sponsors/wiktor-k"

[dependency-groups]
test = ["pytest"]

[tool.mypy]
# There are a couple of minor issues in the generated stub files that mypy
# doesn't like. Suppressing these warnings.
Expand Down
10 changes: 0 additions & 10 deletions src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,3 @@ impl Sig {
)
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_reading_sig() {
Sig::from_packets(PacketParser::from_file("tests/fixtures/sig.pgp").unwrap()).unwrap();
}
}
44 changes: 0 additions & 44 deletions src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,47 +152,3 @@ impl VerificationHelper for PyVerifier {
}
}
}

#[cfg(test)]
mod tests {
use sequoia_openpgp::Cert;

use super::*;

#[test]
fn verify_compressed_signature() {
Python::initialize();
Python::attach(|py| {
#[pyfunction]
fn test(_key_ids: Vec<String>) -> Vec<crate::cert::Cert> {
vec![crate::cert::Cert::from(
Cert::from_file("tests/fixtures/compressed-pubkey.pgp")
.expect("reading pubkey for compressed signature works"),
)]
}
let f = pyo3::wrap_pyfunction!(test)(py).expect("wrapping pyfunction works");
let bytes = std::fs::read("tests/fixtures/compressed-sig.pgp")
.expect("reading compressed signature from disk works");

verify(Some(&bytes), Some(f.into()), None, None).expect("verification to succeed");
});
}

#[test]
fn verify_example_from_readme() {
Python::initialize();
Python::attach(|py| {
#[pyfunction]
fn test(_key_ids: Vec<String>) -> Vec<crate::cert::Cert> {
vec![crate::cert::Cert::from(
Cert::from_file("tests/fixtures/signing-key.asc")
.expect("signing key reading succeeds"),
)]
}
let f = pyo3::wrap_pyfunction!(test)(py).expect("wrapping pyfunction works");
let bytes = b"-----BEGIN PGP MESSAGE-----\n\nxA0DAAoWhjdbhUuGrPkByxdiAAAAAABkYXRhIHRvIGJlIHNpZ25lZMK9BAAWCgBv\nBYJp6ftzCRCGN1uFS4as+UcUAAAAAAAeACBzYWx0QG5vdGF0aW9ucy5zZXF1b2lh\nLXBncC5vcmc3UxaVh0GrzpGDSqwKe1nVnBGmDiTYQC/rYRhi3yQ/2BYhBK/PVAXo\n9J281dxUioY3W4VLhqz5AAD9hAEA1HX+UXFdqAwgRXH0g3+qN85spOnG1aiuML1N\nlXgKeTwBAO2QVu2VLjpFnFu8zZ12V0iRqA1xLUxkZyqburTeTlMM\n=y77Y\n-----END PGP MESSAGE-----\n";

verify(Some(bytes), Some(f.into()), None, None).expect("verification to succeed");
});
}
}
Loading
Loading