22// SPDX-License-Identifier: MIT OR Apache-2.0
33
44use crate :: { serialize:: serialize_report, SerializeError } ;
5+ #[ cfg( feature = "timestamps" ) ]
56use chrono:: { DateTime , FixedOffset } ;
67use indexmap:: map:: IndexMap ;
78#[ cfg( feature = "uuids" ) ]
@@ -41,6 +42,7 @@ pub struct Report {
4142 /// The time at which the first test in this report began execution.
4243 ///
4344 /// This is not part of the JUnit spec, but may be useful for some tools.
45+ #[ cfg( feature = "timestamps" ) ]
4446 pub timestamp : Option < DateTime < FixedOffset > > ,
4547
4648 /// The overall time taken by the test suite.
@@ -68,6 +70,7 @@ impl Report {
6870 name : name. into ( ) ,
6971 #[ cfg( feature = "uuids" ) ]
7072 uuid : None ,
73+ #[ cfg( feature = "timestamps" ) ]
7174 timestamp : None ,
7275 time : None ,
7376 tests : 0 ,
@@ -96,6 +99,7 @@ impl Report {
9699 }
97100
98101 /// Sets the start timestamp for the report.
102+ #[ cfg( feature = "timestamps" ) ]
99103 pub fn set_timestamp ( & mut self , timestamp : impl Into < DateTime < FixedOffset > > ) -> & mut Self {
100104 self . timestamp = Some ( timestamp. into ( ) ) ;
101105 self
@@ -174,6 +178,7 @@ pub struct TestSuite {
174178 pub failures : usize ,
175179
176180 /// The time at which the TestSuite began execution.
181+ #[ cfg( feature = "timestamps" ) ]
177182 pub timestamp : Option < DateTime < FixedOffset > > ,
178183
179184 /// The overall time taken by the TestSuite.
@@ -201,6 +206,7 @@ impl TestSuite {
201206 Self {
202207 name : name. into ( ) ,
203208 time : None ,
209+ #[ cfg( feature = "timestamps" ) ]
204210 timestamp : None ,
205211 tests : 0 ,
206212 disabled : 0 ,
@@ -215,6 +221,7 @@ impl TestSuite {
215221 }
216222
217223 /// Sets the start timestamp for the TestSuite.
224+ #[ cfg( feature = "timestamps" ) ]
218225 pub fn set_timestamp ( & mut self , timestamp : impl Into < DateTime < FixedOffset > > ) -> & mut Self {
219226 self . timestamp = Some ( timestamp. into ( ) ) ;
220227 self
@@ -318,6 +325,7 @@ pub struct TestCase {
318325 /// The time at which this test case began execution.
319326 ///
320327 /// This is not part of the JUnit spec, but may be useful for some tools.
328+ #[ cfg( feature = "timestamps" ) ]
321329 pub timestamp : Option < DateTime < FixedOffset > > ,
322330
323331 /// The time it took to execute this test case.
@@ -346,6 +354,7 @@ impl TestCase {
346354 name : name. into ( ) ,
347355 classname : None ,
348356 assertions : None ,
357+ #[ cfg( feature = "timestamps" ) ]
349358 timestamp : None ,
350359 time : None ,
351360 status,
@@ -369,6 +378,7 @@ impl TestCase {
369378 }
370379
371380 /// Sets the start timestamp for the test case.
381+ #[ cfg( feature = "timestamps" ) ]
372382 pub fn set_timestamp ( & mut self , timestamp : impl Into < DateTime < FixedOffset > > ) -> & mut Self {
373383 self . timestamp = Some ( timestamp. into ( ) ) ;
374384 self
@@ -557,6 +567,7 @@ pub struct TestRerun {
557567 /// The time at which this rerun began execution.
558568 ///
559569 /// This is not part of the JUnit spec, but may be useful for some tools.
570+ #[ cfg( feature = "timestamps" ) ]
560571 pub timestamp : Option < DateTime < FixedOffset > > ,
561572
562573 /// The time it took to execute this rerun.
@@ -590,6 +601,7 @@ impl TestRerun {
590601 pub fn new ( kind : NonSuccessKind ) -> Self {
591602 TestRerun {
592603 kind,
604+ #[ cfg( feature = "timestamps" ) ]
593605 timestamp : None ,
594606 time : None ,
595607 message : None ,
@@ -602,6 +614,7 @@ impl TestRerun {
602614 }
603615
604616 /// Sets the start timestamp for this rerun.
617+ #[ cfg( feature = "timestamps" ) ]
605618 pub fn set_timestamp ( & mut self , timestamp : impl Into < DateTime < FixedOffset > > ) -> & mut Self {
606619 self . timestamp = Some ( timestamp. into ( ) ) ;
607620 self
0 commit comments