1
1
// Copyright (c) The nextest Contributors
2
2
// SPDX-License-Identifier: MIT OR Apache-2.0
3
3
4
+ #[ cfg( feature = "timestamps" ) ]
4
5
use chrono:: DateTime ;
5
6
use goldenfile:: Mint ;
6
7
use owo_colors:: OwoColorize ;
@@ -13,9 +14,14 @@ use std::time::Duration;
13
14
fn fixtures ( ) {
14
15
let mut mint = Mint :: new ( "tests/fixtures" ) ;
15
16
17
+ #[ cfg( all( feature = "timestamps" , feature = "uuids" , feature = "strip-ansi" ) ) ]
16
18
let f = mint
17
19
. new_goldenfile ( "basic_report.xml" )
18
20
. expect ( "creating new goldenfile succeeds" ) ;
21
+ #[ cfg( not( any( feature = "timestamps" , feature = "uuids" , feature = "strip-ansi" ) ) ) ]
22
+ let f = mint
23
+ . new_goldenfile ( "basic_report_no_default_features.xml" )
24
+ . expect ( "creating new goldenfile succeeds" ) ;
19
25
20
26
let basic_report = basic_report ( ) ;
21
27
basic_report
@@ -25,13 +31,15 @@ fn fixtures() {
25
31
26
32
fn basic_report ( ) -> Report {
27
33
let mut report = Report :: new ( "my-test-run" ) ;
34
+ #[ cfg( feature = "timestamps" ) ]
28
35
report. set_timestamp (
29
36
DateTime :: parse_from_rfc2822 ( "Thu, 1 Apr 2021 10:52:37 -0800" )
30
37
. expect ( "valid RFC2822 datetime" ) ,
31
38
) ;
32
39
report. set_time ( Duration :: new ( 42 , 234_567_890 ) ) ;
33
40
34
41
let mut test_suite = TestSuite :: new ( "testsuite0" ) ;
42
+ #[ cfg( feature = "timestamps" ) ]
35
43
test_suite. set_timestamp (
36
44
DateTime :: parse_from_rfc2822 ( "Thu, 1 Apr 2021 10:52:39 -0800" )
37
45
. expect ( "valid RFC2822 datetime" ) ,
@@ -74,11 +82,13 @@ fn basic_report() -> Report {
74
82
. set_message ( "skipped message" ) ;
75
83
// no description to test that.
76
84
let mut test_case = TestCase :: new ( "testcase3" , test_case_status) ;
85
+ #[ cfg( feature = "timestamps" ) ]
77
86
test_case
78
87
. set_timestamp (
79
88
DateTime :: parse_from_rfc2822 ( "Thu, 1 Apr 2021 11:52:41 -0700" )
80
89
. expect ( "valid RFC2822 datetime" ) ,
81
- )
90
+ ) ;
91
+ test_case
82
92
. set_assertions ( 20 )
83
93
. set_system_out ( "testcase3 output" )
84
94
. set_system_err ( "testcase3 error" ) ;
@@ -138,6 +148,8 @@ fn basic_report() -> Report {
138
148
test_suite. add_property ( Property :: new ( "env" , "FOOBAR" ) ) ;
139
149
140
150
report. add_test_suite ( test_suite) ;
151
+ #[ cfg( feature = "uuids" ) ]
152
+ report. set_uuid ( uuid:: Uuid :: parse_str ( "0500990f-0df3-4722-bbeb-90a75b8aa6bd" ) . expect ( "uuid parsing succeeds" ) ) ;
141
153
142
154
report
143
155
}
0 commit comments