This is an automated email from the ASF dual-hosted git repository.
PsiACE pushed a commit to branch chore/xtask-download-serde-data
in repository https://gitbox.apache.org/repos/asf/datasketches-rust.git
The following commit(s) were added to
refs/heads/chore/xtask-download-serde-data by this push:
new 2d99a09 refactor: simplify serialization snapshot selection
2d99a09 is described below
commit 2d99a09b8e940c0b187359cc4cd165e400ab325e
Author: Chojan Shang <[email protected]>
AuthorDate: Tue Jul 28 16:40:40 2026 +0800
refactor: simplify serialization snapshot selection
---
xtask/src/test_data.rs | 47 ++++++++++++++++++-----------------------------
1 file changed, 18 insertions(+), 29 deletions(-)
diff --git a/xtask/src/test_data.rs b/xtask/src/test_data.rs
index 57bb3a5..8ba3131 100644
--- a/xtask/src/test_data.rs
+++ b/xtask/src/test_data.rs
@@ -74,42 +74,31 @@ fn extract_snapshots<R: Read + Seek>(
destination: &Path,
language: &str,
) -> Result<()> {
- let source_suffix = ["serialization", language, "snapshots"];
+ let source_directory =
Path::new("serialization").join(language).join("snapshots");
let mut members = Vec::new();
let mut expected_files = BTreeSet::new();
for index in 0..archive.len() {
let member = archive.by_index(index)?;
- let path = Path::new(member.name());
- let parent_matches = path
- .parent()
- .map(|parent| {
- parent
- .iter()
- .rev()
- .take(source_suffix.len())
- .zip(source_suffix.iter().rev())
- .all(|(actual, expected)| actual == *expected)
- && parent.iter().count() >= source_suffix.len()
- })
- .unwrap_or(false);
-
- if !member.is_dir()
- && path.extension().is_some_and(|extension| extension == "sk")
- && parent_matches
+ let Some(path) = member.enclosed_name() else {
+ continue;
+ };
+
+ if member.is_dir()
+ || path.extension().is_none_or(|extension| extension != "sk")
+ || path
+ .parent()
+ .is_none_or(|parent| !parent.ends_with(&source_directory))
{
- let Some(name) = path.file_name().map(ToOwned::to_owned) else {
- continue;
- };
- if !expected_files.insert(name.clone()) {
- return Err(format!(
- "duplicate {language} snapshot in archive: {}",
- Path::new(&name).display()
- )
- .into());
- }
- members.push((index, name));
+ continue;
}
+
+ let name = path
+ .file_name()
+ .expect("snapshot path has a file name")
+ .to_owned();
+ expected_files.insert(name.clone());
+ members.push((index, name));
}
if members.is_empty() {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]