craft-pst: name the test writer's feature test-support, with test-writer as its alias (#1383)

This commit is contained in:
.CooCoo authored and GitHub committed 2026-11-16 21:35:49 -05:00
1 parent d33b8a228f
commit d21fa0f65e
6 files changed
+47 -6

No files matched your search

Generated
+1
View File
@@ -2738,6 +2738,7 @@ dependencies = [
name = "craft-pst"
version = "0.1.0"
dependencies = [
"craft-pst",
"proptest",
]
+4 -1
View File
@@ -10,7 +10,9 @@ repository.workspace = true
[features]
# The test writer (`test_writer`): synthetic .pst files for the tests of code that reads them.
# A dev-dependency feature only.
test-writer = []
test-support = []
# The earlier name of `test-support`, kept as an alias that turns it on.
test-writer = ["test-support"]
[lints]
workspace = true
@@ -18,4 +20,5 @@ workspace = true
[dependencies]
[dev-dependencies]
craft-pst = { path = ".", features = ["test-support"] }
proptest = { workspace = true }
+2 -1
View File
@@ -53,7 +53,8 @@ is left out and named (`Error::Cap`).
## What is not here
- Writing. The `test-writer` feature has a writer of small synthetic files, for tests only.
- Writing. The `test-support` feature has a writer of small synthetic files, for tests only.
`test-writer` is an alias of `test-support`.
- Offline folders files with 4 KB pages (version 36) and files protected by Windows Information
Protection (version 37): `Error::UnsupportedVersion`.
- Text in a code page: `PropValue::String8` carries the bytes, and the caller decodes them in
+1 -1
View File
@@ -24,7 +24,7 @@ pub(crate) fn decode(method: Encryption, data: &mut [u8], bid: u64) {
}
/// Encodes `data` in place (the test writer's side).
#[cfg(any(test, feature = "test-writer"))]
#[cfg(any(test, feature = "test-support"))]
pub(crate) fn encode(method: Encryption, data: &mut [u8], bid: u64) {
match method {
Encryption::None => {}
+3 -3
View File
@@ -36,9 +36,9 @@ mod pst;
pub mod recur;
mod source;
/// The test writer: synthetic .pst files from invented folders and messages, for this crate's
/// tests and, through the `test-writer` feature (a dev-dependency only, never in a build that
/// ships), for the tests of the import that reads them.
#[cfg(any(test, feature = "test-writer"))]
/// tests and, through the `test-support` feature (a dev-dependency only, never in a build that
/// ships; `test-writer` is an alias of it), for the tests of the import that reads them.
#[cfg(any(test, feature = "test-support"))]
#[doc(hidden)]
#[path = "tests/writer.rs"]
#[allow(
+36
View File
@@ -0,0 +1,36 @@
//! The test writer used the way a dependent crate's tests use it: through the `test-support`
//! feature (or `test-writer`, its alias), from outside the crate.
use std::io::Cursor;
use craft_pst::test_writer::{FileSpec, FolderSpec, Layout, MessageSpec, build};
use craft_pst::{Encryption, Format, Pst};
#[test]
fn a_file_from_the_test_writer_opens() {
let spec = FileSpec {
layout: Layout::new(Format::Unicode, Encryption::Permute),
password: None,
password_ansi: false,
name: "Personal Folders".into(),
folders: vec![FolderSpec {
name: "Inbox".into(),
class: Some("IPF.Note".into()),
messages: vec![MessageSpec { class: "IPM.Note".into(), subject: "Lunch on Friday?".into(), ..Default::default() }],
children: Vec::new(),
}],
named: Vec::new(),
named_strings: Vec::new(),
};
let bytes = build(&spec);
let mut pst = Pst::open(Cursor::new(bytes.as_slice())).unwrap();
assert_eq!(pst.format(), Format::Unicode);
assert_eq!(pst.encryption(), Encryption::Permute);
assert_eq!(pst.store().unwrap().display_name.as_deref(), Some("Personal Folders"));
let tree = pst.walk_folders().unwrap();
let inbox = tree.folders.iter().find(|f| f.folder.name == "Inbox").unwrap();
let items = pst.items(inbox.folder.id).unwrap();
let subjects: Vec<Option<String>> = items.items.iter().map(|i| i.properties.text(0x0037)).collect();
assert_eq!(subjects, vec![Some("Lunch on Friday?".to_string())]);
}