Skip to content

Commit b2fe203

Browse files
committed
make uuid an optional dependency
1 parent 04ab643 commit b2fe203

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ categories = ["encoding", "development-tools"]
1111
edition = "2021"
1212
rust-version = "1.70"
1313

14+
[features]
15+
default = ["uuids"]
16+
uuids = ["dep:uuid", "dep:newtype-uuid"]
17+
1418
[dependencies]
1519
chrono = { version = "0.4.41", default-features = false, features = ["std"] }
1620
indexmap = "2.7.1"
1721
quick-xml = "0.38.1"
18-
newtype-uuid = "1.2.4"
22+
newtype-uuid = { version = "1.2.4", optional = true }
1923
thiserror = "2.0.12"
2024
strip-ansi-escapes = "0.2.1"
21-
uuid = "1.17.0"
25+
uuid = { version = "1.17.0", optional = true }
2226

2327
[dev-dependencies]
2428
goldenfile = "1.7.3"

src/report.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
use crate::{serialize::serialize_report, SerializeError};
55
use chrono::{DateTime, FixedOffset};
66
use indexmap::map::IndexMap;
7+
#[cfg(feature = "uuids")]
78
use newtype_uuid::{GenericUuid, TypedUuid, TypedUuidKind, TypedUuidTag};
89
use std::{borrow::Borrow, hash::Hash, io, iter, ops::Deref, time::Duration};
10+
#[cfg(feature = "uuids")]
911
use uuid::Uuid;
1012

1113
/// A tag indicating the kind of report.
14+
#[cfg(feature = "uuids")]
1215
pub enum ReportKind {}
1316

17+
#[cfg(feature = "uuids")]
1418
impl TypedUuidKind for ReportKind {
1519
fn tag() -> TypedUuidTag {
1620
const TAG: TypedUuidTag = TypedUuidTag::new("quick-junit-report");
@@ -19,6 +23,7 @@ impl TypedUuidKind for ReportKind {
1923
}
2024

2125
/// A unique identifier associated with a report.
26+
#[cfg(feature = "uuids")]
2227
pub type ReportUuid = TypedUuid<ReportKind>;
2328

2429
/// The root element of a JUnit report.
@@ -30,6 +35,7 @@ pub struct Report {
3035
/// A unique identifier associated with this report.
3136
///
3237
/// This is an extension to the spec that's used by nextest.
38+
#[cfg(feature = "uuids")]
3339
pub uuid: Option<ReportUuid>,
3440

3541
/// The time at which the first test in this report began execution.
@@ -60,6 +66,7 @@ impl Report {
6066
pub fn new(name: impl Into<XmlString>) -> Self {
6167
Self {
6268
name: name.into(),
69+
#[cfg(feature = "uuids")]
6370
uuid: None,
6471
timestamp: None,
6572
time: None,
@@ -73,6 +80,7 @@ impl Report {
7380
/// Sets a unique ID for this `Report`.
7481
///
7582
/// This is an extension that's used by nextest.
83+
#[cfg(feature = "uuids")]
7684
pub fn set_report_uuid(&mut self, uuid: ReportUuid) -> &mut Self {
7785
self.uuid = Some(uuid);
7886
self
@@ -81,6 +89,7 @@ impl Report {
8189
/// Sets a unique ID for this `Report` from an untyped [`Uuid`].
8290
///
8391
/// This is an extension that's used by nextest.
92+
#[cfg(feature = "uuids")]
8493
pub fn set_uuid(&mut self, uuid: Uuid) -> &mut Self {
8594
self.uuid = Some(ReportUuid::from_untyped_uuid(uuid));
8695
self

src/serialize.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub(crate) fn serialize_report_impl(
5252
// Use the destructuring syntax to ensure that all fields are handled.
5353
let Report {
5454
name,
55+
#[cfg(feature = "uuids")]
5556
uuid,
5657
timestamp,
5758
time,
@@ -68,6 +69,7 @@ pub(crate) fn serialize_report_impl(
6869
("failures", failures.to_string().as_str()),
6970
("errors", errors.to_string().as_str()),
7071
]);
72+
#[cfg(feature = "uuids")]
7173
if let Some(uuid) = uuid {
7274
testsuites_tag.push_attribute(("uuid", uuid.to_string().as_str()));
7375
}

0 commit comments

Comments
 (0)