Skip to content

Commit 50878e5

Browse files
committed
fix the stuff i broke while merging
1 parent f0d8da5 commit 50878e5

File tree

7 files changed

+43
-47
lines changed

7 files changed

+43
-47
lines changed

Cargo.lock

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ name = "test_results_parser"
88
crate-type = ["cdylib", "rlib"]
99

1010
[dependencies]
11-
# Version 0.23 currently suffers from https://github.com/PyO3/pyo3/issues/4723
11+
anyhow = "1.0.94"
12+
base16ct = { version = "0.2.0", features = ["std"] }
13+
indexmap = "2.6.0"
1214
pyo3 = { version = "0.23.3", features = ["abi3-py312", "anyhow"] }
1315
quick-xml = "0.37.1"
1416
regex = "1.11.1"

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ dev-dependencies = [
2121
"pytest-cov>=6.0.0",
2222
"pytest-reportlog>=0.4.0",
2323
"maturin>=1.7.4",
24-
"msgpack>=1.1.0",
2524
]

src/compute_name.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
use crate::testrun::Framework;
12
use quick_xml::escape::unescape;
23
use std::{borrow::Cow, collections::HashSet};
34

4-
use crate::testrun::Framework;
5-
65
fn compute_pytest_using_filename(classname: &str, name: &str, filename: &str) -> String {
76
let path_components = filename.split('/').count();
87

src/raw_upload.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,12 @@ use crate::testrun::ParsingInfo;
1616
#[derive(Deserialize, Debug, Clone)]
1717
struct TestResultFile {
1818
filename: String,
19-
#[serde(skip_deserializing)]
20-
_format: String,
2119
data: String,
22-
#[serde(skip_deserializing)]
23-
_labels: Vec<String>,
2420
}
2521
#[derive(Deserialize, Debug, Clone)]
2622
struct RawTestResultUpload {
2723
#[serde(default)]
28-
network: Option<Vec<String>>,
24+
network: Option<HashSet<String>>,
2925
test_results_files: Vec<TestResultFile>,
3026
}
3127

@@ -57,10 +53,10 @@ fn serialize_to_legacy_format(readable_files: Vec<ReadableFile>) -> Vec<u8> {
5753
pub fn parse_raw_upload(raw_upload_bytes: &[u8]) -> anyhow::Result<(Vec<ParsingInfo>, Vec<u8>)> {
5854
let upload: RawTestResultUpload =
5955
serde_json::from_slice(raw_upload_bytes).context("Error deserializing json")?;
60-
let network: Option<HashSet<String>> = upload.network.map(|v| v.into_iter().collect());
56+
let network: Option<HashSet<String>> = upload.network;
6157

62-
let mut results: Vec<ParsingInfo> = Vec::new();
63-
let mut readable_files: Vec<ReadableFile> = Vec::new();
58+
let mut results: Vec<ParsingInfo> = Vec::with_capacity(upload.test_results_files.len());
59+
let mut readable_files: Vec<ReadableFile> = Vec::with_capacity(upload.test_results_files.len());
6460

6561
for file in upload.test_results_files {
6662
let decoded_file_bytes = BASE64_STANDARD

tests/test_aggregation.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
from datetime import datetime, timezone
2+
import json
3+
import base64
4+
import zlib
25

36
from test_results_parser import (
4-
parse_junit_xml,
7+
parse_raw_upload,
58
AggregationReader,
69
BinaryFormatWriter,
710
)
811

912
def test_aggregation():
1013
with open("./tests/junit.xml", "br") as f:
1114
junit_file = f.read()
12-
parsed = parse_junit_xml(junit_file)
15+
16+
raw_upload = {
17+
"test_results_files": [
18+
{
19+
"filename": "test_results.json",
20+
"data": base64.b64encode(zlib.compress(junit_file)).decode("utf-8"),
21+
}
22+
]
23+
}
24+
25+
parsed, _ = parse_raw_upload(json.dumps(raw_upload).encode("utf-8"))
1326

1427
now = int(datetime.now(timezone.utc).timestamp())
1528

@@ -18,7 +31,7 @@ def test_aggregation():
1831
timestamp=now,
1932
commit_hash="e9fcd08652d091fa0c8d28e323c24fb0f4acf249",
2033
flags=["upload", "flags"],
21-
testruns=parsed.testruns,
34+
testruns=parsed[0]["testruns"],
2235
)
2336

2437
serialized = writer.serialize()

uv.lock

Lines changed: 0 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)